♻️ Adopt node-graph's GraphTaskHandle for @task.graph decorators#796
Draft
elinscott wants to merge 1 commit into
Draft
♻️ Adopt node-graph's GraphTaskHandle for @task.graph decorators#796elinscott wants to merge 1 commit into
GraphTaskHandle for @task.graph decorators#796elinscott wants to merge 1 commit into
Conversation
node-graph aiidateam#150 made ``build`` graph-only by handle type, removing it from ``BaseHandle``. The graph decorator still returned a plain ``TaskHandle``, so every ``@task.graph`` handle lost ``build``/``run``/``run_get_graph``/``submit`` when paired with node-graph > 0.6.5. Mirror node-graph's own decorator: the graph decorator now returns a ``GraphTaskHandle`` carrying the four graph-materializing methods. Plain task handles drop them - they only ever raised there, and plain handles keep node-graph's direct-execute ``run`` semantics. Requires node-graph with aiidateam#150 (unreleased at time of writing). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
node-graph #150 made
buildgraph-only by handle type: it removed the method (and its runtimetask_type != "GRAPH"guard) fromBaseHandleand moved it to a newGraphTaskHandle. node-graph's own decorator now dispatches on the spec type:aiida-workgraph's graph decorator still returns a plain
TaskHandle, so when paired withnode-graph > 0.6.5every@task.graphhandle losesbuild/run/run_get_graph/submit:Change
Mirror the upstream pattern:
aiida_workgraph.task.GraphTaskHandle(TaskHandle), returned by the@task.graphdecorator.builddelegates to node-graph'sGraphTaskHandle.buildrather than inheriting it, because node-graph's__init__takesspeconly, while ours must also wireget_current_graphandgraph_class=WorkGraph. The delegation only needsself._spec/self._graph_class/self.identifier, all present here.run,run_get_graphandsubmitmove fromTaskHandleontoGraphTaskHandle. They all materialize aWorkGraphviaself.build, which only makes sense for graph specs; on plain task handles they only ever raised. Plain handles now keep node-graph's direct-executerunsemantics, matching the behaviour of New syntax for thegraph_builder's output #150Compatibility
#150 is unreleased at the time of writing; the
node-graphversion pin should be bumped upon the next node-graph release, and this PR should not be merged prior.