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

Issue984/switch to ruff #987

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open

Issue984/switch to ruff #987

wants to merge 18 commits into from

Conversation

Leahh02
Copy link
Collaborator

@Leahh02 Leahh02 commented Jan 10, 2025

This PR fixes issue #984.

This PR will be compared with PR #986 which switches to pylint so we can decide which one to switch to.

@Leahh02 Leahh02 added the WIP (lint-only) Only run the linter in CI, nothing else label Jan 10, 2025
@Leahh02
Copy link
Collaborator Author

Leahh02 commented Jan 10, 2025

This PR fixes issue #984.

This PR will be compared with PR #986 which switches to pylint so we can decide which one to switch to.

There are things that Ruff isn't picking up that I thought it would. For example, it's not picking up message E501, the line too long error, when it should be. This is because it's only checking rules sections ["E4", "E7", "E9", "F"] because that's the default for the select category of the configuration. We can add more sections to the select category or create a extend-select section to the configuration.

There are some message codes that I set to ignore in ruff.toml even though they are in "preview". It seems like "preview" is something they're working to introduce. I went ahead and added "preview" message codes into ruff.toml that were in setup.cfg so we'd have them there when they get added to a new release. These messages are PLR0914 and PLR0916

@Leahh02
Copy link
Collaborator Author

Leahh02 commented Jan 13, 2025

Message controls for specific lines and for entire files

For pylama we have some lines where we want to skip linting. We do this by having # noqa at the end of the line. ruff uses the same syntax, you can add # noqa at the end of the line to skip all linting message codes or you can specify a code(s) to skip, for example # noqa: F841. It's nice that ruff follows this same format as pylama (pylint doesn't, see my comments about this in PR #986 . Depending on the error message groups we decide to add to our configuration we might need to ignore lines we weren't ignoring before, and we might need to stop ignoring some lines because we not be checking the message codes that were flagging those lines anymore.

In addition to skipping specific lines, we also have specific message codes skipped for an entire file. We're doing this in pylama by adding # pylama:ignore=message_code at the bottom of the file. For example, we have # pylama:ignore=W0511,R1732 at the bottom of bee_client.py. The ruff equivalent is to have # ruff: noqa: message_code anywhere in the file, although they say it's preferred to be at the top of the file. So like the line specific skips we'll need to see which codes we want to add/remove and then we need to decide if we want to keep these ignore lines at the bottom or move them to the top.

Here's ruff documentation on error suppression: https://docs.astral.sh/ruff/linter/#error-suppression

@Leahh02
Copy link
Collaborator Author

Leahh02 commented Jan 21, 2025

warning: Invalid `# noqa` directive on beeflow/client/bee_client.py:37: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
warning: Invalid `# noqa` directive on beeflow/client/bee_client.py:234: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
warning: Invalid `# noqa` directive on beeflow/client/bee_client.py:473: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
warning: Invalid `# noqa` directive on beeflow/client/bee_client.py:479: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
warning: Invalid `# noqa` directive on beeflow/client/bee_client.py:703: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
warning: Invalid `# noqa` directive on beeflow/common/worker/__init__.py:3: expected a comma-separated list of codes (e.g., `# noqa: F401, F841`).
beeflow/client/bee_client.py:123:5: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation
    |
121 |                    'and it is still running. ')
122 |               sys.exit(1)
123 |       else:  # beeflow was started on compute node but user no longer owns node
    |  _____^
124 | |         if command:
    | |________^ PLR5501
125 |               warn('beeflow has not been started!')
126 |               sys.exit(1)
    |
    = help: Convert to `elif`

beeflow/client/bee_client.py:172:28: PLR2004 Magic value used in comparison, consider replacing `500` with a constant variable
    |
170 | def error_handler(resp):  # noqa (this is an error handler, it doesn't need to return an expression)
171 |     """Handle a 500 error in a response."""
172 |     if resp.status_code != 500:
    |                            ^^^ PLR2004
173 |         return resp
174 |     data = resp.json()
    |

beeflow/client/bee_client.py:298:5: PLR0915 Too many statements (76 > 50)
    |
