Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lockfile upload #401

Merged
merged 29 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d929963
Support creating lockfile envs
nkaretnikov Apr 29, 2024
d1c6f60
Remove redundant import
nkaretnikov Apr 29, 2024
e3a83d9
Update state
nkaretnikov Apr 29, 2024
42230f2
Remove workarounds that are no longer needed
nkaretnikov Apr 30, 2024
c7f4805
Handle `is_lockfile` in test
nkaretnikov Apr 30, 2024
b3fdfd8
Initial edit spec support
nkaretnikov Apr 30, 2024
fe424d5
Send updated spec to server
nkaretnikov Apr 30, 2024
e6bd472
Get channels from lockfile
nkaretnikov Apr 30, 2024
f346820
Get dependencies from lockfile
nkaretnikov Apr 30, 2024
d606a17
gabs edits
gabalafou May 5, 2024
7b0d4a8
Add warning about no syncing between lockfile and GUI
gabalafou May 7, 2024
6ebd16d
Revert unneeded changes
gabalafou May 14, 2024
c3705d9
Working proof of concept: lockfile upload
gabalafou May 15, 2024
61e5a40
Switch to lockfile/specification
gabalafou Jun 11, 2024
be078a2
Merge branch 'main' into lockfile-upload
gabalafou Jun 12, 2024
86008f6
Show dependencies and channels for lockfile-built envs
gabalafou Jun 18, 2024
54a1dd1
reset SpecificationEdit when switching builds
gabalafou Jun 18, 2024
fd9a585
Kim's suggestions
gabalafou Jul 9, 2024
9626ea0
Show installed dependencies and channels on view environment built fr…
gabalafou Jul 9, 2024
54bf876
lint
gabalafou Jul 9, 2024
2dd8c0a
yarn install
gabalafou Jul 9, 2024
dae542c
yarn install (with correct version of yarn this time)
gabalafou Jul 9, 2024
96b4311
note about file formats
gabalafou Jul 9, 2024
6d7a97b
lint
gabalafou Jul 9, 2024
be8b847
Three changes:
gabalafou Jul 23, 2024
bc3d29f
update yarn.lock
gabalafou Aug 9, 2024
46455ac
Fix Docker Compose for GitHub Actions
gabalafou Aug 9, 2024
0bea284
Merge branch 'main' into lockfile-upload
gabalafou Aug 9, 2024
912ad1f
Merge branch 'docker-compose-v2' into lockfile-upload
gabalafou Aug 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This guide will help you to set up your local development environment.

Before setting up conda-store-ui, you must prepare your environment.

