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 Docker Compose.

๐Ÿš€ Quick Start

With Docker (Recommended for users)

make up                    # Start all services
# Open http://localhost/
make down                  # Stop all services

With Pixi (Recommended for developers)

pixi shell                 # Activate environment (optional)
pixi run dev-setup         # Install dependencies + generate models
pixi run generate-codegen  # Regenerate models (if needed, with schema validation files)

๐Ÿ“‚ Project Structure

/qualpipe-webapp
โ”‚
โ”œโ”€โ”€ docker-compose.dev.yml           # Docker compose for developer
โ”œโ”€โ”€ docker-compose.yml               # Docker compose for user
โ”œโ”€โ”€ Makefile                         # Makefile to build Backend and Frontend
โ”‚
โ”œโ”€โ”€ docs/                            # Document folder
โ”‚
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ qualpipe_webapp/             # FastAPI backend
โ”‚       โ”œโ”€โ”€ backend/                 # FastAPI backend
โ”‚       โ”‚   โ”œโ”€โ”€ main.py              # Main FastAPI app
โ”‚       โ”‚   โ”œโ”€โ”€ 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
โ”‚       โ”‚   โ”œโ”€โ”€ requirements.txt     # Frontend dependencies
โ”‚       โ”‚   โ”œโ”€โ”€ requirements-dev.txt # Frontend dependencies for developer
โ”‚       โ”‚   โ””โ”€โ”€ Dockerfile           # Frontend container
โ”‚       โ”‚
โ”‚       โ”œโ”€โ”€ nginx/
โ”‚       โ”‚   โ”œโ”€โ”€ nginx.conf
โ”‚       โ”‚   โ””โ”€โ”€ ssl/                 # (optional later)
โ”‚
โ””โ”€โ”€ .gitignore

Instructions

Docker Deployment

To run it in the background, from the project folder qualpipe-webapp simply execute:

make up

Then open your browser:

To stop everything, execute:

make down

Pixi Development

For development with automatic model generation:

# Activate pixi environment (optional)
pixi shell

# Setup environment and generate models
pixi run dev-setup

# Manually regenerate models (if criteria change)
pixi run generate-codegen

# Or use the installed console script
qualpipe-generate-models --help

If you also want to automatically see the logs you can then run it via docker compose

To run it the first time execute: (later on you can remove the --build)

docker-compose up --build

To stop it you can soft-kill with CTRL-C and shut down all the services executing make down.

If instead you do any modification to the config while the containers are running or in case Docker caches wrong stuff, you can restart it running:

make restart

or

docker-compose down -v --remove-orphans
docker-compose up --build

๐Ÿ› ๏ธ Makefile Commands

Description of all the Makefile functionalities:

Command What it does
make build Build the Docker images
make up Build and start services (backend + frontend) in background
make down Stop all services
make logs View combined logs (both frontend and backend)
make logs-backend View only backend logs
make logs-frontend View only frontend logs
make restart Restart the containers
make prune Clean up unused Docker containers/images
------------------ -----------------------------------------------------------
make build-dev Build the Docker images
make up-dev Build and start services (backend + frontend) in background

๐Ÿ”ง Code Generation with Pixi

This project uses Pixi for package management and includes automated code generation for Pydantic models based on qualpipe criteria, and automatic schema generation.

Prerequisites

Install Pixi on your system:

# On macOS
curl -fsSL https://pixi.sh/install.sh | bash

# On Linux
curl -fsSL https://pixi.sh/install.sh | bash

# Or using conda/mamba
conda install -c conda-forge pixi

Available Pixi Commands

Command Description
pixi run dev-setup Complete development setup (install + generate models)
pixi run install Install the package with dependencies
pixi run install-all Install with all optional dependencies
pixi run generate-codegen Generate Pydantic models from qualpipe criteria
pixi run generate-frontend-schema Generate yaml file for javascript frontend validation
pixi shell Activate the pixi environment

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

Generated Files

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

Frontend schema generation

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 reads 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.

