Skip to content

Commit

Permalink
Add cleanup method to SlurmJob class
Browse files Browse the repository at this point in the history
  • Loading branch information
TorecLuik committed Apr 4, 2024
1 parent 8780a0b commit c33dd79
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions biomero/slurm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ def wait_for_completion(self, slurmClient, omeroConn) -> str:
logger.info(
f"You can get the logfile using `Slurm Get Update` on job {self.job_id}")
return self.job_state

def cleanup(self, slurmClient) -> Result:
"""
Cleanup remaining log files.
Args:
slurmClient: The Slurm client.
Returns:
Result: The result of the cleanup operation.
"""
return slurmClient.cleanup_tmp_files(self.job_id)

def completed(self):
"""
Expand Down Expand Up @@ -609,7 +621,7 @@ def from_config(cls, configfile: str = '',

def cleanup_tmp_files(self,
slurm_job_id: str,
filename: str,
filename: str = None,
data_location: str = None,
logfile: str = None,
) -> Result:
Expand Down Expand Up @@ -637,8 +649,9 @@ def cleanup_tmp_files(self,
"""
cmds = []
# zip
rmzip = f"rm {filename}.*"
cmds.append(rmzip)
if filename:
rmzip = f"rm {filename}.*"
cmds.append(rmzip)
# log
if logfile is None:
logfile = self._LOGFILE
Expand Down

0 comments on commit c33dd79

Please sign in to comment.