-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfunction.py
More file actions
45 lines (35 loc) · 1.23 KB
/
function.py
File metadata and controls
45 lines (35 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from __future__ import annotations
from typing import Any, Dict, Optional
from morph_lib.error import MorphApiError
from morph.config.project import load_project
from morph.task.utils.logging import get_morph_logger
from morph.task.utils.morph import find_project_root_dir
from morph.task.utils.run_backend.execution import run_cell
from morph.task.utils.run_backend.state import (
MorphFunctionMetaObjectCacheManager,
MorphGlobalContext,
)
def load_data(alias: str, variables: Optional[Dict[str, Any]] = None) -> Any:
"""
Get execution result of the alias.
"""
project_root = find_project_root_dir()
project = load_project(project_root)
if not project:
raise MorphApiError("Project configuration not found.")
context = MorphGlobalContext.get_instance()
context.partial_load(project_root, alias)
resource = context.search_meta_object_by_name(alias)
if not resource:
raise MorphApiError(f"Resource {alias} not found.")
meta_obj_cache = MorphFunctionMetaObjectCacheManager().get_cache()
vars = variables or {}
logger = get_morph_logger()
return run_cell(
project,
resource,
vars,
logger,
None,
meta_obj_cache,
).result