Skip to main content

CTAO DPPS QualPipe Web Application

Project description

QualPipe-Webapp

The QualPipe-webapp project uses FastAPI as backend and frontend, plus D3.js for dynamic frontend visualizations, separated into clean services using Kubernetes (Kind).

Prerequisites

Make sure these software are already installed on your system:

If you are on a Mac, these dependencies can be quickly installed via homebrew executing:

brew install docker pixi

and verify the installation

docker version
pixi -V

๐Ÿš€ Quick Start

Developer setup (first time only)

1. Clone the repo:

git clone <repository-url>
cd qualpipe-webapp

2. Setup environment

To setup the development environment execute:

pixi run dev-setup

This will:

  • โœ… Create an isolate Python environment with pixi
  • โœ… Install all dependencies from pyproject.toml (frontend, test, doc, dev)
  • โœ… Install the ctao-qualpipe-webapp package in editable mode
  • โœ… Generate data models
  • โœ… Compile backend and frontend requirements
  • โœ… Generate javascript schema
  • โœ… Install node dependencies

3. Configure host

To add qualpipe.local hostname to the /etc/hosts file execute:

echo "127.0.0.1 qualpipe.local" | sudo tee -a /etc/hosts

4. Start the local development environment

To deploy the app and start the local development environment execute:

pixi run dev-up

This will:

  • โœ… Create a kind cluster with port mappings
  • โœ… Build Docker images (backend + frontend)
  • โœ… Install NGINX Ingress Controller
  • โœ… Deploy the application via Helm

โณ Wait for all pods to be ready (can take 2-3 minutes).

5. Access the application

No port-forward needed! The kind cluster exposes ports directly via extraPortMappings.

Open in your browser:


Developer Workflow (after the first time)

Pre-requisite: the local kubernetes cluster should be running already, if not execute pixi run dev-up. If you changed any dependency or modified code that requires model regeneration re-execute pixi run dev-setup.

If only images are changed:

Rebuild images and restart services

pixi run dev-restart

If images are NOT changed:

Upgrade only Helm chart

pixi run helm-dev-upgrade

View logs

To display logs from both backend and frontend containers execute:

pixi run kind-logs

To stop logs, you can soft-kill them with CTRL-C.


Verify installation

To check that the app is correctly deployed and properly set up, execute this command:

pixi run dev-health

If something is not โœ… OK check the cluster status with:

pixi run kind-status

or see Troubleshooting.


๐Ÿงช How to run tests

Here below are listed the commands to run all the various possible tests. To get more dertailled information visit also gitlab pages.

Backend unit tests

pixi run test-backend

Frontend python unit tests

pixi run test-frontend-py

Frontend javascript unit tests

pixi run test-frontend-js

Frontend end-to-end tests

By default the installed test browser are chromium, firefox, and webkit (Safari). Other browsers can be installed modifying the file playwright.config.ts. To execute the test run:

pixi run test-frontend-e2e

If the tests are failing for some browsers you can restrict the tests to a specific browser, e.g. Chromium, adding the flag --project=chromium to the above command. See also the troubleshooting.

To inspect the interactive html generated report simply execute:

npx playwright show-report

This will serve the interactvie html report at http://localhost:9323. Press Ctrl+C to quit.

All tests

To run all kinds of tests execute:

pixi run all-tests

You can always add the flag --project=chromium (or firefox or webkit) at the end of the previous command.


Cleanup

When you have done with your development you can execute a soft clean or a full clean

Soft clean

To stop only the pods, preserving the cluster, simply execute:

pixi run stop

To restart your development workflow then execute one of the following command, upon your case:

# With images rebuilding
pixi run dev-restart
# Without images rebuilding
pixi run dev-restart-no-build

Full clean

To stop the pods and remove the cluster execute:

pixi run stop-and-delete

To restart you development workflow, if you did not change the image, then execute:

pixi run dev-up-no-build

Otherwise if you need also to rebuild the image restart it with:

pixi run dev-up

Docker clean

You can remove the unused Docker container with:

pixi run prune

If you instead you want to clean everything (stop pods, remove cluster, remove docker images) you can execute:

pixi run clean-all

To restart your development workflow you can execute:

pixi run dev-up

๐Ÿ“‚ Project Structure

