aiidateam / aiida-core

The official repository for the AiiDA code
https://aiida-core.readthedocs.io
Other
434 stars 186 forks source link

verdi data psml uploadfamily fails for AiiDA 2.0 #4932

Closed yakutovicha closed 3 years ago

yakutovicha commented 3 years ago

Describe the bug

I tried to import psml pseudo family in Quantum Mobile using the develop branch of AiiDA (sha 6c4ced3331b389cebd01a59d55eb4b07f9452672):

$ verdi data psml uploadfamily /usr/local/share/siesta/psml-files-qm/nc-sr-04_pbe_standard/ nc-sr-04_pbe_standard_psml "Pseudos from PseudoDojo." 

however, it failed with the following error:

Traceback (most recent call last):
  File "/home/max/.virtualenvs/aiida/bin/verdi", line 12, in <module>
    sys.exit(verdi())
  File "/home/max/.virtualenvs/aiida/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/max/.virtualenvs/aiida/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/max/.virtualenvs/aiida/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/max/.virtualenvs/aiida/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/max/.virtualenvs/aiida/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/max/.virtualenvs/aiida/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/max/.virtualenvs/aiida/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/max/codes/aiida-core/aiida/cmdline/utils/decorators.py", line 74, in wrapper
    return wrapped(*args, **kwargs)
  File "/home/max/.virtualenvs/aiida/lib/python3.7/site-packages/aiida_siesta/commands/data_psml.py", line 37, in psml_uploadfamily
    files_found, files_uploaded = upload_psml_family(folder, group_label, group_description, stop_if_existing)
  File "/home/max/.virtualenvs/aiida/lib/python3.7/site-packages/aiida_siesta/data/psml.py", line 113, in upload_psml_family
    pseudo, created = PsmlData.get_or_create(afile, use_first=True, store_psml=False)
  File "/home/max/.virtualenvs/aiida/lib/python3.7/site-packages/aiida_siesta/data/psml.py", line 245, in get_or_create
    instance = cls(file=filename)
  File "/home/max/codes/aiida-core/aiida/orm/nodes/data/singlefile.py", line 37, in __init__
    self.set_file(file, filename=filename)
TypeError: set_file() got multiple values for argument 'filename'
bosonie commented 3 years ago

This command is from the aiida_siesta package and probably needs to be modified in order to be compatible with aiida 2.0. In any case this command will be deprecated in favour of:

aiida-pseudo install family usr/local/share/siesta/psml-files-qm/nc-sr-04_pbe_standard/ nc-sr-04_pbe_standard_psml -P pseudo.psml
sphuber commented 3 years ago

The problem is because PsmlData.set_file uses the following (incorrect) signature:

https://github.com/siesta-project/aiida_siesta_plugin/blob/81e294fdd892a54611d76e92e06c3ba69986e1f2/aiida_siesta/data/psml.py#L308

The SinglefileData.set_file method was changed to be:

https://github.com/aiidateam/aiida-core/blob/7323962d62b0f7351f0a63010fcb0858558106d4/aiida/orm/nodes/data/singlefile.py#L69

(i.e. add the argument filename) in commit bec7ee14aeaae65a1f30b547696dd081e43629f6, which was released with `aiida-core==1.0.1. A deprecation warning has been emitted ever since if subclasses were instantiated with the old signature.

@bosonie if you are still making a release soon, maybe it would be useful to update the class method signature so that the plugin is compatible with v1.* and v2.*.

bosonie commented 3 years ago

Thanks. In case there is no other major back incompatible change, I might consider it.

sphuber commented 3 years ago

I think you should simply be able to add the filename=None argument to the set_file method and it should work

ramirezfranciscof commented 3 years ago

From the above I understand that this will then be dealt with in the aiida-siesta package, correct? If so I'm closing the issue down, but let me know if I'm misinterpreted something and you want to re-open it.

bosonie commented 3 years ago

@ramirezfranciscof correct! It is actually already fixed, but not released. In any case it is a deprecated part of the code. Thanks for closing this.