Skip to main content

A simple helper to run pipelines of PytorchLightning models

Project description

TrainTrack ML

Quickly run stages of an ML pipeline from the command line

Documentation

ci Code style: black

Welcome to repository and documentation the TrainTrack library. Detailed documentation coming very soon! See here for the documentation of the examples of this library.

Install

TrainTrack is most easily installed with pip:

pip install traintrack

Objective

The aim of TrainTrack is simple: Given any set of self-contained Pytorch Lightning modules, run them in a serial and trackable way.

At its heart, TrainTrack is nothing more than a loop over the stages defined in a pipeline.yaml configuration file. However, it can also handle data processing steps (i.e. non-trainable modules), automatically creates grid scans over combinations of hyperparameters, logs training with (currently) either Tensorboard or Weights & Biases, and can run separate, dependent Slurm batch jobs. It also has an opinionated approach to how data is passed from stage to stage, via Lightning callbacks. In this way, the only code that needs to be written is Lightning modules, all other boilerplate and tracking is handled by TrainTrack.

Example

traintrack uses two ingredients to run and track your training pipeline:

  1. A project configuration file
  2. A pipeline configuration file

It also makes one or two assumptions about the structure of your project. For project MyFirstMNIST, we should structure it as

📦 MyFirstMNIST
┣ 📂 architectures
┣ 📂 notebooks
┣ 📂 configs
┃ ┣ 📜 project_config.yaml
┃ ┗ 📜 my_first_pipeline.yaml
┗ 📂 logs

Note: Only configs/project_config.yaml is a required file. All else is configurable. An example project_config.yaml:

# project_config.yaml

# Location of libraries
libraries:
    model_library: architectures
    artifact_library: /my/checkpoint/directory
    

# The lines you would like/need in a batch script before the call to pipeline.py
custom_batch_setup:
    - conda activate my-favorite-environment
    
# If you need to set up some environment before a batch is submitted, define it here in order of commands to run
command_line_setup:
    - module load cuda
    
# If you need to run jobs serially, set to true
serial: False

# Which logger to use - options are Weights & Biases [wandb], TensorBoard [tb], or [None]
logger: wandb

We can launch a vanilla run of TrainTrack with

traintrack configs/my_first_pipeline.yaml

This trains and performs inference callbacks in the terminal.

A Pipeline

The pipeline config file defines a pipeline, for example:

# my_first_pipeline.yaml

stages:
    - {set: CNN, name: ResNet50, config: test_train.yaml}

which presumes a directory structure of:

📦 MyFirstMNIST
┣ 📂 architectures
┃ ┗ 📂 CNN
┃ ┃ ┣ 📜 cnn_base.py
┃ ┃ ┣ 📜 test_train.yaml
┃ ┃ ┗ 📂 Models
┃ ┃ ┃ ┗ 📜 resnet.py

Again, see this repository for example pipelines in action.

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

traintrack-0.1.6.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

traintrack-0.1.6-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file traintrack-0.1.6.tar.gz.

File metadata

  • Download URL: traintrack-0.1.6.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.10

File hashes

Hashes for traintrack-0.1.6.tar.gz
Algorithm Hash digest
SHA256 113e31731b7763b7f985318936e17abe92bf89d5ba44bb7184c0b4d9c2b3c055
MD5 7d16eb3855fc3869f4e225519cac35e8
BLAKE2b-256 8b7c88f9b6652b2f0bb73a6d9f37da92aaef83b540a7db749c2f92b55cfa4098

See more details on using hashes here.

File details

Details for the file traintrack-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: traintrack-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.10

File hashes

Hashes for traintrack-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ac0a87e4dac024c1e4996f343badd358f5242b096adcc032ded26476cc5b2676
MD5 e218d422fd5c4a288dc19ad30d3dbed1
BLAKE2b-256 417b615b9679afe4ba043c61465e95fafb13b22e3d2036059d29c3e058490b55

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