/qualpipe-webapp
โ”‚
โ”œโ”€โ”€ kind-dev-config.yml              # Kind configuration file for local development
โ”œโ”€โ”€ chart/                           # Helm chart instructions for deployment
โ”œโ”€โ”€ Makefile                         # Makefile to build Backend and Frontend
โ”‚
โ”œโ”€โ”€ docs/                            # Document folder
โ”‚
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ qualpipe_webapp/
โ”‚       โ”œโ”€โ”€ backend/                 # FastAPI backend
โ”‚       โ”‚   โ”œโ”€โ”€ main.py              # Main FastAPI app for backend
โ”‚       โ”‚   โ”œโ”€โ”€ data/                # JSON data sources
โ”‚       โ”‚   โ”œโ”€โ”€ requirements.txt     # Backend dependencies
โ”‚       โ”‚   โ”œโ”€โ”€ requirements-dev.txt # Backend dependencies for developer
โ”‚       โ”‚   โ””โ”€โ”€ Dockerfile           # Backend container
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ frontend/                # FastAPI frontend
โ”‚       โ”‚   โ”œโ”€โ”€ /templates/          # Template pages
โ”‚       โ”‚   โ”œโ”€โ”€ /static/             # Static files (css, js, lib)
โ”‚       โ”‚   โ”œโ”€โ”€ main.py              # Main FastAPI app for frontend
โ”‚       โ”‚   โ”œโ”€โ”€ requirements.txt     # Frontend dependencies
โ”‚       โ”‚   โ”œโ”€โ”€ requirements-dev.txt # Frontend dependencies for developer
โ”‚       โ”‚   โ””โ”€โ”€ Dockerfile           # Frontend container
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ nginx/
โ”‚       โ”‚   โ”œโ”€โ”€ nginx.conf
โ”‚       โ”‚   โ””โ”€โ”€ ssl/                 # (optional later)
โ”‚      ...
โ””โ”€โ”€ .gitignore

Pixi command

All the available Pixi tasks are listed and described in the table below.

Command: pixi Description
shell Activate the pixi environment
run install Install editable pixi environment
run install-all Install editable pixi environment with all extra dependencies
run compile-requirements-backend Generate/update backend requirements.txt
run compile-requirements-frontend Generate/update frontend requirements.txt
run compile-requirements-backend-dev Generate/update backend requirements-dev.txt
run compile-requirements-frontend-dev Generate/update frontend requirements-dev.txt
run compile-requirements Generate/update backend and frontend requirements.txt
run compile-requirements-dev Generate/update backend and frontend requirements-dev.txt
run npm-install Install NodeJS dependencies
run generate-codegen Generate Pydantic models from qualpipe criteria
run generate-frontend-schema Generate yaml file for javascript frontend validation (combines those produced by generate-codegen)
run build-backend Build backend image
run build-backend-dev Build backend dev image
run build-frontend Build frontend image
run build-frontend-dev Build frontend dev image
run build-images Build backend- and frontend- images
run build-images-dev Build backend- and frontend- dev images
run kind-create Create local kind cluster
run kind-delete Delete local kind cluster
run kind-load-images Load docker images on the cluster
run kind-load-dev-images Load docker dev images on the cluster
run kind-status Show kubernetes cluster status
run kind-clean-failed Remove kubernetes resources left from previously failed installation
run helm-install Install Helm chart
run helm-dev-install Install Helm chart for local development
run helm-uninstall Uninstall Helm chart
run helm-upgrade Upgrade Helm chart
run helm-dev-upgrade Upgrade Helm chart for local development
run ingress-install Install NGINX ingress controller for kind
run setup Install dependencies, execute generate-codegen and generate-frontend-schema, and install nodejs dependencies
run dev-setup Install dev dependencies in editable mode, execute generate-codegen and generate-frontend-schema, and install nodejs dependencies
run up Production deployment
run dev-up Deploy the complete development environment (create a kubernetes cluster, build docker dev images, install NGINX ingress controller for kind, install dev helm chart)
run dev-up-no-build Deploy the complete development environment without rebuilding images
run restart Build images and reinstall Helm chart
run dev-restart Build dev images and reinstall Helm chart
run dev-restart-no-build Reinstall Helm chart
run stop Stop pods preserving cluster
run stop-and-delete Stop pods and delete the cluster
run prune Cleanup dangling Docker images
run clean-all Stop pods, delete cluster, and remove docker images
run browser-install Install Playwright browsers for e2e tests
run test-backend Run backend python unit tests
run test-frontend-py Run frontend python unit tests
run test-frontend-js Run frontend javascript unit tests with Mocha
run test-frontend-e2e Run frontend javascript end-to-end tests with Playwright
run all-tests Run all backend and frontend tests
run check-backend Check backend health
run check-frontend Check frontend health
run check Check backend and frontend health
run kind-logs-backend Show backend container logs
run kind-logs-frontend Show frontend container logs
run kind-logs Show backend and frontend container logs
run dev-health Check backend and frontend health, check API endpoint, check that pods are running
run format Run ruff formatting
run lint Run ruff linting
run lint-fix Run ruff linting and fix

Pixi dependency graph tasks

install โ”€โ”
         โ”‚
