Skip to main content

1 actarius

PyPI-Status PyPI-Versions Build-Status Codecov Codefactor code quality LICENCE

Opinionated wrappers for the mlflow tracking API.

from actarius import NewExperimentRun

1.1 Features

actarius is meant to facilitate the way we log mlflow experiments in BigPanda, which means the following additions over the mlflow tracking API:

  • Automatically logging stdout and stderr to file (without hiding them from the terminal/console) and logging this file an easilly readable artifact of the experiment. This supports nested experiment run contexts.

  • Adding a bunch of default tags (currently focused around git).

  • Convenience logging methods for dataframes as CSVs, and of arbitrary Python objects as either Pickle or text files (the latter using their inherent text represention).

  • Warning but not erroring when mlflow is badly- or not configured.

1.2 Installation

pip install actarius

1.3 Use

actarius provides a custom context manager that wraps around MLflow code to help you run and track experiments using BigPanda’s conventions.

This context manager should be provided with some basic parameters that configure which experiment is being run:

from actarius import ExperimentRunContext, log_df
expr_databricks_path = 'Shared/experiments/pattern_generation/run_org'
with ExperimentRunContext(expr_databricks_path):
  mlflow.set_tags({'some_tag': 45})
  mlflow.log_params({'alpha': 0.5, 'beta': 0.2})
  # run experiment code...
  mlflow.log_metrics({'auc': 0.71, 'stability': 33.43})
  log_df(my_df)

actarius also provides an experiment object that needs to be closed explicitly:

from actarius import ExperimentRun
expr_databricks_path = 'Shared/experiments/pattern_generation/run_org'
exp_obj = ExperimentRun(expr_databricks_path)
exp_obj.set_tags({'some_tag': 45})
exp_obj.log_params({'alpha': 0.5, 'beta': 0.2})
# run experiment code...
exp_obj.log_df(my_df)
exp_obj.end_run(
  tags={'another_tag': 'test'},
  params={'log_param_here': 4},
  metrics={'auc': 0.71, 'stability': 33.43},
)

1.4 Configuration

actarius will fail silently if either mlflow or the databricks cli is not correctly configured. It will issue a small warning on each experiment logging attempt, however (each closing of an experiment context, and each explicit call to an end_run() method of an actarius.ExperimentRun object).

Additionally, in this case experiment results will be logged into the ./mlruns/ directory (probably to the ./mlruns/0/ subdirectory), with random run ids determined and used to create per-run sub-directories.

To have the stack trace of the underlying error printed after the warning, simply set the value of the ACTARIUS__PRINT_STACKTRACE environment variable to True. Runing will then commence regularly.

1.5 Contributing

1.5.1 Installing for development

Clone:

git clone git@github.com:bigpandaio/actarius.git

Install in development mode, including test dependencies:

cd actarius
pip install -e '.[test]'

1.5.2 Running the tests

To run the tests use:

cd actarius
pytest

1.5.3 Adding documentation

The project is documented using the numpy docstring conventions, which were chosen as they are perhaps the most widely-spread conventions that are both supported by common tools such as Sphinx and result in human-readable docstrings. When documenting code you add to this project, follow these conventions.

Additionally, if you update this README.rst file, use python setup.py checkdocs to validate it compiles.

1.6 Credits

Created by Shay Palachy (shay.palachy@gmail.com).

Release files for actarius 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for actarius 0.0.2
File Size Uploaded
actarius-0.0.2.tar.gz 28.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for actarius 0.0.2
File Interpreter ABI Platform
actarius-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 42.9 kB

Release files / actarius-0.0.2.tar.gz

Download URL actarius-0.0.2.tar.gz
Size 28.8 kB
Tags Source
SHA-256 checksum
How to use checksums
af7b0bcb56f59cbbd84648dfa7b01ab5de534c2eb3906ebb4afa2668a287fe37
BLAKE2b-256 checksum
How to use checksums
f7b0a2fbc49708e3da7080168755594143333aef7ab01fda682f7b7327721a82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

Release files / actarius-0.0.2-py3-none-any.whl

Download URL actarius-0.0.2-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48ef5bc15f34c44c72e13e65ea77c5c7a462fe9f6cc57a76f52c0ebcffa9950c
BLAKE2b-256 checksum
How to use checksums
749efc5d5b177ae0df4462327f1bb70f967cd8f6b1b1c191692b92b1a085d24c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page