forked from aiidateam/aiida-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
33 lines (23 loc) · 1.32 KB
/
Copy pathcode.py
File metadata and controls
33 lines (23 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Code that represents a shell command."""
from __future__ import annotations
import typing as t
from aiida.orm import InstalledCode
__all__ = ('ShellCode',)
class ShellCode(InstalledCode):
"""Code that represents a shell command.
This code type is automatically generated by the :func:`~aiida_shell.engine.launch.launch_shell_job` function and is
a subclass of :class:`~aiida.orm.nodes.data.code.installed.InstalledCode`. It can therefore be used for any other
calculation job as well.
"""
def __init__(self, *args: t.Any, default_calc_job_plugin: str = 'core.shell', **kwargs: t.Any) -> None:
"""Construct a new instance."""
self.validate_default_calc_job_plugin(default_calc_job_plugin)
super().__init__(*args, default_calc_job_plugin=default_calc_job_plugin, **kwargs)
@staticmethod
def validate_default_calc_job_plugin(default_calc_job_plugin: str) -> None:
"""Validate the default calculation job plugin.
The ``ShellCode`` should only be used with the ``core.shell`` calculation job entry point.
:raises ValueError: If ``default_calc_job_plugin`` is not ``core.shell``.
"""
if default_calc_job_plugin != 'core.shell':
raise ValueError(f'`default_calc_job_plugin` has to be `core.shell`, but got: {default_calc_job_plugin}')