The term transport in AiiDA refers to a class that the engine uses to perform operations on local or remote machines where its
CalcJob are submitted.
The base class
Transport defines an interface for these operations, such as copying files and executing commands.
A transport plugin is a class that implements this base class for a specific connection method.
aiida-core package ships with two transport plugins: the
local transport can be used to connect with the localhost and makes use only of some standard python modules like
ssh transport, which can be used for machines that can be connected to over ssh, is simply a wrapper around the library paramiko that is installed as a required dependency of
Developing a plugin¶
The transport class is actually almost never used directly by the user. It is mostly utilized by the engine that uses the transport plugin to connect to the machine where the calculation job, that it is managing, is running. The engine has to be able to use always the same methods regardless of which kind of transport is required to connect to the computer in question.
The generic transport class contains a set of minimal methods that an implementation must support in order to be fully compatible with the other plugins.
If not, a
NotImplementedError will be raised, interrupting the managing of the calculation or whatever is using the transport plugin.
As for the general functioning of the plugin, the
__init__() method is used only to initialize the class instance, without actually opening the transport channel.
The connection must be opened only by the
__enter__() method, (and closed by
__enter__() method lets you use the transport class using the
with statement (see python docs), in a way similar to the following:
with TransportPlugin() as transport: transport.some_method()
To ensure this, for example, the local plugin uses a hidden boolean variable
_is_open that is set when the
__exit__() methods are called.
ssh logic is instead given by the property sftp.
The other functions that require some care are the copying functions, called using the following terminology:
put: from local source to remote destination
get: from remote source to local destination
copy: copying files from remote source to remote destination
Note that these functions must accept both files and folders and internally they will fallback to functions like
The last function requiring care is
exec_command_wait(), which is an analogue to the subprocess python module.
The function gives the freedom to execute a string as a remote command, thus it could produce nasty effects if not written with care.
Be sure to escape any strings for bash!
this template as a starting point to implementing a new transport plugin.
It contains the interface with all the methods that need to be implemented, including docstrings that will work with Sphinx documentation.