generate-codegen โ”€โ”
                  โ”‚
compile-requirements-backend โ”€โ”€โ”
                               โ”œโ”€โ†’ compile-requirements
compile-requirements-frontend โ”€โ”˜

compile-requirements-backend-dev โ”€โ”€โ”
                                   โ”œโ”€โ†’ compile-requirements-dev
compile-requirements-frontend-dev โ”€โ”˜

install-all โ”€โ”
             โ”‚
generate-codegen โ”€โ”
                  โ”‚
compile-requirements-backend-dev โ”€โ”€โ”
                                   โ”œโ”€โ†’ compile-requirements-dev
compile-requirements-frontend-dev โ”€โ”˜           โ”‚
                                               โ”‚
npm-install โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
                                               โ”œโ”€โ†’ dev-setup
generate-frontend-schema โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


kind-create โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
build-backend-dev  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
                                โ”œโ”€โ†’ build-images-dev โ”€โ”
build-frontend-dev โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                     โ”‚
                                                      โ”œโ”€โ†’ dev-up
ingress-install โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
helm-dev-install โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

kind-create โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
ingress-install โ”€โ”€โ”€โ”œโ”€โ†’ dev-up-no-build
helm-dev-install โ”€โ”€โ”˜

build-backend โ”€โ”€โ”
                โ”œโ”€โ†’ build-images
build-frontend โ”€โ”˜

kind-clean-failed โ”€โ”
                   โ”œโ”€โ†’ helm-install
kind-load-images โ”€โ”€โ”˜

kind-clean-failed โ”€โ”€โ”€โ”€โ”
                      โ”œโ”€โ†’ helm-dev-install
kind-load-dev-images โ”€โ”˜

kind-load-images โ”€โ”€โ†’ helm-upgrade
kind-load-dev-images โ”€โ”€โ†’ helm-dev-upgrade

helm-uninstall โ”€โ”€โ”€โ”
build-images โ”€โ”€โ”€โ”€โ”€โ”คโ”€โ†’ restart
helm-install โ”€โ”€โ”€โ”€โ”€โ”˜

helm-uninstall โ”€โ”€โ”€โ”
build-images-dev โ”€โ”คโ”€โ†’ dev-restart
helm-install โ”€โ”€โ”€โ”€โ”€โ”˜

helm-uninstall โ”€โ”€โ”€โ”
                  โ”œโ”€โ†’ dev-restart-no-build
helm-dev-install โ”€โ”˜

helm-uninstall โ”€โ”€โ†’ stop

kind-delete โ”€โ”
             โ”œโ”€โ†’ stop-and-delete
             โ””โ”€โ†’ clean-all

test-backend โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
test-frontend-py โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
test-frontend-js โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
browser-install โ”€โ”€โ†’ test-frontend-e2e
                           โ””โ”€โ†’ all-tests

check-backend โ”€โ”€โ”
                โ”œโ”€โ†’ check
check-frontend โ”€โ”˜

kind-logs-backend โ”€โ”€โ”
                    โ”œโ”€โ†’ kind-logs
kind-logs-frontend โ”€โ”˜

Makefile commands for advanced debug

We use the Makefile only for advanced debug pourposes

Makefile command Description
make dev-forward Manual port-forward (debug/fallback)
make dev-debug-network Debug network cluster/pod/ingress
make dev-trace-request Trace end-to-end request
make dev-debug-setup Advance diagnostic cluster setup
make kind-status-all Complete health check cluster/app

Code Generation Workflow

The project automatically generates Pydantic models from qualpipe criteria classes:

# Generate models manually
pixi run generate-codegen

# Or use the console script directly (after installation)
qualpipe-generate-models --module qualpipe.core.criterion \
    --out-generated src/qualpipe_webapp/backend/generated \
    --out-schemas src/qualpipe_webapp/frontend/static

The code generation creates:

  • Python Models: src/qualpipe_webapp/backend/generated/qualpipe_criterion_model.py

    • Pydantic models for each criterion type
    • Validation logic for telescope parameters
    • Type-safe configuration classes
  • JSON/YAML Schemas: src/qualpipe_webapp/frontend/static/

    • criteria_schema.json - JSON schema for frontend criteria report validation
    • criteria_schema.yaml - YAML schema for configuration

Such files are then implemented into metadata_schema.yaml with:

pixi run generate-frontend-schema

which is used for complete frontend validations, with all the correct references read from the configuration file config.js. The metadata_schema.yaml file is auto-generated from a template, so

[!IMPORTANT] Do not edit metadata_schema.yaml directly โ€” edit template_metadata_schema.yaml instead.

Integration with CI/CD

