Skip to content

Commit

Permalink
refactor: Collect job inputs only once per execute
Browse files Browse the repository at this point in the history
  • Loading branch information
giffels committed Mar 1, 2024
1 parent 97c63c9 commit 16159ad
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions reana_job_controller/compute4punch_job_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ def execute(self) -> str:
"""
self._create_c4p_workspace_environment()
self._create_c4p_job_execution_script()
self._create_c4p_job_description()
self._upload_job_inputs()
job_inputs = self._get_job_inputs()
self._create_c4p_job_description(job_inputs=job_inputs)
self._upload_job_inputs(job_inputs=job_inputs)

submit_cmd_list = [
f"cd {self.c4p_abs_workspace_path}",
Expand Down Expand Up @@ -230,9 +231,9 @@ def c4p_rel_workspace_path(self) -> str:
"""Determine and return the relative Compute4PUNCH workspace path."""
return os.path.join(C4P_REANA_REL_WORKFLOW_PATH, self.workflow_uuid)

def _create_c4p_job_description(self) -> None:
def _create_c4p_job_description(self, job_inputs: Iterable) -> None:
"""Create job description for Compute4PUNCH."""
job_inputs = ",".join(self._get_inputs())
job_inputs = ",".join(job_inputs)
job_outputs = "." # download everything from remote job
job_description_template = [
f"executable = {os.path.basename(self.job_execution_script_path)}",
Expand Down Expand Up @@ -338,13 +339,13 @@ def _get_inputs(self) -> Iterable:
),
)

def _upload_job_inputs(self) -> None:
def _upload_job_inputs(self, job_inputs: Iterable) -> None:
"""Upload job inputs to Compute4PUNCH."""
sftp_client = self.c4p_connection.ssh_client.open_sftp()
sftp_client.chdir(self.c4p_rel_workspace_path)

try:
for job_input in self._get_inputs():
for job_input in job_inputs:
if is_directory(self.workflow_workspace, job_input):
try: # check if directory already exists
sftp_client.stat(job_input)
Expand Down

0 comments on commit 16159ad

Please sign in to comment.