From 7b9df18e033ebb22c6ddb47d84e45db6a97f1638 Mon Sep 17 00:00:00 2001 From: Brewster Malevich Date: Thu, 5 Dec 2024 13:34:36 -0800 Subject: [PATCH 1/5] Minor style update to use f-strings over % This was updated to satisfy ruff recommending code style refresh. --- src/impactlab_tools/utils/paralog.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/impactlab_tools/utils/paralog.py b/src/impactlab_tools/utils/paralog.py index 8b6bc7c..e871340 100644 --- a/src/impactlab_tools/utils/paralog.py +++ b/src/impactlab_tools/utils/paralog.py @@ -64,7 +64,7 @@ def __init__(self, jobname, jobtitle, logdir, timeout, exclusive_jobnames=None): if not os.path.exists(logdir): os.makedirs(logdir) for ii in itertools.count(): - logpath = os.path.join(logdir, "%s-%d.log" % (jobname, ii)) + logpath = os.path.join(logdir, f"{jobname}-{ii:d}.log") if not os.path.exists(logpath): self.logpath = logpath break @@ -73,12 +73,7 @@ def __init__(self, jobname, jobtitle, logdir, timeout, exclusive_jobnames=None): # Record this process in the master log with open(os.path.join(logdir, "master.log"), 'a') as fp: fp.write( - "%s %s: %d %s\n" % ( - time.asctime(), - self.jobtitle, - os.getpid(), - self.logpath - ) + f"{time.asctime()} {self.jobtitle}: {os.getpid():d} {self.logpath}\n" ) except Exception: print("CAUGHT A WILD EXCEPTION BUT IGNORING IT WITHOUT LOGGING IT!") @@ -106,7 +101,7 @@ def claim(self, dirpath): status_path = StatusManager.claiming_filepath(dirpath, self.jobname) try: with open(status_path, 'w') as fp: - fp.write("%d %s: %s\n" % (os.getpid(), self.jobtitle, self.logpath)) + fp.write(f"{os.getpid():d} {self.jobtitle}: {self.logpath}\n") except Exception: print("CAUGHT A WILD EXCEPTION BUT IGNORING IT WITHOUT LOGGING IT!") return False # Writing error: cannot calim directory From bb7c03c9011cf352247a9e9dbb6d4ace9def8f59 Mon Sep 17 00:00:00 2001 From: Brewster Malevich Date: Thu, 5 Dec 2024 13:35:26 -0800 Subject: [PATCH 2/5] Bump ruff version in CI to 0.8.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8579eff..8fe9239 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,4 +10,4 @@ sphinx-rtd-theme==3.0.2 pytest==8.3.3 pytest-cov==6.0.0 pyyaml==6.0.2 -ruff==0.6.8 +ruff==0.8.1 From 0d71eae75e6db0a936475b1f7c013f4df7e0e738 Mon Sep 17 00:00:00 2001 From: Brewster Malevich Date: Thu, 5 Dec 2024 13:42:29 -0800 Subject: [PATCH 3/5] Minor style fix for line-length --- src/impactlab_tools/utils/paralog.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/impactlab_tools/utils/paralog.py b/src/impactlab_tools/utils/paralog.py index e871340..c7e8b85 100644 --- a/src/impactlab_tools/utils/paralog.py +++ b/src/impactlab_tools/utils/paralog.py @@ -101,7 +101,9 @@ def claim(self, dirpath): status_path = StatusManager.claiming_filepath(dirpath, self.jobname) try: with open(status_path, 'w') as fp: - fp.write(f"{os.getpid():d} {self.jobtitle}: {self.logpath}\n") + fp.write( + f"{os.getpid():d} {self.jobtitle}: {self.logpath}\n" + ) except Exception: print("CAUGHT A WILD EXCEPTION BUT IGNORING IT WITHOUT LOGGING IT!") return False # Writing error: cannot calim directory From 0458de6cd47aa7b976710d8844dda9490edec61b Mon Sep 17 00:00:00 2001 From: Brewster Malevich Date: Thu, 5 Dec 2024 13:52:57 -0800 Subject: [PATCH 4/5] Minor style fix for line-length --- src/impactlab_tools/utils/paralog.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/impactlab_tools/utils/paralog.py b/src/impactlab_tools/utils/paralog.py index c7e8b85..edd687f 100644 --- a/src/impactlab_tools/utils/paralog.py +++ b/src/impactlab_tools/utils/paralog.py @@ -73,7 +73,8 @@ def __init__(self, jobname, jobtitle, logdir, timeout, exclusive_jobnames=None): # Record this process in the master log with open(os.path.join(logdir, "master.log"), 'a') as fp: fp.write( - f"{time.asctime()} {self.jobtitle}: {os.getpid():d} {self.logpath}\n" + f"{time.asctime()} {self.jobtitle}:" + f"{os.getpid():d} {self.logpath}\n" ) except Exception: print("CAUGHT A WILD EXCEPTION BUT IGNORING IT WITHOUT LOGGING IT!") From 8f6d796aef5ad202bd456abdebb058b5659a33ce Mon Sep 17 00:00:00 2001 From: Brewster Malevich Date: Thu, 5 Dec 2024 13:56:25 -0800 Subject: [PATCH 5/5] Update whatsnew --- whatsnew.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/whatsnew.rst b/whatsnew.rst index b88e879..528c217 100644 --- a/whatsnew.rst +++ b/whatsnew.rst @@ -6,6 +6,7 @@ These are new features and improvements of note in each release. Unreleased ---------- + - Minor code style update. v0.6.0 (May 31, 2024) ---------------------