We use [Docker Compose](https://docs.docker.com/compose/) to set up the infrastructure before starting ensure that you have docker-compose installed. If you need to install docker-compose, please see their [installation documentation](https://docs.docker.com/compose/install/)
We use [Docker Compose](https://docs.docker.com/compose/) to set up the infrastructure before starting ensure that you have Docker Compose installed. If you need to install Docker Compose, please see their [installation documentation](https://docs.docker.com/compose/install/)

1. Clone the [conda-store-ui](https://github.com/conda-incubator/conda-store-ui.git) repository.
2. Copy `.env.example` to `.env`. All default settings should work, but if you want to test against a different version of conda-store-server, you can specify if in the `.env` file by setting the `CONDA_STORE_SERVER_VERSION` variable to the desired version. Refer to the [Configuration documentation](https://conda-incubator.github.io/conda-store-ui/?path=/docs/docs-configuration--page) for more information on the `.env` file.
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

services:
conda-store-worker:
image: quansight/conda-store-server:${CONDA_STORE_SERVER_VERSION:-2024.3.1}
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"build:watch": "tsc --build --watch",
"clean": "rimraf coverage lib storybook-static types .env *.tsbuildinfo",
"clean:slate": "yarn run clean && rimraf node_modules",
"clean:docker": "docker-compose down -v --remove-orphans",
"clean:docker": "docker compose down -v --remove-orphans",
"eslint": "eslint . --ext .ts,.tsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx",
"prepare": "yarnpkg run build && husky install",
"prepublishOnly": "yarnpkg run clean && yarnpkg run webpack:prod",
"start:docker": "docker-compose --profile local-dev up --build",
"start:docker": "docker compose --profile local-dev up --build",
"start": "yarn run start:services && yarn run start:ui",
"start:services": "docker-compose up -d",
"start:services": "docker compose up -d",
"start:ui": "REACT_APP_VERSION=$npm_package_version webpack server --history-api-fallback",
"start:chromium": "webpack serve --open 'chromium'",
"start:prod": "NODE_ENV=production webpack serve",
Expand Down Expand Up @@ -70,6 +70,7 @@
"date-fns-tz": "^1.3.7",
"lodash": "^4.17.21",
"match-sorter": "^6.3.1",
"mui-file-dropzone": "^4.0.2",
"react": "^18.0.0",
"react-beautiful-dnd": "^13.1.0",
"react-dom": "^18.0.0",
Expand Down
4 changes: 3 additions & 1 deletion src/common/models/CondaSpecification.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { CondaSpecificationPip } from "./CondaSpecificationPip";
import type { CondaSpecificationPip } from "./CondaSpecificationPip";
import type { Lockfile } from "./Lockfile";

export type CondaSpecification = {
name: string;
channels: string[];
dependencies: (string | CondaSpecificationPip)[];
variables: Record<string, string>;
prefix?: string | null;
lockfile?: Lockfile;
};
2 changes: 2 additions & 0 deletions src/common/models/Lockfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// TODO: define lockfile type better
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth making an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, done! #413

export type Lockfile = Record<string, any>;
1 change: 1 addition & 0 deletions src/common/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from "./Artifact";
export * from "./BuildPackage";
export * from "./BuildArtifact";
export * from "./Namespace";
export * from "./Lockfile";
96 changes: 56 additions & 40 deletions src/components/BlockContainerEditMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import Grid from "@mui/material/Grid";
import Typography from "@mui/material/Typography";
import { CodeIcon } from "../components";
import { StyledSwitch } from "../styles";
import Button from "@mui/material/Button";
import UploadFileRoundedIcon from "@mui/icons-material/UploadFileRounded";

interface IBlockContainerProps {
title: string;
children: React.ReactNode;
onToggleEditMode: (show: boolean) => void;
isEditMode: boolean;
setShowDialog: (show: boolean) => void;
}

export const BlockContainerEditMode = ({
title,
children,
onToggleEditMode,
isEditMode
isEditMode,
setShowDialog
}: IBlockContainerProps) => {
return (
<Box
Expand Down Expand Up @@ -44,46 +48,58 @@ export const BlockContainerEditMode = ({
>
{title}
</Typography>
<Grid
component="label"
container
spacing={1}
justifyContent={"center"}
sx={{ width: "auto" }}
>
<Grid item sx={{ alignSelf: "baseline" }}>
<Typography
data-testid="block-container-title"
sx={{
fontSize: "14px",
color: "#333",
fontWeight: isEditMode ? "400" : "600"
}}
>
GUI
</Typography>
</Grid>
<Grid item sx={{ alignSelf: "baseline" }}>
<StyledSwitch
checked={isEditMode}
onClick={e => onToggleEditMode(!isEditMode)}
icon={<CodeIcon />}
checkedIcon={<CodeIcon />}
/>
</Grid>
<Grid item sx={{ alignSelf: "baseline" }}>
<Typography
data-testid="block-container-title"
sx={{
fontSize: "14px",
color: "#333",
fontWeight: isEditMode ? "600" : "400"
}}
>
YAML
</Typography>
<Box display="flex" alignItems="center">
<Button
variant="outlined"
color="secondary"
size="small"
startIcon={<UploadFileRoundedIcon />}
onClick={() => setShowDialog(true)}
sx={{ mx: "1em" }}
>
Switch to Conda Lockfile Upload
</Button>{" "}
<Grid
component="label"
container
spacing={1}
justifyContent={"center"}
sx={{ width: "auto" }}
>
<Grid item sx={{ alignSelf: "baseline" }}>
<Typography
data-testid="block-container-title"
sx={{
fontSize: "14px",
color: "#333",
fontWeight: isEditMode ? "400" : "600"
}}
>
GUI
</Typography>
</Grid>
<Grid item sx={{ alignSelf: "baseline" }}>
<StyledSwitch
checked={isEditMode}
onClick={e => onToggleEditMode(!isEditMode)}
icon={<CodeIcon />}
checkedIcon={<CodeIcon />}
/>
</Grid>
<Grid item sx={{ alignSelf: "baseline" }}>
<Typography
data-testid="block-container-title"
sx={{
fontSize: "14px",
color: "#333",
fontWeight: isEditMode ? "600" : "400"
}}
>
YAML
</Typography>
</Grid>
</Grid>
</Grid>
</Box>
</Box>
</Box>
<Box
Expand Down
17 changes: 12 additions & 5 deletions src/components/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import Button from "@mui/material/Button";
import Dialog from "@mui/material/Dialog";
import DialogActions from "@mui/material/DialogActions";
import DialogContent from "@mui/material/DialogContent";
Expand All @@ -12,14 +13,16 @@ interface IAlertDialog {
isOpen: boolean;
closeAction: () => void;
confirmAction: () => void;
confirmText?: string;
}

export const AlertDialog = ({
title,
description,
isOpen,
closeAction,
confirmAction
confirmAction,
confirmText = "Delete"
}: IAlertDialog) => {
return (
<Dialog open={isOpen} onClose={closeAction}>
Expand All @@ -45,11 +48,15 @@ export const AlertDialog = ({
</DialogContentText>
</DialogContent>
<DialogActions>
<StyledButton color="primary" onClick={closeAction}>
<Button color="secondary" onClick={closeAction}>
Cancel
</StyledButton>
<StyledButton color="primary" onClick={() => confirmAction()}>
Delete
</Button>
<StyledButton
color="primary"
onClick={() => confirmAction()}
sx={{ textTransform: "uppercase" }}
>
{confirmText}
</StyledButton>
</DialogActions>
</Dialog>
Expand Down
18 changes: 18 additions & 0 deletions src/components/LockfileSupportInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import Typography from "@mui/material/Typography";

export const LockfileSupportInfo = () => (
<Typography sx={{ fontSize: "12px" }}>
We currently only support the{" "}
<a
href="https://conda.github.io/conda-lock/"
target="_blank"
rel="noreferrer"
>
Conda lockfile
</a>{" "}
format. Other lockfile formats such as Poetry are not supported.
</Typography>
);

export default LockfileSupportInfo;
15 changes: 12 additions & 3 deletions src/features/channels/channelsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,22 @@ export const channelsSlice = createSlice({
{
payload: {
data: {
specification: {
spec: { channels }
}
specification: { spec }
}
}
}
) => {
let channels = [];

if (spec.channels) {
channels = spec.channels;
} else if (spec.lockfile?.metadata?.channels) {
channels = spec.lockfile.metadata.channels.map(
// Note: in the lockfile spec, a channel URL can be a string identifier like "conda-forge"
(channel: { url: string }) => channel.url
);
}

state.channels = channels;
}
);
Expand Down
5 changes: 4 additions & 1 deletion src/features/dependencies/components/Dependencies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ export const Dependencies = ({
<StyledAccordionSummary expandIcon={<ArrowIcon />}>
<StyledAccordionTitle sx={{ color: "primary.main" }}>
Installed Packages{" "}
<Tooltip title="Includes requested packages and their dependencies">
<Tooltip
title="Includes requested packages and their dependencies"
tabIndex={0}
>
<InfoOutlinedIcon
sx={{
fontSize: "20px",
Expand Down
27 changes: 20 additions & 7 deletions src/features/environmentCreate/components/EnvironmentCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,27 @@ export const EnvironmentCreate = () => {
dispatch(descriptionChanged(value));
}, 300);

const createEnvironment = async (code: ICreateEnvironmentArgs) => {
const createEnvironment = async (code: ICreateEnvironmentArgs | string) => {
const namespace = newEnvironment?.namespace;
const environmentInfo = {
namespace,
specification: `${stringify(
code
)}\ndescription: '${description}'\nname: ${name}\nprefix: null`
};
const isLockfile = typeof code === "string";

let environmentInfo;
if (isLockfile) {
environmentInfo = {
namespace,
specification: code,
environment_name: name,
environment_description: description,
is_lockfile: true
};
} else {
environmentInfo = {
namespace,
specification: `${stringify(
code
)}\ndescription: '${description}'\nname: ${name}\nprefix: null`
};
}

try {
const { data } = await createOrUpdate(environmentInfo).unwrap();
Expand Down
Loading
Loading