diff --git a/src/aiida_shell/calculations/shell.py b/src/aiida_shell/calculations/shell.py index 4b88327..e479f34 100644 --- a/src/aiida_shell/calculations/shell.py +++ b/src/aiida_shell/calculations/shell.py @@ -90,6 +90,18 @@ def validate_outputs(cls, value: List, _) -> str | None: return None + def _build_process_label(self) -> str: + """Construct the process label that should be set on ``ProcessNode`` instances for this process class. + + Override the base implementation to include the full label of the ``Code`` which provides more useful info to + the user, for example when looking at an overview of submitted processes. + + :returns: The process label to use for ``ProcessNode`` instances. + """ + if self.inputs: + return f'ShellJob<{self.inputs.code.full_label}>' + return super()._build_process_label() + def prepare_for_submission(self, folder: Folder) -> CalcInfo: """Prepare the calculation for submission. diff --git a/tests/calculations/test_shell.py b/tests/calculations/test_shell.py index e4dd04a..5df634a 100644 --- a/tests/calculations/test_shell.py +++ b/tests/calculations/test_shell.py @@ -177,6 +177,15 @@ def value_raises(self): generate_calc_job('core.shell', {'code': generate_code(), 'nodes': nodes}) +def test_build_process_label(generate_calc_job, generate_code): + """Test the :meth:`~aiida_shell.calculations.shell_job.ShellJob.build_process_label` method.""" + computer = 'localhost' + executable = '/bin/echo' + code = generate_code(executable, computer_label=computer, label='echo') + process = generate_calc_job('core.shell', {'code': code}, return_process=True) + assert process._build_process_label() == f'ShellJob<{code.full_label}>' # pylint: disable=protected-access + + def test_submit_to_daemon(generate_code, submit_and_await): """Test submitting a ``ShellJob`` to the daemon.""" builder = generate_code('echo').get_builder() diff --git a/tests/conftest.py b/tests/conftest.py index fb43fca..7edc02c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -50,7 +50,7 @@ def generate_calc_job(tmp_path): as well as the ``CalcInfo`` instance that it returned. """ - def factory(entry_point_name, inputs=None): + def factory(entry_point_name, inputs=None, return_process=False): """Create a :class:`aiida.engine.CalcJob` instance with the given inputs.""" manager = get_manager() runner = manager.get_runner() @@ -59,6 +59,10 @@ def factory(entry_point_name, inputs=None): process = instantiate_process(runner, process_class, **inputs or {}) calc_info = process.prepare_for_submission(Folder(tmp_path)) + + if return_process: + return process + return tmp_path, calc_info return factory