Open mikibonacci opened 9 months ago
Hi @mikibonacci Is it possible to define custom properties now?
I tried
properties_dict = {
"cell":{"value":[[3.5, 0.0, 0.0], [0.0, 3.5, 0.0], [0.0, 0.0, 3.5]]},
"pbc":{"value":[True,True,True]},
"positions":{"value":[[0.0, 0.0, 0.0],[1.5, 1.5, 1.5]]},
"charge": {"value": [1.0, 1.0]},
"fix": {"value": [[True,True,True],[True,True,True]]},
"symbols":{"value":["Li","Li"]},
}
structure = StructureData(properties = properties_dict)
It raises
NotImplementedError: Property 'fix' is not yet supported.
Supported properties are: ['charge', 'pbc', 'positions', 'cell', 'kinds', 'symbols', 'mass', 'custom']
This is an important feature, and it's would be great if we support it.
Currently, we cannot define unsupported properties (some check in
set_property
method against theget_valid_properties
output), or defined property with some parameters which is not recognized (extra parameters);unsupported properties
When a structure is passed to a plugin calcjob/workchain, there should be a check on all the properties associated to the structure. Then two behaviors can happen:
1 - the code uses a calcfunction to create a new instance of the StructureData without the not supported property 2 - the code warns about the unsupported property, but skips it and continue; this can also be done using some keyword
ignore_property="hubbard"
The second option is the preferred one if we have multiple codes which support different properties, and also avoid some StructureData duplication. -> it should be obvious how and why the property is ignored in the plugin (for example if you look at an old calculation, you should understand the decision clearly). There should be a part of the documentation which explain how to do it in a plugin, the keywords to be used, the warnings/exceptions
custom properties
We may also let the user to define some custom properties, as done in optimade by means of a
prefix
. This means that the StructureData should support such custom property definition, and maybe store them under a different key in the attributes, in such a way to easily find/recognise them. We should provide a template on how to define such properties.