From ab523e12f8c9fded2a079063c910187693a4ad30 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Aug 2025 12:04:41 +0200 Subject: [PATCH 01/12] adjsuted ci yml files to not use codesphere cli --- .env.sample | 5 ----- .gitlab-ci.yml | 1 - README.md | 2 +- ci.Qa.yml | 21 ++++++++------------- ci.dev.yml | 22 ++++++++-------------- ci.prod.yml | 20 ++++++++------------ ci.yml | 15 ++++++++------- 7 files changed, 33 insertions(+), 53 deletions(-) delete mode 100644 .env.sample diff --git a/.env.sample b/.env.sample deleted file mode 100644 index 8627d06..0000000 --- a/.env.sample +++ /dev/null @@ -1,5 +0,0 @@ -export TEAM_ID=$(cs list workspaces | grep $WORKSPACE_ID | awk '{print $2}') -export UV_PYTHON_INSTALL_DIR=/home/user/app/.codesphere-internal/.uv-python-install -export UV_PYTHON_BIN_DIR=/home/user/app/.codesphere-internal/.uv-python-bin -export UV_CACHE_DIR=/home/user/app/.codesphere-internal/.uv -export UV_PYTHON_CACHE_DIR=/home/user/app/.codesphere-internal/.uv-python \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09138ab..c6558c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,6 @@ codesphere-deploy: PLAN: 'Micro' ON_DEMAND: 'false' ENV: | - CS_TOKEN=$CODESPHERE_TOKEN environment: name: 'Preview Deployment Python MR_$CI_MERGE_REQUEST_IID' on_stop: codesphere-teardown diff --git a/README.md b/README.md index bfcc8f0..76fe946 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # python-demo test -before running any stage you will need to set up a 'CS_TOKEN' env var containing an Codesphere API key. +This is a Python demo application with a Streamlit frontend and FastAPI backend. # open backend api docs diff --git a/ci.Qa.yml b/ci.Qa.yml index 3d0f976..776ccf4 100644 --- a/ci.Qa.yml +++ b/ci.Qa.yml @@ -1,22 +1,17 @@ schemaVersion: v0.2 prepare: steps: - - name: install Codesphere cli tool - command: mkdir -p $HOME/.local/bin && wget -qO- - 'https://api.github.com/repos/codesphere-cloud/cs-go/releases/latest' | - grep linux_amd64 | grep browser_download_url | sed s/.*https/https/ | - sed s/\".*$// | xargs wget -O $HOME/.local/bin/cs && chmod +x - $HOME/.local/bin/cs - name: install uv standalone version command: curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv - - command: cp -n .env.sample .env - - name: "set ev vars " - command: . .env && cs set-env -w $WORKSPACE_ID -t $TEAM_ID --env-var - UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install - --env-var UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin - --env-var UV_CACHE_DIR=$PWD/.codesphere-internal/.uv --env-var - UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python + - name: create environment file + command: | + cat > ./env << 'EOF' + export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install + export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin + export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv + export UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python + EOF - name: install frontend environment command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync --no-dev; } diff --git a/ci.dev.yml b/ci.dev.yml index b82cf69..c8f4a2d 100644 --- a/ci.dev.yml +++ b/ci.dev.yml @@ -1,23 +1,17 @@ schemaVersion: v0.2 prepare: steps: - - name: install Codesphere cli tool - command: mkdir -p $HOME/.local/bin && wget -qO- - 'https://api.github.com/repos/codesphere-cloud/cs-go/releases/latest' | - grep linux_amd64 | grep browser_download_url | sed s/.*https/https/ | - sed s/\".*$// | xargs wget -O $HOME/.local/bin/cs && chmod +x - $HOME/.local/bin/cs - name: install uv standalone version command: curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv - - name: copy template .env file - command: cp -n .env.sample .env - - name: "set ev vars " - command: . .env && cs set-env -w $WORKSPACE_ID -t $TEAM_ID --env-var - UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install - --env-var UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin - --env-var UV_CACHE_DIR=$PWD/.codesphere-internal/.uv --env-var - UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python + - name: create environment file + command: | + cat > ./env << 'EOF' + export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install + export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin + export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv + export UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python + EOF - name: install frontend environment command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync; } - name: install backend environment diff --git a/ci.prod.yml b/ci.prod.yml index 2f51ae9..f6cf694 100644 --- a/ci.prod.yml +++ b/ci.prod.yml @@ -1,20 +1,16 @@ schemaVersion: v0.2 prepare: steps: - - name: install Codesphere cli tool - command: mkdir -p $HOME/.local/bin && wget -qO- - 'https://api.github.com/repos/codesphere-cloud/cs-go/releases/latest' | - grep linux_amd64 | grep browser_download_url | sed s/.*https/https/ | - sed s/\".*$// | xargs wget -O $HOME/.local/bin/cs && chmod +x - $HOME/.local/bin/cs - name: install uv standalone version command: nix-env -iA nixpkgs.uv - - name: "set ev vars " - command: . .env && cs set-env -w $WORKSPACE_ID -t $TEAM_ID --env-var - UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install - --env-var UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin - --env-var UV_CACHE_DIR=$PWD/.codesphere-internal/.uv --env-var - UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python + - name: create environment file + command: | + cat > ./env << 'EOF' + export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install + export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin + export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv + export UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python + EOF - name: install frontend environment command: cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync --no-dev; } - name: install backend environment diff --git a/ci.yml b/ci.yml index 80289cc..66d3257 100644 --- a/ci.yml +++ b/ci.yml @@ -1,16 +1,17 @@ schemaVersion: v0.2 prepare: steps: - - name: install Codesphere cli tool - command: mkdir -p $HOME/.local/bin && wget -qO- - 'https://api.github.com/repos/codesphere-cloud/cs-go/releases/latest' | - grep linux_amd64 | grep browser_download_url | sed s/.*https/https/ | - sed s/\".*$// | xargs wget -O $HOME/.local/bin/cs && chmod +x - $HOME/.local/bin/cs - name: install uv standalone version command: curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv - - command: cp -n .env.sample .env + - name: create environment file + command: | + cat > ./env << 'EOF' + export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install + export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin + export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv + export UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python + EOF - name: install frontend environment command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync --no-dev; } From f543f3cc968e16ee18792b05e38d72cef670c344 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Aug 2025 12:18:25 +0200 Subject: [PATCH 02/12] minor changes --- ci.Qa.yml | 1 + ci.dev.yml | 1 + ci.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/ci.Qa.yml b/ci.Qa.yml index 776ccf4..f97da31 100644 --- a/ci.Qa.yml +++ b/ci.Qa.yml @@ -7,6 +7,7 @@ prepare: - name: create environment file command: | cat > ./env << 'EOF' + export PATH="$HOME/app:$PATH" export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv diff --git a/ci.dev.yml b/ci.dev.yml index c8f4a2d..819a113 100644 --- a/ci.dev.yml +++ b/ci.dev.yml @@ -7,6 +7,7 @@ prepare: - name: create environment file command: | cat > ./env << 'EOF' + export PATH="$HOME/app:$PATH" export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv diff --git a/ci.yml b/ci.yml index 66d3257..aa2e386 100644 --- a/ci.yml +++ b/ci.yml @@ -7,6 +7,7 @@ prepare: - name: create environment file command: | cat > ./env << 'EOF' + export PATH="$HOME/app:$PATH" export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv From b022893e51ee775578203e1ad523d044c0cec6ba Mon Sep 17 00:00:00 2001 From: Alex <132889147+alexvcodesphere@users.noreply.github.com> Date: Mon, 11 Aug 2025 12:29:32 +0200 Subject: [PATCH 03/12] Rename ci.Qa.yml to ci.QA.yml --- ci.Qa.yml => ci.QA.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ci.Qa.yml => ci.QA.yml (100%) diff --git a/ci.Qa.yml b/ci.QA.yml similarity index 100% rename from ci.Qa.yml rename to ci.QA.yml From 69607e8fdf79a3a28285554cbfba7c3dd55b23f4 Mon Sep 17 00:00:00 2001 From: Alex <132889147+alexvcodesphere@users.noreply.github.com> Date: Mon, 11 Aug 2025 12:29:49 +0200 Subject: [PATCH 04/12] Rename ci.dev.yml to ci.DEV.yml --- ci.dev.yml => ci.DEV.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ci.dev.yml => ci.DEV.yml (100%) diff --git a/ci.dev.yml b/ci.DEV.yml similarity index 100% rename from ci.dev.yml rename to ci.DEV.yml From d5f3b80199459e9118e3fa7cc748be4bbc703d98 Mon Sep 17 00:00:00 2001 From: Alex <132889147+alexvcodesphere@users.noreply.github.com> Date: Mon, 11 Aug 2025 12:30:03 +0200 Subject: [PATCH 05/12] Rename ci.prod.yml to ci.PROD.yml --- ci.prod.yml => ci.PROD.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ci.prod.yml => ci.PROD.yml (100%) diff --git a/ci.prod.yml b/ci.PROD.yml similarity index 100% rename from ci.prod.yml rename to ci.PROD.yml From 81c62dd70b18ef722755d4a0d0abed951945d539 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Aug 2025 13:46:55 +0200 Subject: [PATCH 06/12] removed unnecessary dependencies --- backend/requirements.txt | 10 ++++++++++ ci.DEV.yml | 34 ++++++++++--------------------- ci.PROD.yml | 32 +++++++++++++---------------- ci.QA.yml | 36 +++++++++++++-------------------- ci.yml | 42 +++++++++++++++++++-------------------- frontend/requirements.txt | 12 +++++++++++ 6 files changed, 81 insertions(+), 85 deletions(-) create mode 100644 backend/requirements.txt create mode 100644 frontend/requirements.txt diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..aca0a52 --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,10 @@ +# Main dependencies +fastapi[all]>=0.115.12 +numpy>=2.3.0 +pandas>=2.3.0 +pytest-cov>=6.1.1 +pytest-profiling>=1.8.1 + +# Dev dependencies (for testing and security checks) +bandit>=1.8.3 +pytest>=8.4.0 diff --git a/ci.DEV.yml b/ci.DEV.yml index 819a113..b286c34 100644 --- a/ci.DEV.yml +++ b/ci.DEV.yml @@ -1,41 +1,29 @@ schemaVersion: v0.2 prepare: steps: - - name: install uv standalone version - command: curl -LsSf https://astral.sh/uv/install.sh | env - UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv - - name: create environment file - command: | - cat > ./env << 'EOF' - export PATH="$HOME/app:$PATH" - export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install - export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin - export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv - export UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python - EOF - - name: install frontend environment - command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync; } - - name: install backend environment - command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync; } + - name: install frontend dependencies + command: cd frontend && pip install -r requirements.txt + - name: install backend dependencies + command: cd backend && pip install -r requirements.txt test: steps: - name: test frontend - command: . ./env && cd frontend && uv run pytest + command: cd frontend && python -m pytest - name: test backend - command: ". ./env && cd backend && uv run pytest " + command: cd backend && python -m pytest - name: security check frontend - command: '. ./env && cd frontend && uv run bandit -r . -c pyproject.toml + command: 'cd frontend && python -m bandit -r . -c pyproject.toml --format=custom --msg-template "{abspath}:{line}: {test_id}[{severity}]: {msg}" -o bandit-results.txt' - name: security check backend - command: '. ./env && cd backend && uv run bandit -r . -c pyproject.toml + command: 'cd backend && python -m bandit -r . -c pyproject.toml --format=custom --msg-template "{abspath}:{line}: {test_id}[{severity}]: {msg}" -o bandit-results.txt' run: frontend: steps: - name: start frontend application - command: . ./env && cd frontend && uv run streamlit run --server.address 0.0.0.0 + command: cd frontend && python -m streamlit run --server.address 0.0.0.0 --server.port 3000 main.py plan: 20 replicas: 1 @@ -46,7 +34,7 @@ run: backend: steps: - name: start backend application - command: . ./env && cd backend && uv run uvicorn app:app --reload --port 3000 + command: cd backend && python -m uvicorn app:app --reload --port 3000 --host 0.0.0.0 plan: 20 replicas: 1 @@ -54,7 +42,7 @@ run: api-docs: steps: - name: deploy docs - command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 + command: cd backend && python -m uvicorn doc:app_docs --host 0.0.0.0 --port 3000 plan: 20 replicas: 1 diff --git a/ci.PROD.yml b/ci.PROD.yml index f6cf694..c92da6b 100644 --- a/ci.PROD.yml +++ b/ci.PROD.yml @@ -1,29 +1,19 @@ schemaVersion: v0.2 prepare: steps: - - name: install uv standalone version - command: nix-env -iA nixpkgs.uv - - name: create environment file - command: | - cat > ./env << 'EOF' - export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install - export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin - export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv - export UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python - EOF - - name: install frontend environment - command: cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync --no-dev; } - - name: install backend environment - command: cd backend && { [ ! -d ".venv" ] && uv venv; uv sync --no-dev; } + - name: install frontend dependencies + command: cd frontend && pip install -r requirements.txt + - name: install backend dependencies + command: cd backend && pip install -r requirements.txt test: steps: [] run: frontend: steps: - name: start frontend application - command: "cd frontend && uv run streamlit run main.py --server.headless true + command: "cd frontend && python -m streamlit run main.py --server.headless true --server.address 0.0.0.0 --server.port 3000 --browser.gatherUsageStats - false --logger.level info " + false --logger.level info" plan: 8 replicas: 1 isPublic: true @@ -33,7 +23,7 @@ run: backend: steps: - name: start backend application - command: cd backend && uv run uvicorn app:app --port 3000 --host 0.0.0.0 + command: cd backend && python -m uvicorn app:app --port 3000 --host 0.0.0.0 --workers 2 plan: 8 replicas: 1 @@ -41,7 +31,7 @@ run: api-docs: steps: - name: deploy docs - command: cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 --port 3000 + command: cd backend && python -m uvicorn doc:app_docs --host 0.0.0.0 --port 3000 --workers 2 plan: 8 replicas: 1 @@ -49,3 +39,9 @@ run: network: path: /api stripPath: false + plan: 8 + replicas: 1 + isPublic: true + network: + path: /api + stripPath: false diff --git a/ci.QA.yml b/ci.QA.yml index f97da31..fa50363 100644 --- a/ci.QA.yml +++ b/ci.QA.yml @@ -1,33 +1,19 @@ schemaVersion: v0.2 prepare: steps: - - name: install uv standalone version - command: curl -LsSf https://astral.sh/uv/install.sh | env - UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv - - name: create environment file - command: | - cat > ./env << 'EOF' - export PATH="$HOME/app:$PATH" - export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install - export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin - export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv - export UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python - EOF - - name: install frontend environment - command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync - --no-dev; } - - name: install backend environment - command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync - --no-dev; } + - name: install frontend dependencies + command: cd frontend && pip install -r requirements.txt + - name: install backend dependencies + command: cd backend && pip install -r requirements.txt test: steps: [] run: frontend: steps: - name: start frontend application - command: ". ./env && cd frontend && uv run streamlit run main.py + command: "cd frontend && python -m streamlit run main.py --server.headless true --server.address 0.0.0.0 --server.port 3000 - --browser.gatherUsageStats false --logger.level info " + --browser.gatherUsageStats false --logger.level info" plan: 20 replicas: 1 isPublic: true @@ -37,7 +23,7 @@ run: backend: steps: - name: start backend application - command: . ./env && cd backend && uv run uvicorn app:app --port 3000 --host + command: cd backend && python -m uvicorn app:app --port 3000 --host 0.0.0.0 --workers 2 plan: 20 replicas: 1 @@ -45,7 +31,7 @@ run: api-docs: steps: - name: deploy docs - command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 + command: cd backend && python -m uvicorn doc:app_docs --host 0.0.0.0 --port 3000 --workers 2 plan: 20 replicas: 1 @@ -53,3 +39,9 @@ run: network: path: /api stripPath: false + plan: 20 + replicas: 1 + isPublic: true + network: + path: /api + stripPath: false diff --git a/ci.yml b/ci.yml index aa2e386..af57be1 100644 --- a/ci.yml +++ b/ci.yml @@ -1,33 +1,19 @@ schemaVersion: v0.2 prepare: steps: - - name: install uv standalone version - command: curl -LsSf https://astral.sh/uv/install.sh | env - UV_INSTALL_DIR="$HOME/app" sh && chmod +x $HOME/app/uv - - name: create environment file - command: | - cat > ./env << 'EOF' - export PATH="$HOME/app:$PATH" - export UV_PYTHON_INSTALL_DIR=$PWD/.codesphere-internal/.uv-python-install - export UV_PYTHON_BIN_DIR=$PWD/.codesphere-internal/.uv-python-bin - export UV_CACHE_DIR=$PWD/.codesphere-internal/.uv - export UV_PYTHON_CACHE_DIR=$PWD/.codesphere-internal/.uv-python - EOF - - name: install frontend environment - command: . ./env && cd frontend && { [ ! -d ".venv" ] && uv venv; uv sync - --no-dev; } - - name: install backend environment - command: . ./env && cd backend && { [ ! -d ".venv" ] && uv venv; uv sync - --no-dev; } + - name: install frontend dependencies + command: cd frontend && pip install -r requirements.txt + - name: install backend dependencies + command: cd backend && pip install -r requirements.txt test: steps: [] run: frontend: steps: - name: start frontend application - command: ". ./env && cd frontend && uv run streamlit run main.py + command: "cd frontend && python -m streamlit run main.py --server.headless true --server.address 0.0.0.0 --server.port 3000 - --browser.gatherUsageStats false --logger.level info " + --browser.gatherUsageStats false --logger.level info" plan: 8 replicas: 1 isPublic: true @@ -37,7 +23,7 @@ run: backend: steps: - name: start backend application - command: . ./env && cd backend && uv run uvicorn app:app --port 3000 --host + command: cd backend && python -m uvicorn app:app --port 3000 --host 0.0.0.0 --workers 2 plan: 8 replicas: 1 @@ -45,7 +31,7 @@ run: api-docs: steps: - name: deploy docs - command: . ./env && cd backend && uv run uvicorn doc:app_docs --host 0.0.0.0 + command: cd backend && python -m uvicorn doc:app_docs --host 0.0.0.0 --port 3000 --workers 2 plan: 8 replicas: 1 @@ -53,3 +39,15 @@ run: network: path: /api stripPath: false + plan: 8 + replicas: 1 + isPublic: true + network: + path: /api + stripPath: false + plan: 8 + replicas: 1 + isPublic: true + network: + path: /api + stripPath: false diff --git a/frontend/requirements.txt b/frontend/requirements.txt new file mode 100644 index 0000000..2f6d724 --- /dev/null +++ b/frontend/requirements.txt @@ -0,0 +1,12 @@ +# Main dependencies +numpy>=2.2.6 +pandas>=2.3.0 +plotly>=6.1.2 +pytest-cov>=6.1.1 +pytest-profiling>=1.8.1 +requests>=2.32.4 +streamlit>=1.45.1 + +# Dev dependencies (for testing and security checks) +bandit>=1.8.3 +pytest>=8.4.0 From 02c8f8bafc74d3de0a8d954b546e729360f38960 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Aug 2025 13:50:20 +0200 Subject: [PATCH 07/12] removed duplicated lines --- ci.PROD.yml | 6 ------ ci.QA.yml | 6 ------ ci.yml | 12 ------------ 3 files changed, 24 deletions(-) diff --git a/ci.PROD.yml b/ci.PROD.yml index c92da6b..f9aeb5e 100644 --- a/ci.PROD.yml +++ b/ci.PROD.yml @@ -39,9 +39,3 @@ run: network: path: /api stripPath: false - plan: 8 - replicas: 1 - isPublic: true - network: - path: /api - stripPath: false diff --git a/ci.QA.yml b/ci.QA.yml index fa50363..6a9af6a 100644 --- a/ci.QA.yml +++ b/ci.QA.yml @@ -39,9 +39,3 @@ run: network: path: /api stripPath: false - plan: 20 - replicas: 1 - isPublic: true - network: - path: /api - stripPath: false diff --git a/ci.yml b/ci.yml index af57be1..76b810f 100644 --- a/ci.yml +++ b/ci.yml @@ -39,15 +39,3 @@ run: network: path: /api stripPath: false - plan: 8 - replicas: 1 - isPublic: true - network: - path: /api - stripPath: false - plan: 8 - replicas: 1 - isPublic: true - network: - path: /api - stripPath: false From 6e646dfdcf4a75a9736575f2ae92bae64a1bb16e Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Aug 2025 13:54:12 +0200 Subject: [PATCH 08/12] use venv --- ci.DEV.yml | 20 ++++++++++---------- ci.PROD.yml | 12 ++++++------ ci.QA.yml | 10 +++++----- ci.yml | 10 +++++----- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ci.DEV.yml b/ci.DEV.yml index b286c34..77aac01 100644 --- a/ci.DEV.yml +++ b/ci.DEV.yml @@ -2,28 +2,28 @@ schemaVersion: v0.2 prepare: steps: - name: install frontend dependencies - command: cd frontend && pip install -r requirements.txt + command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies - command: cd backend && pip install -r requirements.txt + command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt test: steps: - name: test frontend - command: cd frontend && python -m pytest + command: cd frontend && .venv/bin/python -m pytest - name: test backend - command: cd backend && python -m pytest + command: cd backend && .venv/bin/python -m pytest - name: security check frontend - command: 'cd frontend && python -m bandit -r . -c pyproject.toml + command: 'cd frontend && .venv/bin/python -m bandit -r . -c pyproject.toml --format=custom --msg-template "{abspath}:{line}: {test_id}[{severity}]: {msg}" -o bandit-results.txt' - name: security check backend - command: 'cd backend && python -m bandit -r . -c pyproject.toml + command: 'cd backend && .venv/bin/python -m bandit -r . -c pyproject.toml --format=custom --msg-template "{abspath}:{line}: {test_id}[{severity}]: {msg}" -o bandit-results.txt' run: frontend: steps: - name: start frontend application - command: cd frontend && python -m streamlit run --server.address 0.0.0.0 + command: cd frontend && .venv/bin/python -m streamlit run --server.address 0.0.0.0 --server.port 3000 main.py plan: 20 replicas: 1 @@ -34,7 +34,7 @@ run: backend: steps: - name: start backend application - command: cd backend && python -m uvicorn app:app --reload --port 3000 + command: cd backend && .venv/bin/python -m uvicorn app:app --reload --port 3000 --host 0.0.0.0 plan: 20 replicas: 1 @@ -42,11 +42,11 @@ run: api-docs: steps: - name: deploy docs - command: cd backend && python -m uvicorn doc:app_docs --host 0.0.0.0 + command: cd backend && .venv/bin/python -m uvicorn doc:app_docs --host 0.0.0.0 --port 3000 plan: 20 replicas: 1 isPublic: true network: path: /api - stripPath: false + stripPath: false \ No newline at end of file diff --git a/ci.PROD.yml b/ci.PROD.yml index f9aeb5e..924169c 100644 --- a/ci.PROD.yml +++ b/ci.PROD.yml @@ -2,16 +2,16 @@ schemaVersion: v0.2 prepare: steps: - name: install frontend dependencies - command: cd frontend && pip install -r requirements.txt + command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies - command: cd backend && pip install -r requirements.txt + command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt test: steps: [] run: frontend: steps: - name: start frontend application - command: "cd frontend && python -m streamlit run main.py --server.headless true + command: "cd frontend && .venv/bin/python -m streamlit run main.py --server.headless true --server.address 0.0.0.0 --server.port 3000 --browser.gatherUsageStats false --logger.level info" plan: 8 @@ -23,7 +23,7 @@ run: backend: steps: - name: start backend application - command: cd backend && python -m uvicorn app:app --port 3000 --host 0.0.0.0 + command: cd backend && .venv/bin/python -m uvicorn app:app --port 3000 --host 0.0.0.0 --workers 2 plan: 8 replicas: 1 @@ -31,11 +31,11 @@ run: api-docs: steps: - name: deploy docs - command: cd backend && python -m uvicorn doc:app_docs --host 0.0.0.0 --port 3000 + command: cd backend && .venv/bin/python -m uvicorn doc:app_docs --host 0.0.0.0 --port 3000 --workers 2 plan: 8 replicas: 1 isPublic: true network: path: /api - stripPath: false + stripPath: false \ No newline at end of file diff --git a/ci.QA.yml b/ci.QA.yml index 6a9af6a..52222c1 100644 --- a/ci.QA.yml +++ b/ci.QA.yml @@ -2,16 +2,16 @@ schemaVersion: v0.2 prepare: steps: - name: install frontend dependencies - command: cd frontend && pip install -r requirements.txt + command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies - command: cd backend && pip install -r requirements.txt + command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt test: steps: [] run: frontend: steps: - name: start frontend application - command: "cd frontend && python -m streamlit run main.py + command: "cd frontend && .venv/bin/python -m streamlit run main.py --server.headless true --server.address 0.0.0.0 --server.port 3000 --browser.gatherUsageStats false --logger.level info" plan: 20 @@ -23,7 +23,7 @@ run: backend: steps: - name: start backend application - command: cd backend && python -m uvicorn app:app --port 3000 --host + command: cd backend && .venv/bin/python -m uvicorn app:app --port 3000 --host 0.0.0.0 --workers 2 plan: 20 replicas: 1 @@ -31,7 +31,7 @@ run: api-docs: steps: - name: deploy docs - command: cd backend && python -m uvicorn doc:app_docs --host 0.0.0.0 + command: cd backend && .venv/bin/python -m uvicorn doc:app_docs --host 0.0.0.0 --port 3000 --workers 2 plan: 20 replicas: 1 diff --git a/ci.yml b/ci.yml index 76b810f..200fc18 100644 --- a/ci.yml +++ b/ci.yml @@ -2,16 +2,16 @@ schemaVersion: v0.2 prepare: steps: - name: install frontend dependencies - command: cd frontend && pip install -r requirements.txt + command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies - command: cd backend && pip install -r requirements.txt + command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt test: steps: [] run: frontend: steps: - name: start frontend application - command: "cd frontend && python -m streamlit run main.py + command: "cd frontend && .venv/bin/python -m streamlit run main.py --server.headless true --server.address 0.0.0.0 --server.port 3000 --browser.gatherUsageStats false --logger.level info" plan: 8 @@ -23,7 +23,7 @@ run: backend: steps: - name: start backend application - command: cd backend && python -m uvicorn app:app --port 3000 --host + command: cd backend && .venv/bin/python -m uvicorn app:app --port 3000 --host 0.0.0.0 --workers 2 plan: 8 replicas: 1 @@ -31,7 +31,7 @@ run: api-docs: steps: - name: deploy docs - command: cd backend && python -m uvicorn doc:app_docs --host 0.0.0.0 + command: cd backend && .venv/bin/python -m uvicorn doc:app_docs --host 0.0.0.0 --port 3000 --workers 2 plan: 8 replicas: 1 From 967c2785ba68a4d6cc4b45c6d34277361c0323b4 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Aug 2025 13:56:56 +0200 Subject: [PATCH 09/12] venve package --- ci.DEV.yml | 2 ++ ci.PROD.yml | 2 ++ ci.QA.yml | 2 ++ ci.yml | 2 ++ 4 files changed, 8 insertions(+) diff --git a/ci.DEV.yml b/ci.DEV.yml index 77aac01..199c83b 100644 --- a/ci.DEV.yml +++ b/ci.DEV.yml @@ -1,6 +1,8 @@ schemaVersion: v0.2 prepare: steps: + - name: install python3-venv package + command: apt update && apt install -y python3-venv - name: install frontend dependencies command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies diff --git a/ci.PROD.yml b/ci.PROD.yml index 924169c..c768c6e 100644 --- a/ci.PROD.yml +++ b/ci.PROD.yml @@ -1,6 +1,8 @@ schemaVersion: v0.2 prepare: steps: + - name: install python3-venv package + command: apt update && apt install -y python3-venv - name: install frontend dependencies command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies diff --git a/ci.QA.yml b/ci.QA.yml index 52222c1..3d93ac0 100644 --- a/ci.QA.yml +++ b/ci.QA.yml @@ -1,6 +1,8 @@ schemaVersion: v0.2 prepare: steps: + - name: install python3-venv package + command: apt update && apt install -y python3-venv - name: install frontend dependencies command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies diff --git a/ci.yml b/ci.yml index 200fc18..ac799b6 100644 --- a/ci.yml +++ b/ci.yml @@ -1,6 +1,8 @@ schemaVersion: v0.2 prepare: steps: + - name: install python3-venv package + command: apt update && apt install -y python3-venv - name: install frontend dependencies command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies From bb9dd915170604f34cc1ac8ea7a83438160fdeb2 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Aug 2025 14:00:46 +0200 Subject: [PATCH 10/12] use virtualenv --- ci.DEV.yml | 6 ++---- ci.PROD.yml | 4 +--- ci.QA.yml | 4 +--- ci.yml | 4 +--- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/ci.DEV.yml b/ci.DEV.yml index 199c83b..ed6fa2e 100644 --- a/ci.DEV.yml +++ b/ci.DEV.yml @@ -1,12 +1,10 @@ schemaVersion: v0.2 prepare: steps: - - name: install python3-venv package - command: apt update && apt install -y python3-venv - name: install frontend dependencies - command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt + command: cd frontend && virtualenv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies - command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt + command: cd backend && virtualenv .venv && .venv/bin/pip install -r requirements.txt test: steps: - name: test frontend diff --git a/ci.PROD.yml b/ci.PROD.yml index c768c6e..46887b6 100644 --- a/ci.PROD.yml +++ b/ci.PROD.yml @@ -1,10 +1,8 @@ schemaVersion: v0.2 prepare: steps: - - name: install python3-venv package - command: apt update && apt install -y python3-venv - name: install frontend dependencies - command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt + command: cd frontend && virtualenv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt test: diff --git a/ci.QA.yml b/ci.QA.yml index 3d93ac0..a3b6f75 100644 --- a/ci.QA.yml +++ b/ci.QA.yml @@ -1,10 +1,8 @@ schemaVersion: v0.2 prepare: steps: - - name: install python3-venv package - command: apt update && apt install -y python3-venv - name: install frontend dependencies - command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt + command: cd frontend && virtualenv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt test: diff --git a/ci.yml b/ci.yml index ac799b6..7e42a9c 100644 --- a/ci.yml +++ b/ci.yml @@ -1,10 +1,8 @@ schemaVersion: v0.2 prepare: steps: - - name: install python3-venv package - command: apt update && apt install -y python3-venv - name: install frontend dependencies - command: cd frontend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt + command: cd frontend && virtualenv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt test: From 187ce99434b5e724b1f7cc877a29c3e20d8a8789 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Aug 2025 14:03:46 +0200 Subject: [PATCH 11/12] backend virtualenv --- ci.PROD.yml | 2 +- ci.QA.yml | 2 +- ci.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci.PROD.yml b/ci.PROD.yml index 46887b6..695876c 100644 --- a/ci.PROD.yml +++ b/ci.PROD.yml @@ -4,7 +4,7 @@ prepare: - name: install frontend dependencies command: cd frontend && virtualenv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies - command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt + command: cd backend && virtualenv .venv && .venv/bin/pip install -r requirements.txt test: steps: [] run: diff --git a/ci.QA.yml b/ci.QA.yml index a3b6f75..6ff661d 100644 --- a/ci.QA.yml +++ b/ci.QA.yml @@ -4,7 +4,7 @@ prepare: - name: install frontend dependencies command: cd frontend && virtualenv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies - command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt + command: cd backend && virtualenv .venv && .venv/bin/pip install -r requirements.txt test: steps: [] run: diff --git a/ci.yml b/ci.yml index 7e42a9c..1f5c590 100644 --- a/ci.yml +++ b/ci.yml @@ -4,7 +4,7 @@ prepare: - name: install frontend dependencies command: cd frontend && virtualenv .venv && .venv/bin/pip install -r requirements.txt - name: install backend dependencies - command: cd backend && python3 -m venv .venv && .venv/bin/pip install -r requirements.txt + command: cd backend && virtualenv .venv && .venv/bin/pip install -r requirements.txt test: steps: [] run: From 0975ddfecaeaab4804f1e1425f96ab98adf17a08 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 11 Aug 2025 14:27:36 +0200 Subject: [PATCH 12/12] adjusted prod profile --- ci.PROD.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ci.PROD.yml b/ci.PROD.yml index 695876c..3af153b 100644 --- a/ci.PROD.yml +++ b/ci.PROD.yml @@ -3,8 +3,12 @@ prepare: steps: - name: install frontend dependencies command: cd frontend && virtualenv .venv && .venv/bin/pip install -r requirements.txt - - name: install backend dependencies + - name: install backend dependencies command: cd backend && virtualenv .venv && .venv/bin/pip install -r requirements.txt + - name: optimize python bytecode + command: cd frontend && .venv/bin/python -m compileall -b . + - name: optimize backend bytecode + command: cd backend && .venv/bin/python -m compileall -b . test: steps: [] run: @@ -13,9 +17,9 @@ run: - name: start frontend application command: "cd frontend && .venv/bin/python -m streamlit run main.py --server.headless true --server.address 0.0.0.0 --server.port 3000 --browser.gatherUsageStats - false --logger.level info" + false --logger.level warning --server.enableCORS false --server.enableXsrfProtection true" plan: 8 - replicas: 1 + replicas: 2 isPublic: true network: path: / @@ -24,15 +28,15 @@ run: steps: - name: start backend application command: cd backend && .venv/bin/python -m uvicorn app:app --port 3000 --host 0.0.0.0 - --workers 2 + --workers 4 --worker-class uvicorn.workers.UvicornWorker --access-log --no-use-colors plan: 8 - replicas: 1 + replicas: 2 isPublic: false api-docs: steps: - name: deploy docs command: cd backend && .venv/bin/python -m uvicorn doc:app_docs --host 0.0.0.0 --port 3000 - --workers 2 + --workers 2 --access-log --no-use-colors plan: 8 replicas: 1 isPublic: true