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

Providing custom de-serializer for AiiDA data #13

Closed
mikibonacci opened this issue Jan 22, 2025 · 2 comments · Fixed by #15
Closed

Providing custom de-serializer for AiiDA data #13

mikibonacci opened this issue Jan 22, 2025 · 2 comments · Fixed by #15

Comments

@mikibonacci
Copy link

mikibonacci commented Jan 22, 2025

I was thinking on some custom de-serializer, in such a way to provide AiiDA data which does not have a value property, i.e. which cannot be automatically serialized.
For example, I want to provide an orm.StructureData to a PythonJob, and this is not possible (we don't have the value property). So, I will not have the orm.StructureData node in the provenance of the job. But the AtomsData (if I want to use ASE in the job). This will somehow make provenance strange, as for the top level WorkGraph I will indeed have the orm.StructureData node. Examples are from here, check out the UndiAndKuboToyabe WG and the undi_runs PJob.

A simple solution would be to define, before the de-serialization (or during its action), the value attribute like this:

from aiida import orm

s = orm.StructureData()
de_serializer_method = "get_ase"

s.value = getattr(s,de_serializer_method)()

Then, s.value is just the ase.Atoms object which can be used in the PJob.
Is it a bit hacky maybe, and requires the user to know what he is doing. But actually, we can standardize it for several conversions (ASE, Pymatgen...) and provide documentation on how to test propertly.

This also means that we could then use the same structure node for different jobs, where different python objects (ASE, Pymatgen structures) can be used.

@superstar54 superstar54 linked a pull request Jan 23, 2025 that will close this issue
@superstar54
Copy link
Member

Hi @mikibonacci , thanks for the suggestions. I have implemented a solution in #15 . Please have a try when you have time.

@mikibonacci
Copy link
Author

Hi @superstar54, thanks a lot for the solution, I like it (my solution was too hacky).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants