diff --git a/psiflow/__init__.py b/psiflow/__init__.py index bd179fc..5ad963d 100644 --- a/psiflow/__init__.py +++ b/psiflow/__init__.py @@ -1,6 +1,6 @@ import parsl -from .execution import ExecutionContextLoader +from .execution import ExecutionContextLoader, load_from_yaml # noqa: F401 load = ExecutionContextLoader.load parse_config = ExecutionContextLoader.parse_config diff --git a/psiflow/execution.py b/psiflow/execution.py index 5b04f34..053eab0 100644 --- a/psiflow/execution.py +++ b/psiflow/execution.py @@ -377,3 +377,11 @@ def context(cls): if cls._context is None: raise RuntimeError("No ExecutionContext is currently loaded") return cls._context + + +def load_from_yaml(path: Union[str, Path]) -> ExecutionContext: + assert ExecutionContextLoader._context is None # no previously loaded context + with open(path, "r") as f: + config_dict = yaml.safe_load(f) + psiflow_config, definitions = ExecutionContextLoader.parse_config(config_dict) + return ExecutionContextLoader.load(psiflow_config, definitions)