Skip to main content

Goals scenario analysis

Project description

goals-scenario

Release Build status codecov Commit activity License

Goals scenario analysis

Installation

pip install avenir_goals_scenario

After installation, the goals-scenario command is available on your PATH.

Quick start

For full details of the CLI see the CLI reference.

goals-scenario --help      # or -h
goals-scenario --version

Both commands are driven by a single JSON config file. Field names are case-insensitive.

{
  "pjnz_dir": "path/to/pjnz/files",
  "definition_path": "scenario_definitions.csv",
  "scenario_path": "draws.json",
  "output_dir": "path/to/output",
  "base_year": 2025,
  "output_indicators": ["p_hivpop", "p_infections", "p_hiv_deaths", "h_artpop"],
  "n_simulations": 100,
  "seed": null
}

One-shot run (draw and run together)

Set definition_path in the config and omit scenario_path. Draws are saved automatically to <output_dir>/draws.json.

goals-scenario run config.json

Two-step run (draw first, then run)

Useful when you want to inspect draws before committing to a full model run, or to reuse the same draws across multiple runs. Set both definition_path and scenario_path in the config.

goals-scenario draw config.json   # saves draws to scenario_path
goals-scenario run config.json    # reuses the same draws

If you call run with both paths set and scenario_path already exists, the existing draws are reused. If the file is missing, draws are regenerated and saved.

Tab completion

To install shell tab completion:

goals-scenario --install-completion

Development

Architecture

architecture diagram

Prerequisites

  • uv for installing Python, package management
  • (Optionally) make. Should be installed by default, except on windows, where it is easiest to install it via Chocolatey choco install make

Development with make

There is a Makefile which wraps some common uv commands you will need during development.

Set Up Your Development Environment

Install the environment and the pre-commit hooks with

make install

This will also generate your uv.lock file.

Run code checks

make check

Run tests

make test

Build docs site

make docs

Development with uv

If you choose not to use make, you can use uv directly.

Set Up Your Development Environment

Install the environment and the pre-commit hooks with

uv sync
uv run pre-commit install

This will also generate your uv.lock file.

Run code checks

Run pre-commit checks, include ruff linting and formatting

uv run pre-commit run -a

Run type checking

uv run ty check

Check for vulnerabilities in pypi dependencies

uv run pip-audit --desc -s osv

Run tests

uv run pytest

Build docs site

uv run mkdocs serve

Run compatibility tests

Compatability tests with tox are configured. Run them with

uv run tox

These are also run on CI, so not the end of the world if you don't do it locally.

Vendored SpectrumEngine import code

We need to re-use some of the PJNZ import code from SpectrumEngine. At the moment, this is vendored here directly. There is a script to update the vendored code which should be run before a release. The script uses a file ./scripts/spectrum_engine_ref to clone the specified branch or ref.

With make:

make pjnz-import-code

Run script directly

uv run ./scripts/update_pjnz_import_code.py

CLI

The CLI is built using typer which builds CLI docs automatically from python type hints and decorators. It also gives us some neat things like auto completion. And progress bars down the line!

Release process

Creating a release will

  1. Build & push the package to PyPI
  2. Build an updated docs site

To create a release you need to

  1. Update the version number in the pyproject.toml or ensure it has updated since the last release
  2. Go to the releases page and "Draft a new release"
  3. Create a new tag, I usually use a tag which matches the version number you are releasing. Set a release title and text. Usually useful to include in the text a summary of the changes since the last release.
  4. Publish the release. This will trigger a GitHub action which will push the package to PyPI and update the docs site.

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

avenir_goals_scenario-0.0.6.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

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

avenir_goals_scenario-0.0.6-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

Details for the file avenir_goals_scenario-0.0.6.tar.gz.

File metadata

  • Download URL: avenir_goals_scenario-0.0.6.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for avenir_goals_scenario-0.0.6.tar.gz
Algorithm Hash digest
SHA256 48f9ded086a77cbcc165af3df02001ad73940e342fa00489ca1ef02a402183a3
MD5 36f1b9d34dcd0433906ae32689d90c4f
BLAKE2b-256 821f56753b5e63c0c8c220c44f8df86544b6fa39ad20ca8fd20575f4490c06d8

See more details on using hashes here.

File details

Details for the file avenir_goals_scenario-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: avenir_goals_scenario-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 44.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for avenir_goals_scenario-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b185893f1b0f4225a7187459f598111034a69d212e6a9dc287bc8c122a5e933d
MD5 4584d2668ee8ec2ca5c8762fff41fd6d
BLAKE2b-256 9efe4b68c5f91a0ab38bea08c488ec72beab70551eac0de51a41a28c759f906e

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