Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update root property in the case of nest namespace #350

Merged
merged 3 commits into from
Nov 21, 2024
Merged
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
5 changes: 4 additions & 1 deletion aiida_workgraph/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ def merge_properties(wgdata: Dict[str, Any]) -> None:
if "." in key and prop["value"] not in [None, {}]:
root, key = key.split(".", 1)
root_prop = task["inputs"][root]["property"]
update_nested_dict(root_prop["value"], key, prop["value"])
# update the root property
root_prop["value"] = update_nested_dict(
root_prop["value"], key, prop["value"]
)
prop["value"] = None


Expand Down
16 changes: 16 additions & 0 deletions tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,19 @@ def test_task_wait(decorated_add: Callable) -> None:
wg.run()
report = get_workchain_report(wg.process, "REPORT")
assert "tasks ready to run: add1" in report


def test_set_inputs(decorated_add: Callable) -> None:
"""Test setting inputs of a task."""

wg = WorkGraph(name="test_set_inputs")
add1 = wg.add_task(decorated_add, "add1", x=1)
add1.set({"y": 2, "metadata.store_provenance": False})
data = wg.prepare_inputs(metadata=None)
assert data["wg"]["tasks"]["add1"]["inputs"]["y"]["property"]["value"] == 2
assert (
data["wg"]["tasks"]["add1"]["inputs"]["metadata"]["property"]["value"][
"store_provenance"
]
is False
)
1 change: 1 addition & 0 deletions tests/test_workgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def test_pause_task_before_submit(wg_calcjob):
# assert wg.tasks["add2"].outputs["sum"].value == 9


@pytest.mark.skip(reason="pause task is not stable for the moment.")
def test_pause_task_after_submit(wg_calcjob):
wg = wg_calcjob
wg.tasks["add1"].set({"metadata.options.sleep": 5})
Expand Down
Loading