-
Notifications
You must be signed in to change notification settings - Fork 5
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
Use calcfunction for getitem in For
loop workgraph
#283
base: main
Are you sure you want to change the base?
Conversation
Hi @agoscinski , thanks for the work. There is a function It's also would be good if the user can supply a list of AiiDA data as the input for [structure0, structure1, ...] Because AiiDA does not support a list of AiiDA data as input, internally, we can change it to a dict with keys, the keys keep the order information. {"sequence_0": structure0, ...} and then, in the WorkGraph engine, if the sequence is a dict, we get the AiiDA data directly without serialization. |
Thanks @superstar54 applied your suggestion. The test pass, but it does not test the other use cases you mentioned. I tried to implement a dictionary, but it is a bit opaque to me how to change the iterator to be compatible with dictionaries that use hashable keys. It seems the iterator is hard coded to only work for collections that can be accessed by incremental increasing numbers like lists. Maybe we should generalize this for arbitrary generators. Not sure if this PR is the right place. |
becb66a
to
a4d8ab5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @agoscinski , thanks for the work!
Please test for the changes.
As mentioned in my previous comment, if you use a list of orm.data as the sequence, it will raise an error, because we need to change the list to a dict.
Therefore, you need also modify the aiida_workgraph.workgraph.WorkGraph
to convert it into a dict. Then inside the engine, the sequence is a dict.
aiida_workgraph/engine/workgraph.py
Outdated
@calcfunction | ||
def __getitem__(sequence, count): | ||
value = sequence[count.value] | ||
# only convert value f not already orm type because sequence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# only convert value f not already orm type because sequence | |
# only convert value if not already orm type because sequence |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #283 +/- ##
==========================================
+ Coverage 75.75% 80.70% +4.95%
==========================================
Files 70 66 -4
Lines 4615 5157 +542
==========================================
+ Hits 3496 4162 +666
+ Misses 1119 995 -124
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
To track the provenance in the for loop we now use a calcfunction to track provenance for the
For
loop workgraph. I would like to allow more types than integers for the sequence, but I am not sure how to generically test for types that are supported by aiida core. Some orm types have a_type
class attribute, but not all of them.TODO: