Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/launch_experi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from experi.run import launch as launch_experi

launch_experi("demo.yml")
23 changes: 15 additions & 8 deletions src/experi/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,20 @@ def _set_verbosity(ctx, param, value):
logging.basicConfig(level=logging.DEBUG)


def launch(input_file="experiment.yml", use_dependencies=False, dry_run=False) -> None:
# This function provides an API to access experi's functionality from within
# python scripts, as an alternative to the command-line interface

# Process and run commands
input_file = Path(input_file)
structure = read_file(input_file)
scheduler = process_scheduler(structure)
jobs = process_structure(
structure, scheduler, Path(input_file.parent), use_dependencies
)
run_jobs(jobs, scheduler, input_file.parent, dry_run)


@click.command()
@click.version_option()
@click.option(
Expand Down Expand Up @@ -606,11 +620,4 @@ def _set_verbosity(ctx, param, value):
help="Increase the verbosity of logging events.",
)
def main(input_file, use_dependencies, dry_run) -> None:
# Process and run commands
input_file = Path(input_file)
structure = read_file(input_file)
scheduler = process_scheduler(structure)
jobs = process_structure(
structure, scheduler, Path(input_file.parent), use_dependencies
)
run_jobs(jobs, scheduler, input_file.parent, dry_run)
launch(input_file, use_dependencies, dry_run)