Open chrisjsewell opened 3 years ago
I personally agree that the way that this was coded is not ideal and the concept of importers and exporters should be more "pluginnable". It is not just the base Data
class that has code that is too tightly coupled, but also the StructureData
suffers from code that directly builds in compatibility with ASE and pymatgen, for example, instead of making it easy to extend support to whatever library externally.
The reason I never touched this is because it is actually being used. Exactly due to the design of the code you highlight, it is difficult to detect though since the actual methods that are called are built "dynamically".
The use of _getobject, prepare, and parse* methods are completely undocumented. Given this, I strongly doubt any user or plugin really uses them.
At the very least these are exposed through the CLI, e.g., verdi data structure export
and similar commands will call through to those. Same goes for importers. So I think this functionality is most likely being used and we would have to deprecate it once we find a better architecture to support adding export/import functionality of data types.
also the StructureData suffers from code that directly builds in compatibility with ASE and pymatgen
Yeh I know you were discussing this with Louis 👍
Literally, none of this should be on the base
Data
node class:https://github.com/aiidateam/aiida-core/blob/a80812c30ebb0de12f0429954508f9ceb6120d34/aiida/orm/nodes/data/data.py#L32-L39
https://github.com/aiidateam/aiida-core/blob/a80812c30ebb0de12f0429954508f9ceb6120d34/aiida/orm/nodes/data/data.py#L132-L359
_get_object_*
,_prepare_*
, and_parse_*
methods are completely undocumented. Given this, I strongly doubt any user or plugin really uses them.Data
class, i.e. there should be a separation of concerns between data and logicIt is clear that all of these methods were only really added for the
StructureData
and some other materials related subclasses; in fact the docstring forconvert
is "Convert the AiiDA StructureData into another python object".Taking each method separately, these are where they are used:
i.e. barely used
For
StructureData
it is pretty clear that the whole design is too complex, given that for every one of these methods there is a duplicate public method, e.g.More use, but again could be much better designed.
Lastly,
_export_format_replacements
is not actually used in any subclass of aiida-core.I would be happy to create a PR to remove all these methods, and re-write the code where necessary, but obviously I don't want to bother doing that without some tacit approval. Would they need to go through a deprecation cycle 🤷 (as noted, they are completely undocumented)
cc @sphuber @giovannipizzi @ltalirz