Skip to content

Commit

Permalink
add convenience function for yaml loading
Browse files Browse the repository at this point in the history
  • Loading branch information
svandenhaute committed Oct 29, 2023
1 parent 7a513f1 commit 2d243d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion psiflow/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions psiflow/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 2d243d6

Please sign in to comment.