# How to store which features a code was compiled with?

**URL:** <https://aiida.discourse.group/t/how-to-store-which-features-a-code-was-compiled-with/197>\
**Category:** General Usage\
**Created:** [December 8, 2023, 1:24pm UTC](https://aiida.discourse.group/t/how-to-store-which-features-a-code-was-compiled-with/197 "2023-12-08T13:24:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahkole](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/ahkole/32/256_2.png) [@ahkole](https://aiida.discourse.group/u/ahkole)\
**Post date:** [December 8, 2023, 1:24pm UTC](https://aiida.discourse.group/t/how-to-store-which-features-a-code-was-compiled-with/197/1 "2023-12-08T13:24:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sphuber](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/sphuber/32/6_2.png) [@sphuber](https://aiida.discourse.group/u/sphuber)\
**Post date:** [December 8, 2023, 1:28pm UTC](https://aiida.discourse.group/t/how-to-store-which-features-a-code-was-compiled-with/197/2 "2023-12-08T13:28:50Z")

</div>

There is currently no standardized way in AiiDA for this. However, you could consider using `extras` for this. For example:

```auto
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:

```python
if self.inputs.code.base.extras.get('supports_netcdf', None):
   # Do something that requires netCDF

```

---

<div class="post-metadata">

**Author:** ![ahkole](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/ahkole/32/256_2.png) [@ahkole](https://aiida.discourse.group/u/ahkole)\
**Post date:** [December 8, 2023, 1:35pm UTC](https://aiida.discourse.group/t/how-to-store-which-features-a-code-was-compiled-with/197/3 "2023-12-08T13:35:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sphuber](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/sphuber/32/6_2.png) [@sphuber](https://aiida.discourse.group/u/sphuber)\
**Post date:** [December 8, 2023, 4:03pm UTC](https://aiida.discourse.group/t/how-to-store-which-features-a-code-was-compiled-with/197/4 "2023-12-08T16:03:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ahkole](https://yyz2.discourse-cdn.com/free1/user_avatar/aiida.discourse.group/ahkole/32/256_2.png) [@ahkole](https://aiida.discourse.group/u/ahkole)\
**Post date:** [December 8, 2023, 7:01pm UTC](https://aiida.discourse.group/t/how-to-store-which-features-a-code-was-compiled-with/197/5 "2023-12-08T19:01:35Z")

</div>

Okay, great thanks! I think this will work then yes.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/aiida/original/1X/c417197d3750949351575d03ed03f5e2ad32e649.png) [@system](https://aiida.discourse.group/u/system)\
**Post date:** [December 14, 2023, 3:01pm UTC](https://aiida.discourse.group/t/how-to-store-which-features-a-code-was-compiled-with/197/6 "2023-12-14T15:01:54Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