Development Setup with Pixi

  1. Clone and setup environment:

    git clone <repository-url>
    cd qualpipe-webapp
    pixi run dev-setup  # Install dependencies then generate models and schema files
    
  2. Activate the environment:

    pixi shell
    
  3. Run tests:

    pixi run test
    
  4. Regenerate models and schema files (if qualpipe criteria change):

    pixi run generate-codegen
    pixi run generate-frontend-schema
    

Integration with CI/CD

The generated models are automatically created during:

  • Local development: pixi run dev-setup runs code generation
  • CI/CD pipelines: Code generation runs before 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.

โœ… Tests depend on generated models - Always run code generation before testing.

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

๐Ÿ› ๏ธ Troubleshooting

Import errors with generated models?

pixi run generate-codegen  # Regenerate models

Tests failing?

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

Pixi environment issues?

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

Developers

For developers, you can build containers that automatically file changes, avoiding the need to restart the containers every time. To do so, simply execute:

make build-dev
make up-dev

This will automatically output also every log produced.

๐Ÿงช Running Tests

1. Python Tests with Pytest

Install dependencies:

pip install -r src/qualpipe_webapp/backend/requirements-dev.txt
pip install -r src/qualpipe_webapp/frontend/requirements-dev.txt

Run tests:

pytest -v src/qualpipe_webapp/backend/tests/
pytest -v src/qualpipe_webapp/frontend/tests/

Alternative method

The same result can be achieved in a more compact way using pixi:

pixi run test

2. JavaScript Unit Tests with Mocha

Install NodeJS from the official website.

Install NodeJS dependencies:

npm install

Run all JS unit tests:

npx mocha src/qualpipe_webapp/frontend/unit_tests_js/ --reporter spec

Run a specific test file:

npx mocha src/qualpipe_webapp/frontend/unit_tests_js/base.test.js --reporter spec

The report will be automatically saved in the file test-results.xml

[!NOTE] Add new unit tests in the folder: src/qualpipe_webapp/frontend/unit_tests_js/

If you also want to see the coverage of your unit-tests simply execute:

npm run coverage

3. End-to-End Tests with Playwright

In order to run end-to-end interface test with the real frontend DOM you need first to install NodeJS and its dependencies (see first step of previous section).

Install Playwright browsers:

To install the Playwright library and the browsers (Chromium, Firefox, WebKit) necessary to run the tests, execute in the terminal:

npx playwright install

Start the FastAPI webapp (in another terminal):

make up-dev

or

make up

Run all Playwright E2E tests:

npx playwright test

Run a specific Playwright test:

To run e.g. the home.test.js test execute:

npx playwright test src/qualpipe_webapp/frontend/tests_e2e_js/home.test.js

In this way Playwright will open the browser, load the page, and verify that the DOM successfully pass the selected test.

Generate and view HTML test report:

npx playwright test --reporter html
npx playwright show-report

It will serve the HTML report at http://localhost:9323. Press Ctrl+C to quit.

[!NOTE] Add new end-to-end tests in the folder: src/qualpipe_webapp/frontend/tests_e2e_js/

๐Ÿ› ๏ธ Troubleshooting

[!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. Open a browser and navigate to http://localhost/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.1.2.tar.gz (700.8 kB 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.1.2-py3-none-any.whl (681.4 kB view details)

Uploaded Python 3

File details

Details for the file ctao_qualpipe_webapp-0.1.2.tar.gz.

File metadata

  • Download URL: ctao_qualpipe_webapp-0.1.2.tar.gz
  • Upload date:
  • Size: 700.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for ctao_qualpipe_webapp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a17610c14b4cfcc14f3f61592bd571e6d224c6ee966f44e5c218306bb9d0423d
MD5 c528615cba4ff73cc56d11c2b992394f
BLAKE2b-256 1454709df9af036f243f4e6fd01a0457d5470168c72ddcdcdbeae66b9ba0d332

See more details on using hashes here.

File details

Details for the file ctao_qualpipe_webapp-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ctao_qualpipe_webapp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2584a2061a5d7b6b2bb2636c26ed19f829b6737e0b2d5cb9ff796a092717839f
MD5 45dab97ca1d603d64b84f13ab15368be
BLAKE2b-256 afd5accce16aaab19cdabd11ff1fc7209d9bfc2ad98f462fbfeba7b87edb7c3d

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