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

Add dstack UI #1524

Merged
merged 7 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
31 changes: 29 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,29 @@ jobs:
- run: python -m pip install pre-commit
- run: pre-commit run -a --show-diff-on-failure

frontend-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install packages
run: npm install
- name: Build dist
run: npm run build
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: frontend-build
path: frontend/build

python-test:
needs: [ python-lint ]
needs: [ python-lint, frontend-build ]
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -49,8 +70,14 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install -U '.[all]' -r requirements_dev.txt
- name: Download frontend build
uses: actions/download-artifact@v4
with:
name: frontend-build
path: src/dstack/_internal/server/statics
- name: Run pytest
run: pytest src/tests
run: |
pytest src/tests --runui

update-get-dstack:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
Expand Down
88 changes: 57 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,59 @@ jobs:
runner/dstack-runner-${{ matrix.goos }}-${{ matrix.goarch }}
runner/dstack-shim-${{ matrix.goos }}-${{ matrix.goarch }}

gateway-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: gateway
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install AWS
run: pip install awscli
- name: Install dependencies
run: pip install wheel build
- name: Store version
run: echo VERSION=${GITHUB_REF#refs/tags/} > $GITHUB_ENV
- name: Build package
run: |
echo "__version__ = \"${{ env.VERSION }}\"" > src/dstack/gateway/version.py
python -m build .
- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
WHEEL=dstack_gateway-${{ env.VERSION }}-py3-none-any.whl
aws s3 cp dist/$WHEEL "s3://dstack-gateway-downloads/release/$WHEEL"
echo "${{ env.VERSION }}" | aws s3 cp - "s3://dstack-gateway-downloads/release/latest-version"

frontend-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install packages
run: npm install
- name: Build dist
run: npm run build
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: frontend-build
path: frontend/build

runner-upload:
needs: [gateway-build, runner-compile]
needs: [runner-compile, gateway-build, frontend-build]
runs-on: ubuntu-latest
steps:
- name: Install AWS
Expand Down Expand Up @@ -138,6 +189,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Download frontend build
uses: actions/download-artifact@v4
with:
name: frontend-build
path: src/dstack/_internal/server/statics
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -237,33 +293,3 @@ jobs:
aws s3 cp configuration.json "s3://dstack-runner-downloads/latest/schemas/configuration.json" --acl public-read
aws s3 cp profiles.json "s3://dstack-runner-downloads/latest/schemas/profiles.json" --acl public-read
fi

gateway-build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: gateway
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install AWS
run: pip install awscli
- name: Install dependencies
run: pip install wheel build
- name: Store version
run: echo VERSION=${GITHUB_REF#refs/tags/} > $GITHUB_ENV
- name: Build package
run: |
echo "__version__ = \"${{ env.VERSION }}\"" > src/dstack/gateway/version.py
python -m build .
- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
WHEEL=dstack_gateway-${{ env.VERSION }}-py3-none-any.whl
aws s3 cp dist/$WHEEL "s3://dstack-gateway-downloads/release/$WHEEL"
echo "${{ env.VERSION }}" | aws s3 cp - "s3://dstack-gateway-downloads/release/latest-version"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ dist/
/runner/cmd/shim/shim
/runner/cmd/runner/runner

/src/dstack/_internal/server/statics

build/
.DS_Store
.fleet
Expand Down
35 changes: 35 additions & 0 deletions frontend/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": "last 2 versions"
}
}
],
"@babel/preset-typescript",
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-class-properties"
],
"env": {
"development": {
"plugins": ["react-refresh/babel"]
},
"production": {
"presets": [
[
"minify",
{
"builtIns": false,
"evaluate": false,
"mangle": false
}
]
]
}
}
}
10 changes: 10 additions & 0 deletions frontend/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
build
server.js
src/locale
src/types
src/setupProxy.js
webpack/**
public
staticServer.js
webpack.config.js
34 changes: 34 additions & 0 deletions frontend/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"i18n",
"simple-import-sort"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended"
],
"rules": {
"i18n/no-russian-character": 1,
"simple-import-sort/imports": [
"error",
{
"groups": [
["^react", "lodash", "^\\w", "^@?\\w"],
["^components", "^layouts"],
["^consts", "^hooks", "^libs", "^routes", "^services","^types"],
["^App", "^pages"],
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
["./constants/."],
["./definitions/.", "./types"],
["^.+\\.svg", "^.+\\.png$", "^.+\\.jpg", "^.+\\.s?css$"]
]
}
]
}
}
3 changes: 3 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules/
/.idea/
build
7 changes: 7 additions & 0 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 128,
"tabWidth": 4
}
35 changes: 35 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Installation

Use `npm` to install dependencies:

```shell
npm install
```

## Build

For building the frontend, run:

```shell
npm run build
```

Then copy the build directory:

```shell
cp -r build ../src/dstack/_internal/server/statics
```

## Development

For frontend development, run a `webpack` dev server:

```shell
npm run start
```

The `webpack` dev server expects the API to be running on `http://127.0.0.1:3001`. So ensure to run the API on port `3001`:

```shell
dstack server --port 3001
```
Loading