Skip to content

Commit

Permalink
review applied
Browse files Browse the repository at this point in the history
  • Loading branch information
khsrali committed Nov 5, 2024
1 parent ae5b7d1 commit 21c2be3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/aiida/engine/daemon/execmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def upload_calculation(
# Since the content of the node could potentially be binary, we read the raw bytes and pass them on
for filename in filenames:
with NamedTemporaryFile(mode='wb+') as handle:
content = code.base.repository.get_object_content((Path(root) / filename), mode='rb')
content = code.base.repository.get_object_content(Path(root) / filename, mode='rb')
handle.write(content)
handle.flush()
transport.put(handle.name, str(workdir.joinpath(root, filename)))
Expand Down
17 changes: 9 additions & 8 deletions src/aiida/transports/plugins/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,17 +1226,18 @@ def listdir(self, path='.', pattern=None):
:param pattern: returns the list of files matching pattern.
Unix only. (Use to emulate ``ls *`` for example)
"""
if not pattern:
return self.sftp.listdir(path)
if path.startswith('/'):
base_dir = path
abs_dir = path
else:
base_dir = os.path.join(self.getcwd(), path)
abs_dir = os.path.join(self.getcwd(), path)

filtered_list = self.glob(os.path.join(base_dir, pattern))
if not base_dir.endswith('/'):
base_dir += '/'
return [re.sub(base_dir, '', i) for i in filtered_list]
if not pattern:
return self.sftp.listdir(abs_dir)

filtered_list = self.glob(os.path.join(abs_dir, pattern))
if not abs_dir.endswith('/'):
abs_dir += '/'
return [re.sub(abs_dir, '', i) for i in filtered_list]

def remove(self, path):
"""Remove a single file at 'path'"""
Expand Down
2 changes: 1 addition & 1 deletion src/aiida/transports/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def exec_command_wait_bytes(self, command, stdin=None, workdir=None, **kwargs):
"""Execute the command on the shell, waits for it to finish,
and return the retcode, the stdout and the stderr as bytes.
Enforce the execution to be run from the pwd (as given by self.getcwd), if this is not None.
Enforce the execution to be run from workdir, if this is not None.
The command implementation can have some additional plugin-specific kwargs.
Expand Down
31 changes: 0 additions & 31 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,6 @@ def _generate_calcjob_node(
process_state: ProcessState = ProcessState.FINISHED,
exit_status: int | None = None,
entry_point: str | None = None,
inputs: dict | None = None,
outputs: dict | None = None,
repository: pathlib.Path | None = None,
workdir: pathlib.Path | None = None,
):
"""Generate an instance of a `CalcJobNode`..
Expand All @@ -228,36 +225,8 @@ def _generate_calcjob_node(
exit_status = 0

calcjob_node = CalcJobNode(process_type=entry_point)
calcjob_node.set_process_state(process_state)

if exit_status is not None:
calcjob_node.set_exit_status(exit_status)

if repository is not None:
calcjob_node.base.repository.put_object_from_tree(repository)

calcjob_node.set_remote_workdir(workdir)

# For storing, need to first store the input nodes, then the CalcJobNode, then the output nodes
if inputs is not None:
for input_label, input_node in inputs.items():
calcjob_node.base.links.add_incoming(
input_node,
link_type=LinkType.INPUT_CALC,
link_label=input_label,
)

input_node.store()

if outputs is not None:
# Need to first store CalcJobNode before I can attach `created` outputs
calcjob_node.store()
for output_label, output_node in outputs.items():
output_node.base.links.add_incoming(calcjob_node, link_type=LinkType.CREATE, link_label=output_label)

output_node.store()

# Return unstored by default
return calcjob_node

return _generate_calcjob_node
Expand Down

0 comments on commit 21c2be3

Please sign in to comment.