sphuber / aiida-shell

AiiDA plugin that makes running shell commands easy.
MIT License
14 stars 7 forks source link

`prepare_computer`: Check whether `default_mpiprocs_per_machine` is set #79

Closed sphuber closed 8 months ago

sphuber commented 8 months ago

Fixes #78

If the localhost is created before prepare_computer is ever called, it is possible that the property default_mpiprocs_per_machine is not set. This would result in the ShellJob validation failing if the scheduler type has a job resource class that is a subclass of aiida.schedulers.datastructures.NodeNumberJobResource.

The prepare_computer function now checks that if the localhost computer already exists that the default_mpiprocs_per_machine property is defined if the scheduler has the relevant job resource class. If that is the case, the default is set to 1.

sphuber commented 8 months ago

@giovannipizzi I think this should have helped with the resource validation issue you encountered

giovannipizzi commented 8 months ago

Thanks - I was more thinking to enforce this at the execution level of the specific ShellJob, more than changing the default - the user might want to run on the same computer, even with localhost, with more MPI processes in the future? is it doable?

sphuber commented 8 months ago

the user might want to run on the same computer, even with localhost, with more MPI processes in the future?

It is just the default though, nothing is preventing them from specifying more. If that is what they wanted to do, they would anyway have to explicitly specify it, and so nothing would change in that scenario, whether the computer defines a default or not.

is it doable?

I guess so. Instead of having the check in prepare_computer, I could do a check in launch_shell_job to check that if the computer doesn't define a default, then the metadata.options.resources contains the num_mpiprocs_per_machine key. But the current solution has the benefit that the "problem" is fixed even when directly launching the ShellJob and not use the launch_shell_job wrapper. If we put the solution in the wrapper, then the user would still have to manually specify the resources.