Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #454

Merged
merged 4 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
# Python
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.1
rev: v0.4.2
hooks:
- id: ruff
args: ["--fix"]
Expand Down
8 changes: 3 additions & 5 deletions dpdispatcher/contexts/hdfs_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
shutil.rmtree(gz_dir, ignore_errors=True)
os.mkdir(os.path.join(self.local_root, "tmp"))
rfile_tgz = f"{self.remote_root}/{submission.submission_hash}_*_download.tar.gz"
lfile_tgz = "%s/tmp/" % (self.local_root)
lfile_tgz = f"{self.local_root}/tmp/"

Check warning on line 141 in dpdispatcher/contexts/hdfs_context.py

View check run for this annotation

Codecov / codecov/patch

dpdispatcher/contexts/hdfs_context.py#L141

Added line #L141 was not covered by tests
HDFS.copy_to_local(rfile_tgz, lfile_tgz)

tgz_file_list = glob(os.path.join(self.local_root, "tmp/*_download.tar.gz"))
Expand All @@ -164,7 +164,7 @@
os.path.join(
self.local_root,
task.task_work_path,
"tag_failure_download_%s" % jj,
f"tag_failure_download_{jj}",
),
"w",
) as fp:
Expand Down Expand Up @@ -198,9 +198,7 @@
if check_exists:
if mark_failure:
with open(
os.path.join(
self.local_root, "tag_failure_download_%s" % jj
),
os.path.join(self.local_root, f"tag_failure_download_{jj}"),
"w",
) as fp:
pass
Expand Down
8 changes: 4 additions & 4 deletions dpdispatcher/contexts/local_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def download(
tag_file_path = os.path.join(
self.local_root,
ii.task_work_path,
"tag_failure_download_%s" % kk,
f"tag_failure_download_{kk}",
)
with open(tag_file_path, "w") as fp:
pass
Expand Down Expand Up @@ -181,7 +181,7 @@ def download(
tag_file_path = os.path.join(
self.local_root,
ii.task_work_path,
"tag_failure_download_%s" % jj,
f"tag_failure_download_{jj}",
)
with open(tag_file_path, "w") as fp:
pass
Expand Down Expand Up @@ -227,7 +227,7 @@ def download(
if check_exists:
if mark_failure:
tag_file_path = os.path.join(
self.local_root, "tag_failure_download_%s" % kk
self.local_root, f"tag_failure_download_{kk}"
)
with open(tag_file_path, "w") as fp:
pass
Expand All @@ -252,7 +252,7 @@ def download(
if mark_failure:
with open(
os.path.join(
self.local_root, "tag_failure_download_%s" % jj
self.local_root, f"tag_failure_download_{jj}"
),
"w",
) as fp:
Expand Down
19 changes: 9 additions & 10 deletions dpdispatcher/contexts/ssh_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
# retry for up to 3 times
# ensure alive
self.ensure_alive()
raise RetrySignal("SSH session not active in calling %s" % cmd) from e
raise RetrySignal(f"SSH session not active in calling {cmd}") from e

Check warning on line 303 in dpdispatcher/contexts/ssh_context.py

View check run for this annotation

Codecov / codecov/patch

dpdispatcher/contexts/ssh_context.py#L303

Added line #L303 was not covered by tests

@property
def sftp(self):
Expand Down Expand Up @@ -628,8 +628,7 @@
# check sha256
# `:` means pass: https://stackoverflow.com/a/2421592/9567349
_, stdout, _ = self.block_checkcall(
"sha256sum -c %s --quiet >.sha256sum_stdout 2>/dev/null || :"
% shlex.quote(sha256_file)
f"sha256sum -c {shlex.quote(sha256_file)} --quiet >.sha256sum_stdout 2>/dev/null || :"
)
self.sftp.remove(sha256_file)
# regenerate file list
Expand Down Expand Up @@ -708,7 +707,7 @@
os.path.join(
self.local_root,
ii.task_work_path,
"tag_failure_download_%s" % jj,
f"tag_failure_download_{jj}",
),
"w",
) as fp:
Expand Down Expand Up @@ -758,9 +757,9 @@
assert self.remote_root is not None
self.ssh_session.ensure_alive()
if asynchronously:
cmd = "nohup %s >/dev/null &" % cmd
cmd = f"nohup {cmd} >/dev/null &"

Check warning on line 760 in dpdispatcher/contexts/ssh_context.py

View check run for this annotation

Codecov / codecov/patch

dpdispatcher/contexts/ssh_context.py#L760

Added line #L760 was not covered by tests
stdin, stdout, stderr = self.ssh_session.exec_command(
("cd %s ;" % shlex.quote(self.remote_root)) + cmd
(f"cd {shlex.quote(self.remote_root)} ;") + cmd
)
exit_status = stdout.channel.recv_exit_status()
if exit_status != 0:
Expand All @@ -779,7 +778,7 @@
assert self.remote_root is not None
self.ssh_session.ensure_alive()
stdin, stdout, stderr = self.ssh_session.exec_command(
("cd %s ;" % shlex.quote(self.remote_root)) + cmd
(f"cd {shlex.quote(self.remote_root)} ;") + cmd
)
exit_status = stdout.channel.recv_exit_status()
return exit_status, stdin, stdout, stderr
Expand Down Expand Up @@ -846,12 +845,12 @@
# Thus, it's better to use system's `rm` to remove a directory, which may
# save a lot of time.
if verbose:
dlog.info("removing %s" % remotepath)
dlog.info(f"removing {remotepath}")

Check warning on line 848 in dpdispatcher/contexts/ssh_context.py

View check run for this annotation

Codecov / codecov/patch

dpdispatcher/contexts/ssh_context.py#L848

Added line #L848 was not covered by tests
# In some supercomputers, it's very slow to remove large numbers of files
# (e.g. directory containing trajectory) due to bad I/O performance.
# So an asynchronously option is provided.
self.block_checkcall(
"rm -rf %s" % shlex.quote(remotepath),
f"rm -rf {shlex.quote(remotepath)}",
asynchronously=self.clean_asynchronously,
)

Expand Down Expand Up @@ -921,7 +920,7 @@
f"from {from_f} to {self.ssh_session.username} @ {self.ssh_session.hostname} : {to_f} Error!"
)
# remote extract
self.block_checkcall("tar xf %s" % of)
self.block_checkcall(f"tar xf {of}")

Check warning on line 923 in dpdispatcher/contexts/ssh_context.py

View check run for this annotation

Codecov / codecov/patch

dpdispatcher/contexts/ssh_context.py#L923

Added line #L923 was not covered by tests
# clean up
os.remove(from_f)
self.sftp.remove(to_f)
Expand Down
4 changes: 2 additions & 2 deletions dpdispatcher/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@

source_list = job.resources.source_list
for ii in source_list:
line = "{ source %s; } \n" % ii
line = f"{{ source {ii}; }} \n"
source_files_part += line

export_envs_part = ""
Expand Down Expand Up @@ -466,7 +466,7 @@
job : Job
job
"""
dlog.warning("Job %s should be manually killed" % job.job_id)
dlog.warning(f"Job {job.job_id} should be manually killed")

Check warning on line 469 in dpdispatcher/machine.py

View check run for this annotation

Codecov / codecov/patch

dpdispatcher/machine.py#L469

Added line #L469 was not covered by tests

def get_exit_code(self, job):
"""Get exit code of the job.
Expand Down
4 changes: 2 additions & 2 deletions dpdispatcher/machines/distributed_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

source_list = job.resources.source_list
for ii in source_list:
line = "{ source %s; } \n" % ii
line = f"{{ source {ii}; }} \n"

Check warning on line 67 in dpdispatcher/machines/distributed_shell.py

View check run for this annotation

Codecov / codecov/patch

dpdispatcher/machines/distributed_shell.py#L67

Added line #L67 was not covered by tests
source_files_part += line

export_envs_part = ""
Expand Down Expand Up @@ -96,7 +96,7 @@
def gen_script_end(self, job):
all_task_dirs = ""
for task in job.job_task_list:
all_task_dirs += "%s " % task.task_work_path
all_task_dirs += f"{task.task_work_path} "

Check warning on line 99 in dpdispatcher/machines/distributed_shell.py

View check run for this annotation

Codecov / codecov/patch

dpdispatcher/machines/distributed_shell.py#L99

Added line #L99 was not covered by tests
job_tag_finished = job.job_hash + "_job_tag_finished"
flag_if_job_task_fail = job.job_hash + "_flag_if_job_task_fail"

Expand Down
2 changes: 1 addition & 1 deletion dpdispatcher/machines/lsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
return JobStatus.unsubmitted
ret, stdin, stdout, stderr = self.context.block_call("bjobs " + job_id)
err_str = stderr.read().decode("utf-8")
if ("Job <%s> is not found" % job_id) in err_str:
if (f"Job <{job_id}> is not found") in err_str:

Check warning on line 124 in dpdispatcher/machines/lsf.py

View check run for this annotation

Codecov / codecov/patch

dpdispatcher/machines/lsf.py#L124

Added line #L124 was not covered by tests
if self.check_finish_tag(job):
return JobStatus.finished
else:
Expand Down
2 changes: 1 addition & 1 deletion dpdispatcher/machines/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
).as_posix()
if not self.context.check_file_exists(task_tag_finished):
job_array.add(ii // slurm_job_size)
return super().gen_script_header(job) + "\n#SBATCH --array=%s" % (
return super().gen_script_header(job) + "\n#SBATCH --array={}".format(

Check warning on line 257 in dpdispatcher/machines/slurm.py

View check run for this annotation

Codecov / codecov/patch

dpdispatcher/machines/slurm.py#L257

Added line #L257 was not covered by tests
",".join(map(str, job_array))
)
return super().gen_script_header(job) + "\n#SBATCH --array=0-%d" % (
Expand Down
Loading