Replace the dict-based way of declaring sockets and namespaces with the spec API#35
Replace the dict-based way of declaring sockets and namespaces with the spec API#35superstar54 merged 12 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #35 +/- ##
==========================================
+ Coverage 83.72% 84.15% +0.42%
==========================================
Files 19 20 +1
Lines 1063 1136 +73
==========================================
+ Hits 890 956 +66
- Misses 173 180 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| ###################################################################### | ||
| # Default outputs | ||
| # -------------- | ||
| # ----------------- |
There was a problem hiding this comment.
Just for future reference, it only needs to be as long as the title (less raises an issue, more is unnecessary) 🙂
| import cloudpickle | ||
|
|
||
| if self._func is None: | ||
| if not getattr(self, "_func", None): |
There was a problem hiding this comment.
Because ._func is no longer guaranteed?
There was a problem hiding this comment.
I encountered _func does not exist one time, but I can not reproduce, maybe when reloading the process (e.g., when the daemon restarts). But this should be fixed in another method. I have update it in this commit
There was a problem hiding this comment.
Can you explain this file?
There was a problem hiding this comment.
Yes, the spec API and its related utilities are defined in node-graph and reused by WorkGraph and PythonJob, which keeps this API as the single source of truth. To avoid exposing the "socket" concept to PythonJob users (since it's an AiiDA plugin that can be used independently of WorkGraph), a simple adapter is used to convert "socket" to "port".
It's hard to decide where we put the spec API, we keep it in the node-graph for now.
There was a problem hiding this comment.
Socket and Port are very similar schemas, but Socket has more metadata (e.g., links).
spec
This PR replaces the old dict-based way of declaring sockets and namespaces with the
specAPI fromnode-graph.In this way, one can declare the
output_sepc=spec.dynamic(any)output_spec=spec.dynamic(spec.namespace(sum=int))Before
After
Or, one can use type annotation directly: