aiida-core icon indicating copy to clipboard operation
aiida-core copied to clipboard

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

Open sphuber opened this issue 1 year ago • 2 comments

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.

sphuber avatar Aug 30 '23 19:08 sphuber

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

danielhollas avatar Sep 07 '23 14:09 danielhollas

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.

sphuber avatar Sep 07 '23 15:09 sphuber