aiidateam / aiida-core

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

Deprecate the `aiida.orm.utils.builders.computer` module #6103

Open sphuber opened 1 year ago

sphuber commented 1 year ago

Its functionality is not clear. It is just used in the verdi computer setup command and is essentially used for some validation, but this is already done in the aiida.orm.Computer class, so it feels like this is a very verbose layer that doesn't add much.

danielhollas commented 1 year ago

Note that we're currently using the ComputerBuilder from this module in AiiDAlab.

https://github.com/aiidalab/aiidalab-widgets-base/blob/96d589d41a4edf7bc8e84f6048a06345b9d54455/aiidalab_widgets_base/computational_resources.py#L939

cc @unkcpz @yakutovicha

sphuber commented 1 year ago

Note that the entire functionality you are using can be easily recreated using base resources:

from aiida.common.exceptions import ValidationError
from aiida.orm import Computer

computer = Computer(
    label='label',
    description='description',
    hostname='hostname',
    transport_type='transport',
    scheduler_type='scheduler',
    workdir='workdir',
)

properties = {
    'shebang': 'value',
    'mpirun_command': 'value',
    'default_memory_per_machine': 'value',
    'default_mpiprocs_per_machine': 'value',
    'use_double_quotes': 'value',
    'prepend_text': 'value',
    'append_text': 'value',
}

for key, value in properties.items():
    computer.set_property(key, value)

try:
    computer.store()
except ValidationError:
    # Handle it

I would argue that the amount of code that is in the ComputerBuilder does not justify its maintenance cost given there is straightforward implementation available.

I agree that the set_property interface being separate is not ideal, but that is historical.