Skip to content

Commit

Permalink
refactor: Rename dflowd to chatsky-ui (#72)
Browse files Browse the repository at this point in the history
* fix: Delete poetry usage from code

* refactor: Rename app package to dflowd

* chore: Rename in tests & ci & docs

* chore: Include lower py versions

* ci: Automate testing against many py versions

* test: Kill process after timeout

* doc: Add cli commands desciption

* ci: Delete testing on windows

* refactor: Rename dflowd to chatsky-ui

* refactor: Fix tests workflow

* fix: Enable project-dir use in cli cmds (#74)

* fix: Update front with new structure

* fix: Install ui into user proj

* fix: Enable project-dir in all cli cmds

* refactor: Add new configs

* chore: fix string f-format

* fix makefile

* chore: Fix logs repetition

* refactor: Install whl with pip in dockerfile

* chore: Raise ValueError for same name nodes

* chore: Delete temp_conf.yaml

* fix: Enter project-dir when run_app in makefile

* fix: Use immutable args & clean resources

* fix: Use poetry for production in makefile

* chore: Link to the template main branch
  • Loading branch information
Ramimashkouk authored Aug 30, 2024
1 parent efaed14 commit 76e5919
Show file tree
Hide file tree
Showing 103 changed files with 903 additions and 763 deletions.
39 changes: 25 additions & 14 deletions .github/workflows/backend_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,52 +25,63 @@ jobs:
python -m pip install --upgrade pip poetry
python -m poetry lock --no-update
python -m poetry install --with lint --no-interaction
working-directory: backend/df_designer
working-directory: backend

- name: run black codestyle
run: |
python -m poetry run black --line-length=120 --check .
working-directory: backend/df_designer
working-directory: backend

- name: run flake8 codestyle
run: |
python -m poetry run flake8 --max-line-length 120 --ignore=E203 .
working-directory: backend/df_designer
working-directory: backend

- name: run isort codestyle
run: |
python -m poetry run isort --line-length=120 --diff .
working-directory: backend/df_designer
working-directory: backend

test_backend:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [macOS-latest, ubuntu-latest]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: set up python 3.10
- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}

- name: setup poetry and install dependencies
run: |
python -m pip install --upgrade pip poetry
python -m poetry lock --no-update
python -m poetry install --with lint --no-interaction
working-directory: backend/df_designer
working-directory: backend

- name: build wheel
run: |
python -m poetry build
working-directory: backend/df_designer
working-directory: backend

- name: Create new project
run: |
python -m poetry run dflowd init --destination ../../ --no-input --overwrite-if-exists
working-directory: backend/df_designer
python -m poetry run chatsky.ui init --destination ../ --no-input --overwrite-if-exists
working-directory: backend

- name: Install chatsky-ui into new project poetry environment
run: |
../bin/add_ui_to_toml.sh
working-directory: my_project

- name: run tests
run: |
python -m poetry install
python -m poetry run pytest ../backend/df_designer/app/tests/ --verbose
working-directory: df_designer_project
python -m poetry install --no-root
python -m poetry run pytest ../backend/chatsky_ui/tests/ --verbose
working-directory: my_project
8 changes: 4 additions & 4 deletions .github/workflows/build_and_upload_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ jobs:
run: |
bun install
bun run build
cp -r ./dist/* ../backend/df_designer/app/static
cp -r ./dist/* ../backend/chatsky_ui/static
working-directory: frontend

- name: build wheels and test uploading to pypi
if: startsWith(github.ref, 'refs/tags/v') != true
run: |
python -m poetry --build publish --dry-run
working-directory: backend/df_designer
working-directory: backend

- name: build wheels and upload to pypi
if: startsWith(github.ref, 'refs/tags/v')
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: |
python -m poetry --build publish
working-directory: backend/df_designer
working-directory: backend

- name: upload binaries into release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: backend/df_designer/dist/*
file: backend/dist/*
tag: ${{ github.ref }}
overwrite: true
file_glob: true
10 changes: 5 additions & 5 deletions .github/workflows/docker_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ jobs:
python -m pip install --upgrade pip poetry
python -m poetry lock --no-update
python -m poetry install --with lint --no-ansi --no-interaction
working-directory: backend/df_designer
working-directory: backend

- name: Create new project
run: python -m poetry run dflowd init --destination ../../ --no-input --overwrite-if-exists
working-directory: backend/df_designer
run: python -m poetry run chatsky.ui init --destination ../ --no-input --overwrite-if-exists
working-directory: backend

- name: Build Frontend
run: docker build -f Dockerfile --build-arg PROJECT_DIR=df_designer_project --target=frontend-builder .
run: docker build -f Dockerfile --build-arg PROJECT_DIR=my_project --target=frontend-builder .

- name: Build backend & run app
run: docker build -f Dockerfile --build-arg PROJECT_DIR=df_designer_project --target=runtime .
run: docker build -f Dockerfile --build-arg PROJECT_DIR=my_project --target=runtime .
27 changes: 14 additions & 13 deletions .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#TODO: work with pip to install the package as the end-user would
# name: test app

# on:
Expand Down Expand Up @@ -53,7 +54,7 @@

# - name: copy static files
# run: |
# cp -r frontend/dist/. backend/df_designer/app/static/
# cp -r frontend/dist/. backend/chatsky_ui/static/

# - name: set up python 3.10
# uses: actions/setup-python@v5
Expand All @@ -65,17 +66,17 @@
# python -m pip install --upgrade pip poetry
# python -m poetry lock --no-update
# python -m poetry install --with lint --no-interaction
# working-directory: backend/df_designer
# working-directory: backend

# - name: build wheel
# run: python -m poetry build
# working-directory: backend/df_designer
# working-directory: backend

# - name: Archive backend dist
# uses: actions/upload-artifact@v4
# with:
# name: backend-dist
# path: backend/df_designer/dist
# path: backend/dist


# run_app:
Expand All @@ -89,39 +90,39 @@
# with:
# python-version: '3.10'

# - name: setup dflowd poetry and install dependencies
# - name: setup chatsky-ui poetry and install dependencies
# run: |
# python -m pip install --upgrade pip poetry
# python -m poetry lock --no-update
# python -m poetry install --with lint --no-interaction
# working-directory: backend/df_designer
# working-directory: backend

# - name: Create new project
# run: |
# python -m poetry run dflowd init --destination ../../ --no-input --overwrite-if-exists
# working-directory: backend/df_designer
# python -m poetry run chatsky.ui init --destination ../ --no-input --overwrite-if-exists
# working-directory: backend

# - name: Create dist directory
# run: mkdir -p backend/df_designer/dist
# run: mkdir -p backend/dist

# - name: Download backend dist
# uses: actions/download-artifact@v4
# with:
# name: backend-dist
# path: backend/df_designer/dist
# path: backend/dist

# - name: setup project poetry and install dependencies
# run: |
# python -m pip install --upgrade pip poetry
# python -m poetry lock --no-update
# python -m poetry install --no-interaction
# working-directory: df_designer_project
# working-directory: my_project

# - name: Run back & front
# run: |
# python -m poetry run dflowd run_app &
# python -m poetry run chatsky.ui run_app &
# sleep 10
# working-directory: df_designer_project
# working-directory: my_project

# - name: Install bun
# run: npm install -g bun
Expand Down
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ cython_debug/
#.idea/

.vscode
/df_designer_front/node_modules
/df_designer_front/vscode
/df_designer_front/.vscode

./flows.json
*.sqlite
Expand All @@ -256,4 +253,7 @@ my_project
/playwright-report/
/blob-report/
/playwright/.cache/
df_designer_project

temp_conf.yaml

my_project
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ We have almost finished the main functionality. Nevertheless, we will be glad to
We will be glad if you contribute to Dialog Flow Designer.

## Rules for submitting a PR
All PRs are reviewed by DflowD developers team. In order to make the reviewer job easier and increase the chance that your PR will be accepted, please add a short description with information about why this PR is needed and what changes will be made.
All PRs are reviewed by Chatsky-UI developers team. In order to make the reviewer job easier and increase the chance that your PR will be accepted, please add a short description with information about why this PR is needed and what changes will be made.

## Development
We use poetry as a handy dependency management and packaging tool, which reads pyproject.toml to get specification for commands. poetry is a tool for command running automatization. If your environment does not support poetry, it can be installed as a python package with `pipx install poetry`. However, It's recommended to install isolated from the global Python environment, which prevents potential conflicts with other packages ([Installation on the official site](https://python-poetry.org/docs/#installing-with-the-official-installer:~:text=its%20own%20environment.-,Install%20Poetry,-The%20installer%20script)).
Expand All @@ -14,7 +14,7 @@ We use poetry as a handy dependency management and packaging tool, which reads p
```bash
python3 -m venv poetry-venv \ # create virtual env and install poetry
&& poetry-venv/bin/pip install poetry==1.8.2
cd backend/df_designer \ # using poetry, install DflowD package
cd backend \ # using poetry, install Chatsky-UI package
&& poetry install \
&& poetry shell \
&& cd ../../
Expand Down
33 changes: 10 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ RUN bun run build

#---------------------------------------------------------

# Use a slim variant to reduce image size where possible
FROM python:3.10-slim as backend-builder

WORKDIR /temp

ARG PROJECT_DIR
# ENV PROJECT_DIR ${PROJECT_DIR}

ENV POETRY_VERSION=1.8.2 \
POETRY_HOME=/poetry \
POETRY_VENV=/poetry-venv
Expand All @@ -34,38 +30,29 @@ RUN python3 -m venv $POETRY_VENV \

ENV PATH="${PATH}:${POETRY_VENV}/bin"

COPY ./backend/df_designer /temp/backend/df_designer
COPY --from=frontend-builder /temp/frontend/dist /temp/backend/df_designer/app/static
COPY ./backend /temp/backend
COPY --from=frontend-builder /temp/frontend/dist /temp/backend/chatsky_ui/static

COPY ./${PROJECT_DIR} /temp/${PROJECT_DIR}

# Build the wheel
WORKDIR /temp/backend/df_designer
WORKDIR /temp/backend
RUN poetry build

#---------------------------------------------------------

#TODO: create something like src named e.g. runtime/

FROM python:3.10-slim as runtime

ARG PROJECT_DIR

COPY --from=backend-builder /poetry-venv /poetry-venv

# Set environment variable to use the virtualenv
ENV PATH="/poetry-venv/bin:$PATH"
# Install pip and upgrade
RUN pip install --upgrade pip

# Copy only the necessary files
COPY --from=backend-builder /temp/backend/df_designer /src2/backend/df_designer
COPY ./${PROJECT_DIR} /src2/project_dir
COPY --from=backend-builder /temp/backend/dist /src/dist
COPY ./${PROJECT_DIR} /src/project_dir

# Install the wheel
WORKDIR /src2/project_dir
RUN poetry lock --no-update \
&& poetry install

CMD ["poetry", "run", "dflowd", "run_app"]

WORKDIR /src/project_dir
RUN pip install ../dist/*.whl

# #TODO: change scr to app (maybe)
CMD ["chatsky.ui", "run_app"]
Loading

0 comments on commit 76e5919

Please sign in to comment.