-
Notifications
You must be signed in to change notification settings - Fork 59
Refactor log messages for clarity and consistency #561
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
base: master
Are you sure you want to change the base?
Changes from all commits
11fe336
8140a43
b893544
82b7262
01ffd14
56e3afe
703aa49
2c3b38a
f73e0f9
957cf4a
034c9d7
3f07742
499c691
76150bf
ef28a1b
65dca91
ffe52e1
8d7b566
8c50c4f
89d2a41
2093336
920984d
c8f5657
ef6ebeb
f56fa50
e06c648
6d6c973
dae7909
4ca179c
83644c3
b1758d9
62a3459
774b130
2ae2e62
ad6b971
d02adf6
3aca952
9fc0f84
95b8aa5
cc7efcd
99589d3
711da1d
1e0c21e
10cf5d3
416a767
e530cf6
5adce1b
4084a31
9b1c566
fc690ae
cfbc5dd
81f52a3
7bbc485
37da47c
bca9728
02f1449
c13be3b
a9fbadf
fba9574
0d2cd71
5f42bc8
bfe1615
1ded55e
4033a20
59b6139
1f514de
be99e41
415c114
ac9c1e4
d28233d
1f29674
ba5147d
7ee3919
2fb5e81
033443c
f977a7a
1787bcc
2e8b001
c56ef45
6bd72ad
57a5991
69b4a0b
e80b712
2f22fe5
4bf6a76
170b1ef
9db2abc
4ad8a82
96176dc
284f1f8
8b04937
909e595
1ee843f
6b244da
4bb42d8
e897d8a
ae8a0a3
0d6bf3d
1d0d467
08e24a6
ac7116d
558e911
c8b0198
2960443
6682e06
26a3732
77ce083
ecc93b2
bfe4356
e9d5781
2336f62
a55256d
b74bf7a
eb1a730
c49374e
41b7b37
976f2af
1e9bdd9
37716c3
4251ca4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,7 +178,7 @@ def _setup_ssh(self): | |
| key = pkey_class.from_private_key_file( | ||
| key_path, self.passphrase | ||
| ) | ||
| except paramiko.SSHException as e: | ||
| except paramiko.SSHException: | ||
| pass | ||
| if key is not None: | ||
| break | ||
|
|
@@ -200,7 +200,7 @@ def _setup_ssh(self): | |
| for pkey_class, filename in keyfiles: | ||
| try: | ||
| key = pkey_class.from_private_key_file(filename, self.passphrase) | ||
| except paramiko.SSHException as e: | ||
| except paramiko.SSHException: | ||
|
||
| pass | ||
| if key is not None: | ||
| break | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -167,16 +167,14 @@ def serialize(self, if_static=False): | |||||||||
| def register_task(self, task): | ||||||||||
| if self.belonging_jobs: | ||||||||||
| raise RuntimeError( | ||||||||||
| "Not allowed to register tasks after generating jobs. " | ||||||||||
| f"submission hash error {self}" | ||||||||||
| f"Not allowed to register tasks after generating jobs. submission hash error {self}" | ||||||||||
| ) | ||||||||||
| self.belonging_tasks.append(task) | ||||||||||
|
|
||||||||||
| def register_task_list(self, task_list): | ||||||||||
| if self.belonging_jobs: | ||||||||||
| raise RuntimeError( | ||||||||||
| "Not allowed to register tasks after generating jobs. " | ||||||||||
| f"submission hash error {self}" | ||||||||||
| f"Not allowed to register tasks after generating jobs. submission hash error {self}" | ||||||||||
| ) | ||||||||||
| self.belonging_tasks.extend(task_list) | ||||||||||
|
|
||||||||||
|
|
@@ -219,9 +217,9 @@ def run_submission( | |||||||||
| self.try_recover_from_json() | ||||||||||
| self.update_submission_state() | ||||||||||
| if self.check_all_finished(): | ||||||||||
| dlog.info("info:check_all_finished: True") | ||||||||||
| dlog.info("check_all_finished: True") | ||||||||||
| else: | ||||||||||
| dlog.info("info:check_all_finished: False") | ||||||||||
| dlog.info("check_all_finished: False") | ||||||||||
| self.upload_jobs() | ||||||||||
| if dry_run is True: | ||||||||||
| dlog.info(f"submission succeeded: {self.submission_hash}") | ||||||||||
|
|
@@ -342,7 +340,7 @@ def update_submission_state(self): | |||||||||
| continue | ||||||||||
| job.get_job_state() | ||||||||||
| dlog.debug( | ||||||||||
| f"debug:update_submission_state: job: {job.job_hash}, {job.job_id}, {job.job_state}" | ||||||||||
| f"update_submission_state: job: {job.job_hash}, {job.job_id}, {job.job_state}" | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| def handle_unexpected_submission_state(self): | ||||||||||
|
|
@@ -818,7 +816,7 @@ def get_job_state(self): | |||||||||
| this method will not submit or resubmit the jobs if the job is unsubmitted. | ||||||||||
| """ | ||||||||||
| dlog.debug( | ||||||||||
| f"debug:query database; self.job_hash:{self.job_hash}; self.job_id:{self.job_id}" | ||||||||||
| f"query database; self.job_hash:{self.job_hash}; self.job_id:{self.job_id}" | ||||||||||
| ) | ||||||||||
| assert self.machine is not None | ||||||||||
| job_state = self.machine.check_status(self) | ||||||||||
|
|
@@ -838,7 +836,7 @@ def handle_unexpected_job_state(self): | |||||||||
| if job_state == JobStatus.terminated: | ||||||||||
| self.fail_count += 1 | ||||||||||
| dlog.info( | ||||||||||
| f"job: {self.job_hash} {self.job_id} terminated; " | ||||||||||
| f"job {self.job_hash} {self.job_id} terminated; " | ||||||||||
| f"fail_cout is {self.fail_count}; resubmitting job" | ||||||||||
| ) | ||||||||||
| retry_count = 3 | ||||||||||
|
|
@@ -848,32 +846,32 @@ def handle_unexpected_job_state(self): | |||||||||
| if (self.fail_count) > 0 and (self.fail_count % retry_count == 0): | ||||||||||
| last_error_message = self.get_last_error_message() | ||||||||||
| err_msg = ( | ||||||||||
| f"job:{self.job_hash} {self.job_id} failed {self.fail_count} times." | ||||||||||
| f"job {self.job_hash} {self.job_id} failed {self.fail_count} times." | ||||||||||
| ) | ||||||||||
| if last_error_message is not None: | ||||||||||
| err_msg += f"\nPossible remote error message: {last_error_message}" | ||||||||||
| raise RuntimeError(err_msg) | ||||||||||
| self.submit_job() | ||||||||||
| if self.job_state != JobStatus.unsubmitted: | ||||||||||
| dlog.info( | ||||||||||
| f"job:{self.job_hash} re-submit after terminated; new job_id is {self.job_id}" | ||||||||||
| f"job {self.job_hash} re-submit after terminated; new job_id is {self.job_id}" | ||||||||||
| ) | ||||||||||
| time.sleep(0.2) | ||||||||||
| self.get_job_state() | ||||||||||
| dlog.info( | ||||||||||
| f"job:{self.job_hash} job_id:{self.job_id} after re-submitting; the state now is {repr(self.job_state)}" | ||||||||||
| f"job {self.job_hash} job_id:{self.job_id} after re-submitting; the state now is {repr(self.job_state)}" | ||||||||||
| ) | ||||||||||
|
Comment on lines
+862
to
863
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Standardize job_id formatting and apply Ruff suggestion. Line 862 uses Apply this diff to standardize the format and fix the f-string: - f"job {self.job_hash} job_id:{self.job_id} after re-submitting; the state now is {repr(self.job_state)}"
+ f"job {self.job_hash} job_id is {self.job_id} after re-submitting; the state now is {self.job_state!r}"📝 Committable suggestion
Suggested change
🧰 Tools🪛 Ruff (0.14.8)862-862: Use explicit conversion flag Replace with conversion flag (RUF010) 🤖 Prompt for AI Agents |
||||||||||
| self.handle_unexpected_job_state() | ||||||||||
| if self.resources.wait_time != 0: | ||||||||||
| time.sleep(self.resources.wait_time) | ||||||||||
|
|
||||||||||
| if job_state == JobStatus.unsubmitted: | ||||||||||
| dlog.debug(f"job: {self.job_hash} unsubmitted; submit it") | ||||||||||
| dlog.debug(f"job {self.job_hash} unsubmitted; submit it") | ||||||||||
| # if self.fail_count > 3: | ||||||||||
| # raise RuntimeError("job:job {job} failed 3 times".format(job=self)) | ||||||||||
| self.submit_job() | ||||||||||
| if self.job_state != JobStatus.unsubmitted: | ||||||||||
| dlog.info(f"job: {self.job_hash} submit; job_id is {self.job_id}") | ||||||||||
| dlog.info(f"job {self.job_hash} was submitted; job_id is {self.job_id}") | ||||||||||
| if self.resources.wait_time != 0: | ||||||||||
| time.sleep(self.resources.wait_time) | ||||||||||
| # self.get_job_state() | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'except' clause does nothing but pass and there is no explanatory comment.