Dear all,
I’m trying to use portable codes in my project and I’m getting an error from paramiko while uploading the code file (test.py):
Expected Unicode or bytes, got PurePosixPath('test.py')
I temporarily solved the issue by modifying the aiida/transports/plugins/ssh.py file giving as argument to sftp.normalize, sftp.stat, sftp.chmod, sftp.put methods, str(path)
instead of path
alone.
Do you have an idea how I can solve it without modifying aiida-core scripts?
I’ll send you below the scripts I’m using for code definition, plugin and the full error.
Thank you.
Davide
Code definition:
from pathlib import Path
from aiida.orm import PortableCode
from aiida import load_profile
load_profile()
code = PortableCode(
label='test',
filepath_files=Path('/home/bidoggia/onedrive/aiida/tests/test_portable/'),
filepath_executable='test.py'
)
code. Store()
Part of plugin:
codeinfo = datastructures.CodeInfo()
codeinfo.code_uuid = self.inputs.code.uuid
calcinfo = datastructures.CalcInfo()
calcinfo.local_copy_list = []
calcinfo.codes_info = [codeinfo]
Full error:
| Traceback (most recent call last):
| File "/home/bidoggia/py_envs/aiida/lib/python3.10/site-packages/aiida/engine/utils.py", line 202, in exponential_backoff_retry
| result = await coro()
| File "/home/bidoggia/py_envs/aiida/lib/python3.10/site-packages/aiida/engine/processes/calcjobs/tasks.py", line 94, in do_upload
| execmanager.upload_calculation(node, transport, calc_info, folder)
| File "/home/bidoggia/py_envs/aiida/lib/python3.10/site-packages/aiida/engine/daemon/execmanager.py", line 193, in upload_calculation
| transport.put(handle.name, (root / filename))
| File "/home/bidoggia/py_envs/aiida/lib/python3.10/site-packages/aiida/transports/plugins/ssh.py", line 857, in put
| if self.isdir(remotepath):
| File "/home/bidoggia/py_envs/aiida/lib/python3.10/site-packages/aiida/transports/plugins/ssh.py", line 766, in isdir
| return S_ISDIR(self.stat(path).st_mode)
| File "/home/bidoggia/py_envs/aiida/lib/python3.10/site-packages/aiida/transports/plugins/ssh.py", line 633, in stat
| return self.sftp.stat(path)
| File "/home/bidoggia/py_envs/aiida/lib/python3.10/site-packages/paramiko/sftp_client.py", line 491, in stat
| path = self._adjust_cwd(path)
| File "/home/bidoggia/py_envs/aiida/lib/python3.10/site-packages/paramiko/sftp_client.py", line 914, in _adjust_cwd
| path = b(path)
| File "/home/bidoggia/py_envs/aiida/lib/python3.10/site-packages/paramiko/py3compat.py", line 156, in b
| raise TypeError("Expected unicode or bytes, got {!r}".format(s))
| TypeError: Expected unicode or bytes, got PurePosixPath('test.py')