Skip to content

Commit

Permalink
launch_shell_job: Move computer to top-level of metadata
Browse files Browse the repository at this point in the history
The `metadata` passed to the `launch_shell_job` is just supposed to
expose the same input of the `ShellJob` and essentially forward it.
However, the `computer` input was expected to be passed nested inside
the `options` namespace, even though it is defined as a top-level
metadata input. This makes the inputs for `launch_shell_job` dfifferent
from the `ShellJob` causing unnecessary confusion. The `computer` input
should now be specified as a top-level metadata input for the
`launch_shell_job` wrapper as well.
  • Loading branch information
sphuber committed Jul 22, 2024
1 parent 8a561b6 commit 0fbfb68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/source/howto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,15 @@ Defining a specific computer
By default the shell command ran by ``launch_shell_job`` will be executed on the localhost, i.e., the computer where AiiDA is running.
However, AiiDA also supports running commands on remote computers.
See the `AiiDA's documentation <https://aiida.readthedocs.io/projects/aiida-core/en/latest/howto/run_codes.html#how-to-set-up-a-computer>`__ for instructions to setting up and configuring a remote computer.
To specify what computer to use for a shell command, pass it as an option to the ``metadata`` keyword:
To specify what computer to use for a shell command, pass it as a key to the ``metadata`` argument:

.. code-block:: python
from aiida.orm import load_computer
from aiida_shell import launch_shell_job
results, node = launch_shell_job(
'date',
metadata={'options': {'computer': load_computer('some-computer')}}
metadata={'computer': load_computer('some-computer')}
)
print(results['stdout'].get_content())
Expand Down
2 changes: 1 addition & 1 deletion src/aiida_shell/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def launch_shell_job( # noqa: PLR0913
generated for each ``CalcJob`` and typically are not of interest to a user running ``launch_shell_job``. In
order to not confuse them, these nodes are omitted, but they can always be accessed through the node.
"""
computer = (metadata or {}).get('options', {}).pop('computer', None)
computer = (metadata or {}).pop('computer', None)

if isinstance(command, str):
code = prepare_code(command, computer, resolve_command)
Expand Down

0 comments on commit 0fbfb68

Please sign in to comment.