Skip to main content

A development library for the RaPiD project

Project description

pypi versions license ci docs

axtreme

Development repo for the RaPiD project with extensions for Ax and BoTorch.

Repo Structure

  • src/: Main package directory
  • tests/: Test directory
  • examples/: Examples and demos
  • tutorials/: Tutorial notebooks

Development Setup

1. Install uv

This project uses uv as package manager. If you haven't already, install uv, preferably using it's "Standalone installer" method:
..on Windows:

powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

..on MacOS and Linux:

curl -LsSf https://astral.sh/uv/install.sh | sh

(see docs.astral.sh/uv for all / alternative installation methods.)

Once installed, you can update uv to its latest version, anytime, by running:

uv self update

2. Install Python

This project requires Python 3.11 or later.
If you don't already have a compatible version installed on your machine, the probably most comfortable way to install Python is through uv:

uv python install

This will install the latest stable version of Python into the uv Python directory, i.e. as a uv-managed version of Python.

Alternatively, and if you want a standalone version of Python on your machine, you can install Python either via winget:

winget install --id Python.Python

or you can download and install Python from the python.org website.

3. Clone the repository

Clone the axtreme repository into your local development directory:

git clone https://github.com/dnv-opensource/axtreme path/to/your/dev/axtreme

Change into the project directory after cloning:

cd axtreme

4. Install dependencies

Run uv sync to create a virtual environment and install all project dependencies into it:

uv sync

Note: Using --no-dev will omit installing development dependencies.

Note: uv will create a new virtual environment called .venv in the project root directory when running uv sync for the first time. Optionally, you can create your own using e.g. uv venv, before running uv sync.

5. (Optional) Install CUDA support

Run uv sync with option --extra cuda to in addition install torch with CUDA support:

uv sync --extra cuda

Note: The exact version of torch that is installed by default depends on the system you are using. E.g., Linux will install the CUDA version by default, while Windows and macOS will install the CPU version.

Alternatively, you can manually install torch with CUDA support. Note 1: Do this preferably after running uv sync. That way you ensure a virtual environment exists, which is a prerequisite before you install torch with CUDA support using below uv pip install command.

To manually install torch with CUDA support, generate a uv pip install command matching your local machine's operating system using the wizard on the official PyTorch website. Note: As we use uv as package manager, remember to replace pip in the command generated by the wizard with uv pip.

If you are on Windows, the resulting uv pip install command will most likely look something like this:

uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

Hint: If you are unsure which cuda version to indicate in above uv pip install .. /cuXXX command, you can use the shell command nvidia-smi on your local system to find out the cuda version supported by the current graphics driver installed on your system. When then generating the uv pip install command with the wizard from the PyTorch website, select the cuda version that matches the major version of what your graphics driver supports (major version must match, minor version may deviate).

6. (Optional) Activate the virtual environment

When using uv, there is in almost all cases no longer a need to manually activate the virtual environment.
uv will find the .venv virtual environment in the working directory or any parent directory, and activate it on the fly whenever you run a command via uv inside your project folder structure:

uv run <command>

However, you still can manually activate the virtual environment if needed. When developing in an IDE, for instance, this can in some cases be necessary depending on your IDE settings. To manually activate the virtual environment, run one of the "known" legacy commands:
..on Windows:

.venv\Scripts\activate.bat

..on Linux:

source .venv/bin/activate

7. Install pre-commit hooks

The .pre-commit-config.yaml file in the project root directory contains a configuration for pre-commit hooks. To install the pre-commit hooks defined therein in your local git repository, run:

uv run pre-commit install

All pre-commit hooks configured in .pre-commit-config.yaml will now run each time you commit changes.

pre-commit can also manually be invoked at anytime, using:

uv run pre-commit run --all-files

To skip the pre-commit validation on commits (e.g. when intentionally committing broken code), run:

uv run git commit -m <MSG> --no-verify

8. Test that the installation works

To test that the installation works, run pytest in the project root folder:

uv run pytest

