In this topic, I would like to collect some thoughts on how to improve the transport plugins. While working on the ssh_light
transport plugin, I realised that a few things could be improved. I will add them as follow-up comments to keep this message short.
chdir
and getcwd
methods
I would argue, that those methods are not needed at all. AFAIK, the place where you get landed is specific to the implementation, why depend on that?
I would even go further, and require providing only absolute paths to the methods of the Transport
plugin.
Use pathlib
I think the implementation of the transport classes can be further streamlined if we force all path-like arguments to be of pathlib.Path
type.
It’s important to note that pathlib.Path
is dependent on the local system (see pathlib — Object-oriented filesystem paths — Python 3.11.4 documentation), and so this should not be used to reference remote paths. This is important if you need to distinguish between Posix and Windows.
There is a specific base class for paths: os — Miscellaneous operating system interfaces — Python 3.11.4 documentation
You may also be interested in two implementations of the Path API I have implemented:
- GitHub - aiidateam/archive-path: A package to provide pathlib like access to zip & tar archives, used in aiida-core for the archive storage
- https://github.com/aiidateam/aiida-firecrest/blob/main/aiida_firecrest/remote_path.py