API Reference
Tracking Module
ExperimentTracker
researchlab.tracking.tracker.ExperimentTracker
A context manager for tracking research experiments with Git state.
This class automates the process of starting an MLflow run, capturing the current Git state (base commit and diff), and logging artifacts and parameters.
Example
Attributes:
| Name | Type | Description |
|---|---|---|
run_name |
str
|
The unique, readable ID for this run. |
active_run |
Optional[Run]
|
The currently active MLflow run. |
Source code in src/researchlab/tracking/tracker.py
__enter__()
Starts the MLflow run and captures the Git state.
Returns:
| Name | Type | Description |
|---|---|---|
ExperimentTracker |
ExperimentTracker
|
The instance of the tracker. |
Source code in src/researchlab/tracking/tracker.py
__exit__(exc_type, exc_val, exc_tb)
__init__(experiment_name, run_name=None, tracking_uri=None)
Initializes the ExperimentTracker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_name
|
str
|
The name of the MLflow experiment. |
required |
run_name
|
str | None
|
Optional custom name for the run. If not provided, a readable ID is generated automatically. |
None
|
tracking_uri
|
str | None
|
Optional MLflow tracking URI to use. |
None
|
Source code in src/researchlab/tracking/tracker.py
log_config(config_path)
Logs a YAML configuration file as parameters and an artifact.
Recursively parses the YAML file and logs each entry as an MLflow parameter. Also uploads the file itself as an artifact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
str
|
Path to the YAML configuration file. |
required |
Source code in src/researchlab/tracking/tracker.py
Utilities
researchlab.tracking.utils
find_run_by_rlab_id(run_id)
Finds an MLflow run by the custom rlab.run_id tag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
str
|
The readable rlab run ID to search for. |
required |
Returns:
| Type | Description |
|---|---|
Run | None
|
Optional[Run]: The MLflow Run object if found, else None. |
Source code in src/researchlab/tracking/utils.py
generate_run_id()
Generates a unique and readable run ID.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string in the format YYYY-MM-DD_slug (e.g., 2026-02-15_radiant-octopus). |
Source code in src/researchlab/tracking/utils.py
get_git_state(repo_path='.')
Captures the current Git state including base commit and patch.
This captures staged, unstaged, and untracked changes by temporarily using git's "intent-to-add" feature. It restores the untracked state after generating the patch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
repo_path
|
str
|
Path to the git repository. Defaults to ".". |
'.'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: A dictionary containing: - base_commit (str): The HEX SHA of the current HEAD. - patch (str): The git diff output. - is_dirty (bool): True if there are any changes (including untracked). |
Source code in src/researchlab/tracking/utils.py
log_flattened_params(d, prefix='')
Recursively logs a dictionary as flattened MLflow parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
dict[str, Any]
|
The dictionary to log. |
required |
prefix
|
str
|
Optional prefix for parameter keys (used for recursion). |
''
|