Skip to content

Commit

Permalink
Fix execution_count, and only show new_data if it not empty (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Aug 26, 2024
1 parent 84d0abb commit ece97b9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion aiida_workgraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
from .task import Task
from .decorator import task, build_task

__version__ = "0.3.23"
__version__ = "0.3.24"

__all__ = ["WorkGraph", "Task", "task", "build_task"]
1 change: 0 additions & 1 deletion aiida_workgraph/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def new(

# build the socket on the fly if the identifier is a callable
if callable(identifier):
print("identifier is callable", identifier)
identifier = build_socket_from_AiiDA(identifier)
# Call the original new method
return super().new(identifier, name, **kwargs)
7 changes: 3 additions & 4 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 @@ -667,7 +666,6 @@ def kill_task(self, name: str) -> None:
self.logger.error(f"Error in killing task {name}: {e}")

def continue_workgraph(self) -> None:
print("Continue workgraph.")
self.report("Continue workgraph.")
# self.update_workgraph_from_base()
task_to_run = []
Expand Down Expand Up @@ -1499,7 +1497,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

0 comments on commit ece97b9

Please sign in to comment.