You should now be ready to start developing!

Development Tools

You should familiarize yourself with the following tools used in this project. The tools can be configured in the pyproject.toml file;

  • ruff (linting + formatting)
  • mypy (static type checking)
  • pytest (unit testing)
  • pre-commit (code quality checks and fixes on commit)

A brief overview of the tools is provided below:

ruff Formatter

Format the code according to the formatting rules in the pyproject.toml file:

uv run ruff format

ruff Linter

Check the code for issues according to the linting rules in the pyproject.toml file:

uv run ruff check

Fix any issues that can be fixed automatically:

uv run ruff check --fix

mypy

Perform static type checking on source code:

uv run mypy

pytest

Run all tests (with coverage) using:

uv run pytest

Generate a coverage report in addition to running the tests:

uv run pytest --cov=rapid --cov-branch --cov-report=json --cov-report=term-missing

Documentation

See axtreme's documentation on GitHub pages.

Notes on Design Decisions

Imports

We are breaking this rule, and often import classes etc. This follows the approach taken in packages such as pytorch botorch etc.

Definition

Google code standard suggests:

"Use import statements for packages and modules only, not for individual types, classes, or functions"

pros

  • often package with similar names (e.g utils), but the actual method required is clear diferentiated.
  • Less verbose

cons

  • Breaking some recommended practice, not sure what they impact will be.

Numpy vs. Tensors

  • Numpy: Working with ax/in general
  • Torch: working inside or touching "Botorch Layer", or anywhere need gpu or grad

pros

  • If work mostly with tensor need to constantly convert them to numpy when winteracting with ax, plot etc.

cons

  • numpy and tensors have slightly different interfaces
  • Means we don't have one default way of working

Meta

Copyright (c) 2024 DNV AS. All rights reserved.

Sebastian Winter - sebastian.winter@dnv.com

Kristoffer Skare - kristoffer.skare@dnv.com

Magnus Kristiansen - magnus.kristiansen@dnv.com

Distributed under the MIT license. See LICENSE for more information.

https://github.com/dnv-opensource/axtreme

Contributing

  1. Fork it (https://github.com/dnv-opensource/axtreme/fork) (Note: this is currently disabled for this repo. For DNV internal development, continue with the next step.)
  2. Create an issue in your GitHub repo
  3. Create your branch based on the issue number and type (git checkout -b issue-name)
  4. Evaluate and stage the changes you want to commit (git add -i)
  5. Commit your changes (git commit -am 'place a descriptive commit message here')
  6. Push to the branch (git push origin issue-name)
  7. Create a new Pull Request in GitHub

For your contribution, please make sure you follow the STYLEGUIDE before creating the Pull Request.

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

axtreme-0.1.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

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

axtreme-0.1.0-py3-none-any.whl (82.1 kB view details)

Uploaded Python 3

File details

Details for the file axtreme-0.1.0.tar.gz.

File metadata

  • Download URL: axtreme-0.1.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for axtreme-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2f0e1ebcd63f12bb6ebb83bbd1e68789fe57a77c990a9cf40d58197540b36e97
MD5 bdf1e7f8e15971591f56c6576f110d3a
BLAKE2b-256 30871fd75d5ee98cff74fdf65c3ed2e4ee90f641577790634df8aaa6ab39d42c

See more details on using hashes here.

Provenance

The following attestation bundles were made for axtreme-0.1.0.tar.gz:

Publisher: publish_release.yml on dnv-opensource/axtreme

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file axtreme-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: axtreme-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 82.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for axtreme-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dbd2bd4c5f18fe43a755b030e959c4f5ad8d6fcc2bb38fb5cfeb71747e7b22ec
MD5 571e7206f6b13346985be8c4d58c929c
BLAKE2b-256 32fde3376ebf5b904b1213de6f9048ec83660178a20e0bd6bd6df18070e5ebb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for axtreme-0.1.0-py3-none-any.whl:

Publisher: publish_release.yml on dnv-opensource/axtreme

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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