Experiment Graph
module crystallize.experiments.experiment_graph
Section titled “module crystallize.experiments.experiment_graph”Orchestrator for chaining multiple experiments via a DAG.
Global Variables
Section titled “Global Variables”- BASELINE_CONDITION
function find_experiments_root
Section titled “function find_experiments_root”find_experiments_root(start: 'Path', strict: 'bool' = True) → PathWalk up from start until we find a directory that either is called ‘experiments’ or contains a sub-directory called ‘experiments’.
If not found:
- when
strict=True(default), raise FileNotFoundError (explicit failure). - when
strict=False, returnstartand log a warning.
class ExperimentGraph
Section titled “class ExperimentGraph”Manage and run a directed acyclic graph of experiments.
method ExperimentGraph.__init__
Section titled “method ExperimentGraph.__init__”__init__(*experiments: 'Experiment', name: 'str | None' = None) → NoneCreate a graph and optionally infer dependencies from experiments.
method ExperimentGraph.add_dependency
Section titled “method ExperimentGraph.add_dependency”add_dependency(downstream: 'Experiment', upstream: 'Experiment') → NoneAdd an edge from upstream to downstream.
method ExperimentGraph.add_experiment
Section titled “method ExperimentGraph.add_experiment”add_experiment(experiment: 'Experiment') → NoneAdd an experiment node to the graph.
method ExperimentGraph.arun
Section titled “method ExperimentGraph.arun”arun( treatments: 'List[Treatment] | None' = None, replicates: 'int | None' = None, strategy: 'str | None' = None, progress_callback: 'Callable[[str, str], Awaitable[None]] | None' = None) → Dict[str, Result]Execute all experiments respecting dependency order.
classmethod ExperimentGraph.from_experiments
Section titled “classmethod ExperimentGraph.from_experiments”from_experiments(experiments: 'List[Experiment]') → 'ExperimentGraph'Construct a graph automatically from experiment dependencies.
Parameters ---------- experiments: List of all experiments that form the workflow.
Returns ------- ExperimentGraph Fully built and validated experiment graph.
classmethod ExperimentGraph.from_yaml
Section titled “classmethod ExperimentGraph.from_yaml”from_yaml(config: 'str | Path') → 'ExperimentGraph'Load an experiment graph starting from config.
The config argument should point to a config.yaml file for the final experiment. All upstream experiments referenced via experiment#artifact notation are discovered recursively in sibling directories.
method ExperimentGraph.run
Section titled “method ExperimentGraph.run”run( treatments: 'List[Treatment] | None' = None, replicates: 'int | None' = None, strategy: 'str | None' = None) → Dict[str, Result]Synchronous wrapper for the async arun method.
classmethod ExperimentGraph.visualize_from_yaml
Section titled “classmethod ExperimentGraph.visualize_from_yaml”visualize_from_yaml(config: 'str | Path') → NonePrint dependencies and execution order for a YAML graph.