297 | @app.command()
298 | def submit(wf_name: str = typer.Argument(..., help='the workflow name'),  # pylint:disable=R0915
    |     ^^^^^^ PLR0915
299 |            wf_path: pathlib.Path = typer.Argument(..., help='path to the workflow .tgz or dir'),
300 |            main_cwl: str = typer.Argument(...,
    |

beeflow/client/bee_client.py:398:32: PLR2004 Magic value used in comparison, consider replacing `400` with a constant variable
    |
397 |     if resp.status_code != requests.codes.created:  # pylint: disable=no-member
398 |         if resp.status_code == 400:
    |                                ^^^ PLR2004
399 |             data = resp.json()
400 |             error_exit(data['msg'])
    |

beeflow/client/bee_client.py:444:28: PLR2004 Magic value used in comparison, consider replacing `400` with a constant variable
    |
442 |         error_exit('Could not reach WF Manager.')
443 | 
444 |     if resp.status_code == 400:
    |                            ^^^ PLR2004
445 |         error_exit("Could not start workflow. It may have already been started "
446 |                    "and ran to completion (or failure).")
    |

beeflow/common/cloud/__init__.py:6:44: F401 `beeflow.common.cloud.constants.BEE_USER` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
  |
4 | from beeflow.common.cloud import provider
5 | from beeflow.common.cloud import google
6 | from beeflow.common.cloud.constants import BEE_USER
  |                                            ^^^^^^^^ F401
7 | from beeflow.common.cloud.cloud import CloudError
  |
  = help: Use an explicit re-export: `BEE_USER as BEE_USER`

beeflow/common/cloud/__init__.py:7:40: F401 `beeflow.common.cloud.cloud.CloudError` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
  |
5 | from beeflow.common.cloud import google
6 | from beeflow.common.cloud.constants import BEE_USER
7 | from beeflow.common.cloud.cloud import CloudError
  |                                        ^^^^^^^^^^ F401
  |
  = help: Use an explicit re-export: `CloudError as CloudError`

beeflow/common/container_path.py:25:9: PLW2901 `for` loop variable `outside` overwritten by assignment target
   |
23 |     comps = _components(path)
24 |     for outside, inside in bind_mounts.items():
25 |         outside = _components(outside)
   |         ^^^^^^^ PLW2901
26 |         inside = _components(inside)
27 |         if comps[:len(outside)] == outside:
   |

beeflow/common/container_path.py:26:9: PLW2901 `for` loop variable `inside` overwritten by assignment target
   |
24 |     for outside, inside in bind_mounts.items():
25 |         outside = _components(outside)
26 |         inside = _components(inside)
   |         ^^^^^^ PLW2901
27 |         if comps[:len(outside)] == outside:
28 |             base = comps[len(outside):]
   |

beeflow/common/crt_interface.py:8:55: F401 [*] `beeflow.common.config_driver.BeeConfig` imported but unused
   |
 6 | """
 7 | 
 8 | from beeflow.common.config_driver import BeeConfig as bc
   |                                                       ^^ F401
 9 | from beeflow.common.crt.charliecloud_driver import CharliecloudDriver
10 | from beeflow.common.crt.singularity_driver import SingularityDriver
   |
   = help: Remove unused import: `beeflow.common.config_driver.BeeConfig`

beeflow/common/crt_interface.py:10:51: F401 [*] `beeflow.common.crt.singularity_driver.SingularityDriver` imported but unused
   |
 8 | from beeflow.common.config_driver import BeeConfig as bc
 9 | from beeflow.common.crt.charliecloud_driver import CharliecloudDriver
10 | from beeflow.common.crt.singularity_driver import SingularityDriver
   |                                                   ^^^^^^^^^^^^^^^^^ F401
   |
   = help: Remove unused import: `beeflow.common.crt.singularity_driver.SingularityDriver`

beeflow/common/parser/parser.py:279:13: PLR5501 [*] Use `elif` instead of `else` then `if`, to reduce indentation
    |
277 |                   # Fill in glob with value of stderr
278 |                   glob = stderr
279 |               else:
    |  _____________^
280 | |                 if out_map[out].outputBinding:
    | |________________^ PLR5501
281 |                       glob = out_map[out].outputBinding.glob
    |
    = help: Convert to `elif`

beeflow/common/worker/__init__.py:3:42: F401 `beeflow.common.worker.worker.WorkerError` imported but unused; consider removing, adding to `__all__`, or using a redundant alias
  |
1 | """Init file for the worker package."""
2 | 
3 | from beeflow.common.worker.worker import WorkerError  # noqa: this is imported for external code
  |                                          ^^^^^^^^^^^ F401
4 | from beeflow.common.worker.slurm_worker import SlurmWorker
5 | from beeflow.common.worker.lsf_worker import LSFWorker
  |
  = help: Use an explicit re-export: `WorkerError as WorkerError`

beeflow/common/worker/slurm_worker.py:35:9: PLR0915 Too many statements (55 > 50)
   |
33 |         self.default_partition = default_partition
34 | 
35 |     def build_text(self, task):
   |         ^^^^^^^^^^ PLR0915
36 |         """Build text for task script."""
37 |         task_save_path = self.task_save_path(task)
   |

beeflow/common/worker/slurm_worker.py:175:36: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
173 |         try:
174 |             resp = self.session.get(f'{self.slurm_url}/job/{job_id}')
175 |             if resp.status_code == 200:
    |                                    ^^^ PLR2004
176 |                 data = json.loads(resp.text)
177 |                 # Check for errors in the response
    |

beeflow/common/worker/slurm_worker.py:200:32: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
198 |         # HTTP error code, but just an error in the body
199 |         errmsg = f'Unable to cancel job id {job_id}!'
200 |         if resp.status_code != 200:
    |                                ^^^ PLR2004
201 |             raise WorkerError(f'{errmsg}: Bad response code: {resp.status_code}')
202 |         try:
    |

beeflow/common/worker_interface.py:8:46: F401 [*] `beeflow.common.worker.lsf_worker.LSFWorker` imported but unused
  |
7 | from beeflow.common.worker.slurm_worker import SlurmWorker
8 | from beeflow.common.worker.lsf_worker import LSFWorker
  |                                              ^^^^^^^^^ F401
  |
  = help: Remove unused import: `beeflow.common.worker.lsf_worker.LSFWorker`

beeflow/data/cwl/cwl_validation/ml-workflow/machine_learning/linear_regression.py:34:5: F841 Local variable `m_json` is assigned to but never used
   |
32 |     average_y_intercept = np.mean(y_in)
33 |     m_list = average_slope.tolist()
34 |     m_json = json.dumps(m_list)
   |     ^^^^^^ F841
35 |     y_in_list = average_y_intercept.tolist()
36 |     y_in_json = json.dumps(y_in_list)
   |
   = help: Remove assignment to unused variable `m_json`

beeflow/data/cwl/cwl_validation/ml-workflow/machine_learning/linear_regression.py:36:5: F841 Local variable `y_in_json` is assigned to but never used
   |
34 |     m_json = json.dumps(m_list)
35 |     y_in_list = average_y_intercept.tolist()
36 |     y_in_json = json.dumps(y_in_list)
   |     ^^^^^^^^^ F841
37 | 
38 |     print('Learning regression line parameters.')
   |
   = help: Remove assignment to unused variable `y_in_json`

beeflow/data/cwl/cwl_validation/ml-workflow/machine_learning/read_dataset.py:29:5: F841 Local variable `df1` is assigned to but never used
   |
27 |     pickle.dump(X, open("MyX.p", "wb"))
28 |     pickle.dump(Y, open("MyY.p", "wb"))
29 |     df1 = X.to_json()
   |     ^^^ F841
30 |     df2 = Y.to_json()
   |
   = help: Remove assignment to unused variable `df1`

beeflow/data/cwl/cwl_validation/ml-workflow/machine_learning/read_dataset.py:30:5: F841 Local variable `df2` is assigned to but never used
   |
28 |     pickle.dump(Y, open("MyY.p", "wb"))
29 |     df1 = X.to_json()
30 |     df2 = Y.to_json()
   |     ^^^ F841
   |
   = help: Remove assignment to unused variable `df2`

beeflow/remote/remote.py:159:31: PLR2004 Magic value used in comparison, consider replacing `98` with a constant variable
    |
157 |         server.run()
158 |     except OSError as exception:
159 |         if exception.errno == 98:
    |                               ^^ PLR2004
160 |             print(f"Selected port {port_number} is already in use.")
161 |         raise
    |

beeflow/task_manager/background.py:135:28: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
133 |     conn = utils.wfm_conn()
134 |     resp = conn.put(utils.wfm_resource_url("update/"), json={'state_updates': state_updates})
135 |     if resp.status_code == 200:
    |                            ^^^ PLR2004
136 |         # The workflow manager received the updates, so clear the queue
137 |         db.update_queue.clear()
    |

beeflow/tests/mocks.py:101:9: D401 First line of docstring should be in imperative mood: "Returns the task state."
    |
100 |     def get_task_state(self, task_name): # noqa
101 |         """Returns the task state."""
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D401
102 |         return "RUNNING"
    |

beeflow/tests/mocks.py:333:9: D400 First line should end with a period
    |
332 |     def cancel_task(self, job_id): # noqa
333 |         """Return cancelled status"""
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D400
334 |         return 'CANCELLED'
    |
    = help: Add period

beeflow/tests/mocks.py:333:9: D415 First line should end with a period, question mark, or exclamation point
    |
332 |     def cancel_task(self, job_id): # noqa
333 |         """Return cancelled status"""
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ D415
334 |         return 'CANCELLED'
    |
    = help: Add closing punctuation

beeflow/tests/test_db_tm.py:38:37: PLR2004 Magic value used in comparison, consider replacing `3` with a constant variable
   |
36 |     assert db.submit_queue.count() == 1
37 |     assert db.job_queue.count() == 1
38 |     assert db.submit_queue.pop() == 3
   |                                     ^ PLR2004
39 |     popped_job = db.job_queue.pop()
40 |     assert popped_job.task == 45
   |

beeflow/tests/test_db_tm.py:40:31: PLR2004 Magic value used in comparison, consider replacing `45` with a constant variable
   |
38 |     assert db.submit_queue.pop() == 3
39 |     popped_job = db.job_queue.pop()
40 |     assert popped_job.task == 45
   |                               ^^ PLR2004
41 |     assert popped_job.job_id == 1289
42 |     assert popped_job.job_state == 'READY'
   |

beeflow/tests/test_db_tm.py:41:33: PLR2004 Magic value used in comparison, consider replacing `1289` with a constant variable
   |
39 |     popped_job = db.job_queue.pop()
40 |     assert popped_job.task == 45
41 |     assert popped_job.job_id == 1289
   |                                 ^^^^ PLR2004
42 |     assert popped_job.job_state == 'READY'
43 |     assert db.submit_queue.count() == 0
   |

beeflow/tests/test_db_tm.py:116:36: PLR2004 Magic value used in comparison, consider replacing `3` with a constant variable
    |
114 |     db.job_queue.push(task={46, 57}, job_id=111, job_state='some-state2')
115 | 
116 |     assert db.job_queue.count() == 3
    |                                    ^ PLR2004
117 | 
118 |     jobs = list(db.job_queue)
    |

beeflow/tests/test_db_tm.py:122:36: PLR2004 Magic value used in comparison, consider replacing `2` with a constant variable
    |
120 |     db.job_queue.remove_by_id(id_)
121 | 
122 |     assert db.job_queue.count() == 2
    |                                    ^ PLR2004
123 |     job = db.job_queue.pop()
124 |     assert job.task == {8, 9, 10}
    |

beeflow/tests/test_db_tm.py:125:26: PLR2004 Magic value used in comparison, consider replacing `888` with a constant variable
    |
123 |     job = db.job_queue.pop()
124 |     assert job.task == {8, 9, 10}
125 |     assert job.job_id == 888
    |                          ^^^ PLR2004
126 |     assert job.job_state == 'some-state0'
127 |     job = db.job_queue.pop()
    |

beeflow/tests/test_db_tm.py:129:26: PLR2004 Magic value used in comparison, consider replacing `111` with a constant variable
    |
127 |     job = db.job_queue.pop()
128 |     assert job.task == {46, 57}
129 |     assert job.job_id == 111
    |                          ^^^ PLR2004
130 |     assert job.job_state == 'some-state2'
131 |     assert db.job_queue.count() == 0
    |

beeflow/tests/test_db_tm.py:146:26: PLR2004 Magic value used in comparison, consider replacing `888` with a constant variable
    |
144 |     job = db.job_queue.pop()
145 |     assert job.task == {8, 9, 10}
146 |     assert job.job_id == 888
    |                          ^^^ PLR2004
147 |     assert job.job_state == 'COMPLETED'
    |

beeflow/tests/test_scheduler.py:133:46: PLR2004 Magic value used in comparison, consider replacing `2` with a constant variable
    |
131 |         assert task1.allocations[0].start_time == 0
132 |         assert task2.allocations[0].id_ == 'resource-0'
133 |         assert task2.allocations[0].nodes == 2
    |                                              ^ PLR2004
134 |         assert (task2.allocations[0].start_time
135 |                 == task1.requirements.max_runtime)
    |

beeflow/tests/test_scheduler.py:168:42: PLR2004 Magic value used in comparison, consider replacing `2` with a constant variable
    |
166 |         algorithms.Backfill().schedule_all(tasks, resources)
167 | 
168 |         assert len(task1.allocations) == 2
    |                                          ^ PLR2004
169 |         assert all(a.start_time == 0 for a in task1.allocations)
170 |         assert len(task2.allocations) == 4
    |

beeflow/tests/test_scheduler.py:170:42: PLR2004 Magic value used in comparison, consider replacing `4` with a constant variable
    |
168 |         assert len(task1.allocations) == 2
169 |         assert all(a.start_time == 0 for a in task1.allocations)
170 |         assert len(task2.allocations) == 4
    |                                          ^ PLR2004
171 |         start_time = task1.requirements.max_runtime
172 |         assert all(a.start_time == start_time for a in task2.allocations)
    |

beeflow/tests/test_scheduler.py:210:46: PLR2004 Magic value used in comparison, consider replacing `4` with a constant variable
    |
208 |         assert task1.allocations[0].start_time == 0
209 |         assert task2.allocations[0].id_ == 'resource-0'
210 |         assert task2.allocations[0].nodes == 4
    |                                              ^ PLR2004
211 |         assert (task2.allocations[0].start_time
212 |                 == task1.requirements.max_runtime)
    |

beeflow/tests/test_scheduler.py:345:42: PLR2004 Magic value used in comparison, consider replacing `10` with a constant variable
    |
344 |     assert task1.allocations[0].id_ == 'test-resource-2'
345 |     assert task1.allocations[0].nodes == 10
    |                                          ^^ PLR2004
346 |     assert task1.allocations[0].start_time == 0
    |

beeflow/tests/test_scheduler_resource_allocation.py:13:37: PLR2004 Magic value used in comparison, consider replacing `8192` with a constant variable
   |
11 |     assert resource.id_ == 'test-resource'
12 |     assert resource.nodes == 1
13 |     assert resource.mem_per_node == 8192
   |                                     ^^^^ PLR2004
14 |     assert resource.gpus_per_node == 0
   |

beeflow/tests/test_scheduler_resource_allocation.py:37:38: PLR2004 Magic value used in comparison, consider replacing `4` with a constant variable
   |
35 |     assert allocation.id_ == 'resource-0'
36 |     assert allocation.start_time == 0
37 |     assert allocation.max_runtime == 4
   |                                      ^ PLR2004
38 |     assert allocation.nodes == 2
   |

beeflow/tests/test_scheduler_resource_allocation.py:38:32: PLR2004 Magic value used in comparison, consider replacing `2` with a constant variable
   |
36 |     assert allocation.start_time == 0
37 |     assert allocation.max_runtime == 4
38 |     assert allocation.nodes == 2
   |                                ^ PLR2004
   |

beeflow/tests/test_scheduler_resource_allocation.py:59:40: PLR2004 Magic value used in comparison, consider replacing `3` with a constant variable
   |
57 |     requirements = resource_allocation.Requirements(max_runtime=3, nodes=1)
58 | 
59 |     assert requirements.max_runtime == 3
   |                                        ^ PLR2004
60 |     assert requirements.nodes == 1
61 |     # TODO: Determine what the default per node requirements should be
   |

beeflow/tests/test_scheduler_rest.py:53:31: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
   |
51 |     req = conn.put(endpoint('workflows', workflow_name, 'jobs'), json=[task1])
52 | 
53 |     assert req.status_code == 200
   |                               ^^^ PLR2004
54 |     data = req.json
55 |     assert len(data) == 1
   |

beeflow/tests/test_scheduler_rest.py:78:31: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
   |
76 |     req = conn.put(endpoint('resources'), json=[resource1])
77 | 
78 |     assert req.status_code == 200
   |                               ^^^ PLR2004
79 |     assert req.json == 'created 1 resource(s)'
   |

beeflow/tests/test_scheduler_rest.py:91:31: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
   |
89 |     req = conn.put(endpoint('workflows', workflow_name, 'jobs'), json=[task1])
90 | 
91 |     assert req.status_code == 200
   |                               ^^^ PLR2004
92 |     data = req.json
93 |     assert len(data) == 1
   |

beeflow/tests/test_scheduler_rest.py:124:31: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
122 |     req = conn.put(endpoint('resources'), json=[resource1, resource2])
123 | 
124 |     assert req.status_code == 200
    |                               ^^^ PLR2004
125 |     assert req.json == 'created 2 resource(s)'
    |

beeflow/tests/test_scheduler_rest.py:137:31: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
135 |     req = conn.put(endpoint('workflows', workflow_name, 'jobs'), json=[task1])
136 | 
137 |     assert req.status_code == 200
    |                               ^^^ PLR2004
138 |     data = req.json
139 |     assert len(data) == 1
    |

beeflow/tests/test_scheduler_rest.py:166:31: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
164 |     req = conn.put(endpoint('resources'), json=[resource1, resource2])
165 | 
166 |     assert req.status_code == 200
    |                               ^^^ PLR2004
167 |     assert req.json == 'created 2 resource(s)'
    |

beeflow/tests/test_scheduler_rest.py:195:31: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
193 |                    json=[task1, task2, task3])
194 | 
195 |     assert req.status_code == 200
    |                               ^^^ PLR2004
196 |     data = req.json
197 |     assert len(data) == 3
    |

beeflow/tests/test_scheduler_rest.py:197:25: PLR2004 Magic value used in comparison, consider replacing `3` with a constant variable
    |
195 |     assert req.status_code == 200
196 |     data = req.json
197 |     assert len(data) == 3
    |                         ^ PLR2004
198 |     assert data[0]['workflow_name'] == 'test-workflow'
199 |     assert data[0]['task_name'] == 'test-task-0'
    |

beeflow/tests/test_scheduler_rest.py:203:54: PLR2004 Magic value used in comparison, consider replacing `6` with a constant variable
    |
201 |     assert len(data[0]['allocations']) > 0
202 |     # Ensure proper scheduled time
203 |     assert data[0]['allocations'][0]['start_time'] < 6
    |                                                      ^ PLR2004
204 |     assert data[1]['workflow_name'] == 'test-workflow'
205 |     assert data[1]['task_name'] == 'test-task-1'
    |

beeflow/tests/test_scheduler_rest.py:209:54: PLR2004 Magic value used in comparison, consider replacing `6` with a constant variable
    |
207 |     assert len(data[1]['allocations']) > 0
208 |     # Ensure proper scheduled time
209 |     assert data[1]['allocations'][0]['start_time'] < 6
    |                                                      ^ PLR2004
210 |     assert data[2]['workflow_name'] == 'test-workflow'
211 |     assert data[2]['task_name'] == 'test-task-2'
    |

beeflow/tests/test_scheduler_rest.py:212:54: PLR2004 Magic value used in comparison, consider replacing `4` with a constant variable
    |
210 |     assert data[2]['workflow_name'] == 'test-workflow'
211 |     assert data[2]['task_name'] == 'test-task-2'
212 |     assert data[2]['requirements']['max_runtime'] == 4
    |                                                      ^ PLR2004
213 |     assert data[2]['requirements']['nodes'] == 16
214 |     assert len(data[2]['allocations']) > 0
    |

beeflow/tests/test_scheduler_rest.py:213:48: PLR2004 Magic value used in comparison, consider replacing `16` with a constant variable
    |
211 |     assert data[2]['task_name'] == 'test-task-2'
212 |     assert data[2]['requirements']['max_runtime'] == 4
213 |     assert data[2]['requirements']['nodes'] == 16
    |                                                ^^ PLR2004
214 |     assert len(data[2]['allocations']) > 0
215 |     # Ensure proper scheduled time
    |

beeflow/tests/test_scheduler_rest.py:216:54: PLR2004 Magic value used in comparison, consider replacing `6` with a constant variable
    |
214 |     assert len(data[2]['allocations']) > 0
215 |     # Ensure proper scheduled time
216 |     assert data[2]['allocations'][0]['start_time'] < 6
    |                                                      ^ PLR2004
    |

beeflow/tests/test_tm.py:76:22: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
   |
74 |     assert job.job_state == 'RUNNING'
75 | 
76 |     assert status == 200
   |                      ^^^ PLR2004
77 |     assert msg == 'Tasks Added!'
   |

beeflow/tests/test_tm.py:113:22: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
111 |     msg = response.get_json()['msg']
112 |     status = response.status_code
113 |     assert status == 200
    |                      ^^^ PLR2004
114 |     assert msg.count('CANCELLED') == 3
    |

beeflow/tests/test_tm.py:114:38: PLR2004 Magic value used in comparison, consider replacing `3` with a constant variable
    |
112 |     status = response.status_code
113 |     assert status == 200
114 |     assert msg.count('CANCELLED') == 3
    |                                      ^ PLR2004
    |

beeflow/tests/test_wf_manager.py:166:32: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
164 |     mocker.patch('beeflow.common.wf_interface.WorkflowInterface.get_workflow_state', 'Waiting')
165 |     resp = client().post(f'/bee_wfm/v1/jobs/{WF_ID}')
166 |     assert resp.status_code == 200
    |                                ^^^ PLR2004
    |

beeflow/tests/test_wf_manager.py:205:32: PLR2004 Magic value used in comparison, consider replacing `202` with a constant variable
    |
203 |     resp = client().delete(f'/bee_wfm/v1/jobs/{WF_ID}', json=request)
204 |     assert resp.json['status'] == 'Cancelled'
205 |     assert resp.status_code == 202
    |                                ^^^ PLR2004
    |

beeflow/tests/test_wf_manager.py:225:32: PLR2004 Magic value used in comparison, consider replacing `202` with a constant variable
    |
223 |     resp = client().delete(f'/bee_wfm/v1/jobs/{WF_ID}', json=request)
224 |     assert resp.json['status'] == 'Removed'
225 |     assert resp.status_code == 202
    |                                ^^^ PLR2004
    |

beeflow/tests/test_wf_manager.py:241:32: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
239 |     resp = client().patch(f'/bee_wfm/v1/jobs/{WF_ID}', json=request)
240 |     assert resp.json['status'] == 'Workflow Paused'
241 |     assert resp.status_code == 200
    |                                ^^^ PLR2004
    |

beeflow/tests/test_wf_manager.py:260:32: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
258 |     resp = client().patch(f'/bee_wfm/v1/jobs/{WF_ID}', json=request)
259 |     assert resp.json['status'] == 'Workflow Resumed'
260 |     assert resp.status_code == 200
    |                                ^^^ PLR2004
261 | # pylama:ignore=W0621,W0613
    |

beeflow/wf_manager/resources/wf_utils.py:213:28: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
211 |         return
212 | 
213 |     if resp.status_code != 200:
    |                            ^^^ PLR2004
214 |         log.info(f"Submit task to TM returned bad status: {resp.status_code}")
    |

beeflow/wf_manager/resources/wf_utils.py:245:28: PLR2004 Magic value used in comparison, consider replacing `200` with a constant variable
    |
243 |         return "Did not work"
244 | 
245 |     if resp.status_code != 200:
    |                            ^^^ PLR2004
246 |         log.info(f"Something bad happened {resp.status_code}")
247 |         return "Did not work"
    |

Found 66 errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP (lint-only) Only run the linter in CI, nothing else
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant