Many DFT codes have optional features that are only enabled when compiled with a certain library. I.e., there might be support for reading and writing netCDF files only if compiled with the optional netCDF library. For one of the codes I am working with it would be preferable to read info from netCDF files if they are available and also to provide the information for new calculation (for example info from a previous calculation to restart a new one) in the netCDF format if the code supports this. Is there any (recommended) way in AiiDA right now to store the enabled features of a certain code that can be used by a Calcjob to know if it’s possible to use the netCDF format for providing input when starting a calculation? For extracting info from netCDF files after a finished calculation you could simply check if these files are present in the output folder and if so read from those and if not default to other files, but for supplying information to a calculation you still have to start I think it’s more complicated. Many codes will probably crash if you try to supply them with netCDF files but netCDF support was not compiled in. Any help/suggestions for this would be appreciated.
There is currently no standardized way in AiiDA for this. However, you could consider using extras
for this. For example:
from aiida.orm import InstalledCode
code = InstalledCode(....).store()
code.base.extras.set('supports_netcdf', True)
In a CalcJob
plugin, you could then do the following:
if self.inputs.code.base.extras.get('supports_netcdf', None):
# Do something that requires netCDF
Thanks for the very quick reply! This sounds like an approach that might work. Is it considered okay to use the extras
attribute for this in a publicly available plugin?
Yes, this is exactly what extras were designed for. Think of them as custom “tags”. They can be set on any Node
instance. The only thing to be wary of is that extras
are mutable, unlike node attributes. Once set, they can be changed and even deleted. So you cannot be sure that once they are set on the Code
they stay the same. But if you control the Code
that shouldn’t be a problem in this case.
Okay, great thanks! I think this will work then yes.
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.