Skip to main content

Opinionated wrappers for the mlflow tracking API.

Project description

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

Opinionated wrappers for the mlflow tracking API.

from actarius import NewExperimentRun

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.

2 Installation

pip install actarius

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},
)

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.

5 Contributing

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]'

5.2 Running the tests

To run the tests use:

cd actarius
pytest

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.

6 Credits

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

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

actarius-0.0.2.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

actarius-0.0.2-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file actarius-0.0.2.tar.gz.

File metadata

  • Download URL: actarius-0.0.2.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for actarius-0.0.2.tar.gz
Algorithm Hash digest
SHA256 af7b0bcb56f59cbbd84648dfa7b01ab5de534c2eb3906ebb4afa2668a287fe37
MD5 faa3049da9ca88a2b56ff314a50cd70a
BLAKE2b-256 f7b0a2fbc49708e3da7080168755594143333aef7ab01fda682f7b7327721a82

See more details on using hashes here.

File details

Details for the file actarius-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: actarius-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for actarius-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 48ef5bc15f34c44c72e13e65ea77c5c7a462fe9f6cc57a76f52c0ebcffa9950c
MD5 10a05d46672074bda3d229c465525983
BLAKE2b-256 749efc5d5b177ae0df4462327f1bb70f967cd8f6b1b1c191692b92b1a085d24c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page