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

Fix execution_count, and only show new_data if it not empty #273

Merged
merged 1 commit into from
Aug 26, 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
6 changes: 3 additions & 3 deletions aiida_workgraph/engine/workgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def define(cls, spec: WorkChainSpec) -> None:

spec.outputs.dynamic = True

spec.output_namespace("new_data", dynamic=True)
spec.output(
"execution_count",
valid_type=orm.Int,
Expand Down Expand Up @@ -481,7 +480,7 @@ def setup(self) -> None:
self.init_ctx(wgdata)
#
self.ctx._msgs = []
self.ctx._execution_count = 0
self.ctx._execution_count = 1
# init task results
self.set_task_results()
# data not to be persisted, because they are not serializable
Expand Down Expand Up @@ -1499,7 +1498,8 @@ def finalize(self) -> t.Optional[ExitCode]:
)
self.out_many(group_outputs)
# output the new data
self.out("new_data", self.ctx._new_data)
if self.ctx._new_data:
self.out("new_data", self.ctx._new_data)
self.out("execution_count", orm.Int(self.ctx._execution_count).store())
self.report("Finalize workgraph.")
for _, task in self.ctx._tasks.items():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_while.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_while_workgraph(decorated_add, decorated_multiply, decorated_compare):
add1.set_context({"result": "n"})
wg.add_link(multiply1.outputs["result"], add1.inputs["x"])
wg.submit(wait=True, timeout=100)
assert wg.execution_count == 3
assert wg.execution_count == 4
assert wg.tasks["add1"].outputs["result"].value == 29


Expand Down
Loading