Development repo for the RaPiD project with extensions for Ax and BoTorch.
src/: Main package directorytests/: Test directoryexamples/: Examples and demostutorials/: Tutorial notebooks
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 updateThis 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 installThis 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.Pythonor you can download and install Python from the python.org website.
Clone the axtreme repository into your local development directory:
git clone https://github.com/dnv-opensource/axtreme path/to/your/dev/axtremeChange into the project directory after cloning:
cd axtremeRun uv sync to create a virtual environment and install all project dependencies into it:
uv syncNote: Using
--no-devwill omit installing development dependencies.
Note:
uvwill create a new virtual environment called.venvin the project root directory when runninguv syncthe first time. Optionally, you can create your own virtual environment using e.g.uv venv, before runninguv sync.
Run uv sync with option --extra cuda to in addition install torch with CUDA support:
uv sync --extra cudaNote: The exact version of
torchthat 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/cu124Hint: 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).
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/activatepre-commit can be used locally as a convenience tool to run checks such as pyright and ruff. If you choose to use it, you should check that the dependencies and versions match that in pyproject.toml.
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 installAll 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-filesTo skip the pre-commit validation on commits (e.g. when intentionally committing broken code), run:
uv run git commit -m <MSG> --no-verifyTo update the hooks configured in .pre-commit-config.yaml to their newest versions, run:
uv run pre-commit autoupdateTo test that the installation works, run pytest in the project root folder:
uv run pytestYou should now be ready to start developing!
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:
Format the code according to the formatting rules in the pyproject.toml file:
uv run ruff formatCheck the code for issues according to the linting rules in the pyproject.toml file:
uv run ruff checkFix any issues that can be fixed automatically:
uv run ruff check --fixPerform static type checking on source code:
uv run mypyRun all tests (with coverage) using:
uv run pytestGenerate a coverage report in addition to running the tests:
uv run pytest --cov=rapid --cov-branch --cov-report=json --cov-report=term-missingSee axtreme's documentation on GitHub pages.
Copyright (c) 2024 DNV AS. All rights reserved.
Sebastian Winter - [email protected]
Kristoffer Skare - [email protected]
Magnus Kristiansen - [email protected]
Distributed under the MIT license. See LICENSE for more information.
https://github.com/dnv-opensource/axtreme
- 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.)
- Create an issue in your GitHub repo
- Create your branch based on the issue number and type (
git checkout -b issue-name) - Evaluate and stage the changes you want to commit (
git add -i) - Commit your changes (
git commit -am 'place a descriptive commit message here') - Push to the branch (
git push origin issue-name) - Create a new Pull Request in GitHub
For your contribution, please make sure you follow the STYLEGUIDE before creating the Pull Request.