Skip to content

Commit cbb5e34

Browse files
authored
Merge pull request #367 from DimitriPapadopoulos/pre-commit
pre-commit autoupdate
2 parents b1626c7 + daa4d51 commit cbb5e34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+281
-425
lines changed

.github/workflows/test-v3.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ jobs:
5151

5252
steps:
5353
- uses: actions/checkout@v3
54-
54+
5555
- name: Set up Python 3.10
5656
uses: actions/setup-python@v3
5757
with:
5858
python-version: "3.10"
59-
59+
6060
- name: Install dependencies
6161
run: |
6262
python -m pip install --upgrade pip

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
build/
1616
/doc/source/*/generated/
1717
/doc/source/tutorial/capsul_tutorial.ipynb
18-
*.egg-info/
18+
*.egg-info/

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exclude: |
1010
1111
repos:
1212
- repo: https://github.com/pre-commit/pre-commit-hooks
13-
rev: v4.5.0
13+
rev: v5.0.0
1414
hooks:
1515
- id: check-added-large-files
1616
- id: check-case-conflict
@@ -30,7 +30,7 @@ repos:
3030
- id: trailing-whitespace
3131

3232
- repo: https://github.com/astral-sh/ruff-pre-commit
33-
rev: v0.3.0
33+
rev: v0.9.1
3434
hooks:
3535
- id: ruff
3636
- id: ruff-format

capsul/application.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ def executable(definition, **kwargs):
247247
elif isinstance(definition, Process):
248248
if kwargs:
249249
raise ValueError(
250-
"executable() do not allow to modify parameters "
251-
"of an existing process"
250+
"executable() do not allow to modify parameters of an existing process"
252251
)
253252
return definition
254253
elif isinstance(definition, type) and issubclass(definition, Process):

capsul/config/configuration.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ def is_valid_config(self, requirements, explain=False):
121121
other requirements. The implementation is free to interpret it as
122122
it needs. Thus modules implementations should document how they
123123
define and check their requirements.
124-
124+
125125
explain: bool
126-
bool value to specify that an explanation is required when a module
127-
configuration is not valid. When :param:`explain` is true and the
128-
configuration module is invalid, the returned value is a
129-
:type:`str` containing the reason why the module is not valid.
126+
bool value to specify that an explanation is required when a module
127+
configuration is not valid. When :param:`explain` is true and the
128+
configuration module is invalid, the returned value is a
129+
:type:`str` containing the reason why the module is not valid.
130130
131131
Returns
132132
-------
@@ -140,7 +140,7 @@ def is_valid_config(self, requirements, explain=False):
140140
instance a SPM module may return ``{'matlab': {'mcr': True'}}``
141141
"""
142142
raise NotImplementedError(
143-
"A subclass of ModuleConfiguration must " "define is_valid_config()"
143+
"A subclass of ModuleConfiguration must define is_valid_config()"
144144
)
145145

146146

capsul/database/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ConnectionError(Exception):
8484
def engine_database(config):
8585
class_string = database_classes.get(config["type"])
8686
if class_string is None:
87-
raise ValueError(f'Invalid database type: {config["type"]}')
87+
raise ValueError(f"Invalid database type: {config['type']}")
8888
module_name, class_name = class_string.rsplit(":", 1)
8989
module = importlib.import_module(module_name)
9090
database_class = getattr(module, class_name)
@@ -274,7 +274,7 @@ def failed_node_paths(self, engine_id, execution_id):
274274

275275
def print_execution_report(self, report, file=sys.stdout):
276276
print(
277-
"====================\n" "| Execution report |\n" "====================\n",
277+
"====================\n| Execution report |\n====================\n",
278278
file=file,
279279
)
280280
print("label:", report["label"], file=file)
@@ -290,7 +290,7 @@ def print_execution_report(self, report, file=sys.stdout):
290290
print("-" * 50, file=file)
291291
print(report["error_detail"], file=file)
292292
print("-" * 50, file=file)
293-
print("\n---------------\n" "| Jobs status |\n" "---------------\n", file=file)
293+
print("\n---------------\n| Jobs status |\n---------------\n", file=file)
294294
print("waiting:", report["waiting"])
295295
print("ready:", report["ready"])
296296
print("ongoing:", report["ongoing"])
@@ -348,7 +348,7 @@ def print_execution_report(self, report, file=sys.stdout):
348348

349349
if report["engine_debug"]:
350350
print(
351-
"\n----------------\n" "| Engine debug |\n" "----------------\n",
351+
"\n----------------\n| Engine debug |\n----------------\n",
352352
file=file,
353353
)
354354
for k, v in report["engine_debug"].items():

capsul/database/populse_db.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _enter(self):
107107
self.storage = Storage(self.path)
108108
else:
109109
raise NotImplementedError(
110-
f'Invalid populse-db connection type: {self.config["type"]}'
110+
f"Invalid populse-db connection type: {self.config['type']}"
111111
)
112112
with self.storage.schema() as schema:
113113
schema.add_schema("capsul.database.populse_db")
@@ -397,9 +397,9 @@ def job_finished_json(
397397
waiting_job["return_code"] = (
398398
"Not started because de dependent job failed"
399399
)
400-
db.capsul_job[engine_id, execution_id, waiting_id].job = (
401-
waiting_job
402-
)
400+
db.capsul_job[
401+
engine_id, execution_id, waiting_id
402+
].job = waiting_job
403403
waiting.remove(waiting_id)
404404
failed.append(waiting_id)
405405
stack.update(waiting_job.get("waited_by", []))
@@ -429,9 +429,9 @@ def job_finished_json(
429429

430430
if not ongoing and not ready:
431431
if failed:
432-
db.capsul_execution[engine_id, execution_id].error = (
433-
"Some jobs failed"
434-
)
432+
db.capsul_execution[
433+
engine_id, execution_id
434+
].error = "Some jobs failed"
435435
db.capsul_execution[engine_id, execution_id].update(
436436
{
437437
"status": "finalization",
@@ -485,12 +485,12 @@ def set_job_output_parameters(
485485
indices = job.get("parameters_index", {})
486486
for name, value in output_parameters.items():
487487
values[indices[name]] = value
488-
db.capsul_job[engine_id, execution_id, job_id].job.output_parameters = (
489-
output_parameters
490-
)
491-
db.capsul_execution[engine_id, execution_id].workflow_parameters_values = (
492-
values
493-
)
488+
db.capsul_job[
489+
engine_id, execution_id, job_id
490+
].job.output_parameters = output_parameters
491+
db.capsul_execution[
492+
engine_id, execution_id
493+
].workflow_parameters_values = values
494494

495495
def job_json(self, engine_id, execution_id, job_id):
496496
if os.path.exists(self.path):

capsul/database/redis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _enter(self):
113113
self.redis = self._connect(decode_responses=True)
114114
else:
115115
raise NotImplementedError(
116-
f'Invalid Redis connection type: {self.config["type"]}'
116+
f"Invalid Redis connection type: {self.config['type']}"
117117
)
118118
if self.redis.get("capsul:shutting_down"):
119119
raise RuntimeError(

capsul/dataset.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def _path_list(self, unused_meta=None):
236236
path_list.append(self.data_type)
237237
elif not self.process:
238238
raise ValueError(
239-
"BIDS schema requires a value for either " "data_type or process"
239+
"BIDS schema requires a value for either data_type or process"
240240
)
241241

242242
filename = [f"sub-{self.sub}", f"ses-{self.ses}"]
@@ -1247,7 +1247,8 @@ def path_for_parameters(self, executable, parameters=None):
12471247

12481248
if parameters is None:
12491249
parameters = [
1250-
field.name for field in executable.user_fields() # if field.path_type
1250+
field.name
1251+
for field in executable.user_fields() # if field.path_type
12511252
]
12521253
if self.debug:
12531254
if self._current_iteration is not None:

capsul/engine/__init__.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,30 @@ def execution_context(engine_label, engine_config, executable):
6262
req_to_check.update(added_req)
6363
else:
6464
if module_name in needed_modules:
65-
# Keep the invalid config in order to be able to display explanation
66-
# later
67-
invalid_needed_configs.setdefault(module_name, {})[module_field] = module_config
65+
# Keep the invalid config in order to be able to display explanation
66+
# later
67+
invalid_needed_configs.setdefault(module_name, {})[module_field] = (
68+
module_config
69+
)
6870

6971
# now check we have only one module for each
7072
for module_name in needed_modules:
7173
valid_module_configs = valid_configs.get(module_name)
7274
if valid_module_configs is None:
73-
message = f'Execution environment "{engine_label}" has no ' \
74-
f"valid configuration for module {module_name}."
75-
76-
for module_field, module_config in invalid_needed_configs.get(module_name, {}).items():
75+
message = (
76+
f'Execution environment "{engine_label}" has no '
77+
f"valid configuration for module {module_name}."
78+
)
79+
80+
for module_field, module_config in invalid_needed_configs.get(
81+
module_name, {}
82+
).items():
7783
# Get explanation about invalid config rejection
7884
explaination = module_config.is_valid_config(requirements, explain=True)
7985
message += f"\n - {module_field.name} is not valid for requirements: {explaination}"
8086

8187
raise RuntimeError(message)
82-
88+
8389
if len(valid_module_configs) > 1:
8490
# print(f"several {module_name} valid condfigs:")
8591
# for field, v in valid_module_configs.items():
@@ -211,7 +217,7 @@ def quote(x):
211217
return f"'{x}'"
212218

213219
raise RuntimeError(
214-
f'Command failed: {" ".join(quote(i) for i in workers_command)}'
220+
f"Command failed: {' '.join(quote(i) for i in workers_command)}"
215221
) from e
216222

217223
def kill_workers(self, worker_ids=None):
@@ -232,7 +238,7 @@ def quote(x):
232238
return f"'{x}'"
233239

234240
raise RuntimeError(
235-
f'Command failed: {" ".join(quote(i) for i in cmd)}'
241+
f"Command failed: {' '.join(quote(i) for i in cmd)}"
236242
) from e
237243
self.database.worker_ended(self.engine_id, worker_id)
238244

@@ -261,7 +267,7 @@ def assess_ready_to_start(self, executable):
261267
missing.append(field.name)
262268
if missing:
263269
raise ValueError(
264-
f'Value missing for the following parameters: {", ".join(missing)}'
270+
f"Value missing for the following parameters: {', '.join(missing)}"
265271
)
266272

267273
def start(self, executable, debug=False):

0 commit comments

Comments
 (0)