The generated models are automatically created during:

  • Local development: pixi run dev-setup
  • CI/CD pipelines: Code generation runs before CI tests
  • Package installation: Post-install hooks generate models

[!IMPORTANT] Important Notes โš ๏ธ Generated files are git-ignored - They're created automatically and should not be committed.

โœ… Some tests depend on generated models - Always run code generation before testing, if your changes had an impact on the models.

๐Ÿ”„ Automatic regeneration - Models update automatically when qualpipe criteria change.

๐Ÿ› ๏ธ Troubleshooting

[!IMPORTANT] Import errors with generated models?

pixi run generate-codegen  # Regenerate models

[!IMPORTANT] Tests failing?

# Ensure models and schemas are generated before running tests
pixi run generate-codegen
pixi run generate-frontend-schema
pixi run test

[!IMPORTANT] Pixi environment issues?

pixi clean              # Clean cache
pixi run dev-setup      # Complete reinstall + code generation

[!IMPORTANT] Port already in use If you see errors like bind: address already in use:

# Find process using port 8080
lsof -i :8080

# Kill the process
kill -9 <PID>

# Or delete and recreate cluster
make kind-delete
make dev-up

[!IMPORTANT] Application not accessible To use the cluster run 'make export-kubeconfig'

  1. Check if pods are running:

    kubectl get pods -n default
    

    All pods should be Running with READY 1/1.

  2. Check Ingress:

    kubectl get ingress -n default
    kubectl describe ingress qualpipe-webapp-ingress -n default
    
  3. Check Ingress Controller:

    kubectl get pods -n ingress-nginx
    

    The ingress-nginx-controller-* pod should have STATUS: Running.

  4. Manual port-forward (fallback): Try to setup a manual port forward with:

    make dev-forward
    

    Then try to access: http://localhost:8080/

[!IMPORTANT] Logs not showing Inspect last logs with:

# Backend logs
kubectl logs -n default -l app.kubernetes.io/component=backend --tail=50

# Frontend logs
kubectl logs -n default -l app.kubernetes.io/component=frontend --tail=50

# Nginx logs
kubectl logs -n default -l app.kubernetes.io/component=nginx --tail=50

# Ingress Controller logs
kubectl logs -n ingress-nginx -l app.kubernetes.io/component=controller --tail=50

[!IMPORTANT] Playwright test are failing for a specific browser? You can execute Playwright tests on a specific browser (chromium, firefox, webkit)

npx playwright test --project=chromium

โš ๏ธ Note: WebKit browser generally works only with the latest Mac OS update.

[!IMPORTANT] Some tests about validation are failing? Ensure you have generated models and schema (see the Tests failing? section for detailed instructions.)

[!IMPORTANT] All test failing with ERR_CONNECTION_REFUSED? Verify that the WebApp is running, executing

Or you can open a browser and navigate to http://qualpipe.local:8080/home . If you can't display the page, the WebApp is not running. See instruction above on how to run it.


๐Ÿ‘ฉโ€๐Ÿ’ป Contributing

If you want to contribute in developing the code, be aware that we are using pre-commit, code-spell and ruff tools for automatic adherence to the code style. To enforce running these tools whenever you make a commit, setup the pre-commit hook executing:

pre-commit install

The pre-commit hook will then execute the tools with the same settings as when a merge request is checked on GitLab, and if any problems are reported the commit will be rejected. You then have to fix the reported issues before tying to commit again.

๐Ÿ“„ License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.


Useful Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ctao_qualpipe_webapp-0.3.0rc3.tar.gz (3.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ctao_qualpipe_webapp-0.3.0rc3-py3-none-any.whl (3.5 MB view details)

Uploaded Python 3

File details

Details for the file ctao_qualpipe_webapp-0.3.0rc3.tar.gz.

File metadata

  • Download URL: ctao_qualpipe_webapp-0.3.0rc3.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for ctao_qualpipe_webapp-0.3.0rc3.tar.gz
Algorithm Hash digest
SHA256 ab09a3b6ac9b2066b0dfcec679cd6707a4197b3eb1def877079fc6c3a6ff42f8
MD5 12098e417f0a57860988e50674cfe115
BLAKE2b-256 0ebd9436160a7e09847130ef1ccff39228c340fe71a578450bf80427f68ae8d7

See more details on using hashes here.

File details

Details for the file ctao_qualpipe_webapp-0.3.0rc3-py3-none-any.whl.

File metadata

File hashes

Hashes for ctao_qualpipe_webapp-0.3.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 8577f59da0691166b915f12e601cc07b4a3b0f564b9de24c32e19fa6102fb422
MD5 9410fec6cf06ec5ed656bb6a58dac50d
BLAKE2b-256 5fab2f26c8e81f095a711fabfb692688cd73789b901f0f2c17981ae65e5787b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page