Environment variables provide runtime metadata about your workflow or model execution. Use them to build dynamic paths, log run information, or integrate with external systems.
Available Variables
| Variable | Description | Example |
|---|---|---|
MIXTRAIN_RUN_NUMBER | Sequential run number for this workflow/model | "1", "42" |
MIXTRAIN_WORKFLOW_NAME | Name of the workflow (only set for workflows) | "my-workflow" |
MIXTRAIN_MODEL_NAME | Name of the model (only set for models) | "my-model" |
WORKSPACE_NAME | Current workspace name | "my-workspace" |
Usage
Access these variables using Python's os.getenv():
import os
from mixtrain import MixFlow
class MyWorkflow(MixFlow):
def run(self):
run_number = os.getenv("MIXTRAIN_RUN_NUMBER")
workflow_name = os.getenv("MIXTRAIN_WORKFLOW_NAME")
workspace = os.getenv("WORKSPACE_NAME")
# Build dynamic output paths
output_path = f"/data/results/{workflow_name}/run_{run_number}/"
print(f"Run #{run_number} of {workflow_name} in {workspace}")
return {"output_path": output_path}Common Patterns
Versioned Output Paths
def run(self):
run_num = os.getenv("MIXTRAIN_RUN_NUMBER")
name = os.getenv("MIXTRAIN_WORKFLOW_NAME")
# Each run saves to a unique directory
self.save_model(f"/data/models/{name}/v{run_num}/model.pt")Logging Run Context
def run(self):
context = {
"run": os.getenv("MIXTRAIN_RUN_NUMBER"),
"workflow": os.getenv("MIXTRAIN_WORKFLOW_NAME"),
"workspace": os.getenv("WORKSPACE_NAME"),
}
print(f"Starting run with context: {context}")