diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index b25624f..37419e6 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -2,8 +2,7 @@ name: Ruff on: push: branches: - - master - - dev + - main pull_request: jobs: ruff: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..3407a9f --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,40 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: + +jobs: + pytest: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + + steps: + - uses: actions/checkout@v4 + + - name: Setup Conda environment + uses: conda-incubator/setup-miniconda@v3 + with: + miniforge-version: latest + use-mamba: true + activate-environment: CADET-GUI + environment-file: environment.yml + + # No CADET-Process release includes CADETProcess.instruments yet (the + # LC flow-sheet layer this GUI is built on); pin a dev-branch commit + # known to have it, rather than floating on the branch tip. + - name: Install CADET-Process + run: pip install "git+https://github.com/fau-advanced-separations/CADET-Process.git@a064f9c" + + - name: Install CADET-GUI + run: pip install -e . --group dev + + - name: Install headless Chromium + run: playwright install --with-deps chromium + + - name: Run tests + run: pytest -v diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 298ccb2..13c7e1a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,42 +11,25 @@ ### Coding Style -We use the [`Ruff` linter / formatter](https://docs.astral.sh/ruff/formatter/) for all Python files. -To install the latest version of Ruff, use the following command: - +We use [`Ruff`](https://docs.astral.sh/ruff/) for linting and formatting all Python files. ```bash pip install ruff +ruff check # lint +ruff format # format ``` -**Linting:** To check your files for compliance with our coding standards, run the following command: - -```bash -ruff check -``` - -This command will analyze the specified directory and report any issues that need to be addressed. - -**Formatting:** To automatically format your files according to our coding standards, use: - -```bash -ruff format -``` - -This command will apply the necessary formatting changes to ensure consistency across the codebase. - ### Unit Tests -Install the dev dependencies and run the suite with [pytest](https://docs.pytest.org/): - ```bash -pip install -e ".[dev]" +pip install -e . --group dev pytest ``` Slow tests (real optimizer runs) are marked `@pytest.mark.slow`; skip them -during day-to-day work with `pytest -m "not slow"`, but run the full suite, -slow tests included, before opening a pull request. +locally with `pytest -m "not slow"`, but run the full suite before opening a +pull request. CI (`.github/workflows/tests.yml`) runs the full suite, +including headless-browser element tests, on every push to `main` and PR. ### Pre-commit Hooks @@ -63,14 +46,11 @@ slow tests included, before opening a pull request. ## Versioning -CADET-GUI follows the same versioning approach as -[CADET-Process](https://github.com/fau-advanced-separations/CADET-Process): -a plain `MAJOR.MINOR.PATCH` string in `__version__` -(`cadetgui/__init__.py`), the single source of truth `pyproject.toml` reads -dynamically (`[tool.setuptools.dynamic] version = { attr = -"cadetgui.__version__" }`) — never duplicate the version number elsewhere. -While the project is pre-1.0, a MINOR bump may still include breaking -changes; PATCH is for fixes only. Tag each release `vX.Y.Z` to match. +CADET-GUI follows [CADET-Process](https://github.com/fau-advanced-separations/CADET-Process)'s +versioning: a plain `MAJOR.MINOR.PATCH` string in `cadetgui/__init__.py`'s +`__version__`, read dynamically by `pyproject.toml` — never duplicate it +elsewhere. Pre-1.0, a MINOR bump may include breaking changes; PATCH is +fixes only. Tag each release `vX.Y.Z`. ## Publish Package diff --git a/README.md b/README.md index 649189f..32cb6fe 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # CADET-GUI -CADET-GUI provides widget-based graphical user elements to configure, run and -analyse [CADET-Process](https://github.com/fau-advanced-separations/CADET-Process) +Widget-based graphical elements to configure, run and analyse +[CADET-Process](https://github.com/fau-advanced-separations/CADET-Process) simulations from a Jupyter notebook. --- @@ -33,17 +33,15 @@ and versioning. ## Getting started Everything is a plain [ipywidgets](https://ipywidgets.readthedocs.io/)/ -[anywidget](https://anywidget.dev/) object: build one, call `.display()` (or -just let it be the last expression in a Jupyter cell), and keep using its -Python attributes from other cells. +[anywidget](https://anywidget.dev/) object: build one, call `.display()`, and +keep using its Python attributes from other cells. ### The workbench `WorkbenchWidget` is the top-level entry point — a sidebar with four steps (System Configuration, Process Configuration, Simulation, Parameter -Estimation), each a widget of its own that stays reachable as a plain -attribute (`.instrument`, `.configuration`, `.solution`, -`.parameter_estimation`): +Estimation), each also reachable as its own attribute: `.instrument`, +`.configuration`, `.solution`, `.parameter_estimation`. ```python from cadetgui.widgets.composite import WorkbenchWidget @@ -56,9 +54,8 @@ See [`examples/workbench.ipynb`](examples/workbench.ipynb). ### Composing widgets yourself -The same widgets that make up `WorkbenchWidget` can be built and wired by -hand — useful for a notebook that only needs a couple of steps, or a custom -layout: +Build and wire the same widgets by hand for a custom layout or a subset of +steps: ```python from cadetgui.widgets.composite import ConfigurationWidget, SolutionWidget @@ -72,22 +69,24 @@ solution.display() ``` See [`examples/configuration_and_solution.ipynb`](examples/configuration_and_solution.ipynb) -and [`examples/custom_sidebar.ipynb`](examples/custom_sidebar.ipynb) (a -`SidebarShell` built from a hand-picked set of widgets). +and [`examples/custom_sidebar.ipynb`](examples/custom_sidebar.ipynb). ### Example data [`examples/data/`](examples/data/) and [`examples/EXAMPLE_DATA.md`](examples/EXAMPLE_DATA.md) hold small synthetic -datasets (generated by simulating a known process and adding noise, never -measured data) for exercising Parameter Estimation without needing your own -experimental files first. +datasets for exercising Parameter Estimation without your own experimental +files. ### Running as a web app -[`examples/webapp/`](examples/webapp/) shows deploying `WorkbenchWidget` -through [Voilà](https://voila.readthedocs.io/), turning the notebook into a -standalone page with no visible code cells. +[`examples/webapp/`](examples/webapp/) deploys `WorkbenchWidget` as a +standalone page via [Voilà](https://voila.readthedocs.io/): + +```bash +pip install voila +voila examples/webapp/app.ipynb +``` --- diff --git a/pyproject.toml b/pyproject.toml index c76ce3e..2aab486 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ "Intended Audience :: Science/Research" ] dependencies = [ - "CADETProcess>=0.11", + "CADET-Process>=0.11", "anywidget", "ipywidgets>=8", "traitlets", @@ -52,6 +52,7 @@ cadetgui = [ [dependency-groups] testing = [ "coverage", + "playwright", "pytest", "pytest-cov" ] @@ -66,6 +67,7 @@ docs = [ ] dev = [ "coverage", + "playwright", "pytest", "pytest-cov", "myst-nb>=0.17.1",