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

+2-2
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

+1-1
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

+2-2
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

+1-2
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

+6-6
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

+4-4
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

+13-13
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

+1-1
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

+3-2
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

+17-11
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):

capsul/execution_context.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,9 @@ def find_temporary_to_generate(executable):
760760
else:
761761
field.generate_temporary = True
762762
if isinstance(node, ProcessIteration):
763-
node.process.field(field.name).generate_temporary = (
764-
field.generate_temporary
765-
)
763+
node.process.field(
764+
field.name
765+
).generate_temporary = field.generate_temporary
766766
# print('!temporaries! ', field.name, '=', field.generate_temporary)
767767

768768
stack = [(executable, field) for field in executable.user_fields()]

capsul/in_context/spm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def spm_command(spm_batch_filename, execution_context=None):
5555
if spm_batch_filename is not None:
5656
cmd += ["batch", spm_batch_filename]
5757
else:
58-
raise NotImplementedError("Running SPM with matlab is not " "implemented yet")
58+
raise NotImplementedError("Running SPM with matlab is not implemented yet")
5959
return cmd
6060

6161

capsul/pipeline/custom_nodes/reduce_node.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def __init__(
7575
bool,
7676
default=False,
7777
output=False,
78-
doc="remove empty (Undefined, None, empty strings) "
79-
"from the output lists",
78+
doc="remove empty (Undefined, None, empty strings) from the output lists",
8079
)
8180
self.input_names = input_names
8281
self.output_names = output_names

capsul/pipeline/pipeline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ def export_parameter(
11221122
# Check if the plug name is valid
11231123
if source_field is None:
11241124
raise ValueError(
1125-
f"Node {node_name} ({node.name}) has no parameter " f"{plug_name}"
1125+
f"Node {node_name} ({node.name}) has no parameter {plug_name}"
11261126
)
11271127

11281128
# Check the pipeline parameter name is not already used

capsul/pipeline/pipeline_nodes.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def __init__(
125125
raise ValueError("output_types parameter should be a list or tuple")
126126
if len(output_types) != len(outputs):
127127
raise ValueError(
128-
"output_types should have the same number of " "elements as outputs"
128+
"output_types should have the same number of elements as outputs"
129129
)
130130
else:
131131
output_types = [typing.Any] * len(outputs)
@@ -385,7 +385,9 @@ def configure_controller(cls):
385385
def configured_controller(self):
386386
c = self.configure_controller()
387387
c.outputs = [
388-
field.name for field in self.fields() if field.is_output() # noqa: F811
388+
field.name
389+
for field in self.fields()
390+
if field.is_output() # noqa: F811
389391
]
390392
c.inputs = self.get_switch_inputs()
391393
c.output_types = [self.field(p).type_str() for p in self.outputs]

capsul/pipeline/test/fake_morphologist/brainorientation.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,7 @@ def pipeline_definition(self):
399399
self.Normalization_NormalizeFSL_allow_retry_initialization = True
400400
self.Normalization_NormalizeFSL_NormalizeFSL_cost_function = "corratio"
401401
self.Normalization_NormalizeFSL_NormalizeFSL_search_cost_function = "corratio"
402-
self.Normalization_NormalizeFSL_ConvertFSLnormalizationToAIMS_standard_template = (
403-
0
404-
)
402+
self.Normalization_NormalizeFSL_ConvertFSLnormalizationToAIMS_standard_template = 0
405403
self.Normalization_NormalizeSPM_allow_retry_initialization = True
406404
self.Normalization_NormalizeSPM_voxel_size = "[1 1 1]"
407405
self.Normalization_NormalizeSPM_cutoff_option = 25

capsul/pipeline/test/fake_morphologist/morphologist.py

+9-27
Original file line numberDiff line numberDiff line change
@@ -1875,30 +1875,18 @@ def pipeline_definition(self):
18751875
self.PrepareSubject_Normalization_NormalizeFSL_alignment = (
18761876
"Not Aligned but Same Orientation"
18771877
)
1878-
self.PrepareSubject_Normalization_NormalizeFSL_set_transformation_in_source_volume = (
1879-
True
1880-
)
1878+
self.PrepareSubject_Normalization_NormalizeFSL_set_transformation_in_source_volume = True
18811879
self.PrepareSubject_Normalization_NormalizeFSL_NormalizeFSL_cost_function = (
18821880
"corratio"
18831881
)
1884-
self.PrepareSubject_Normalization_NormalizeFSL_NormalizeFSL_search_cost_function = (
1885-
"corratio"
1886-
)
1887-
self.PrepareSubject_Normalization_NormalizeFSL_ConvertFSLnormalizationToAIMS_standard_template = (
1888-
0
1889-
)
1882+
self.PrepareSubject_Normalization_NormalizeFSL_NormalizeFSL_search_cost_function = "corratio"
1883+
self.PrepareSubject_Normalization_NormalizeFSL_ConvertFSLnormalizationToAIMS_standard_template = 0
18901884
self.PrepareSubject_Normalization_NormalizeSPM_voxel_size = "[1 1 1]"
18911885
self.PrepareSubject_Normalization_NormalizeSPM_cutoff_option = 25
18921886
self.PrepareSubject_Normalization_NormalizeSPM_nbiteration = 16
1893-
self.PrepareSubject_Normalization_NormalizeSPM_ConvertSPMnormalizationToAIMS_target = (
1894-
"MNI template"
1895-
)
1896-
self.PrepareSubject_Normalization_NormalizeSPM_ConvertSPMnormalizationToAIMS_removeSource = (
1897-
False
1898-
)
1899-
self.PrepareSubject_Normalization_NormalizeBaladin_set_transformation_in_source_volume = (
1900-
True
1901-
)
1887+
self.PrepareSubject_Normalization_NormalizeSPM_ConvertSPMnormalizationToAIMS_target = "MNI template"
1888+
self.PrepareSubject_Normalization_NormalizeSPM_ConvertSPMnormalizationToAIMS_removeSource = False
1889+
self.PrepareSubject_Normalization_NormalizeBaladin_set_transformation_in_source_volume = True
19021890
self.PrepareSubject_Normalization_Normalization_AimsMIRegister_anatomical_template = "/casa/host/build/share/brainvisa-share-5.2/anatomical_templates/MNI152_T1_2mm.nii.gz"
19031891
self.PrepareSubject_Normalization_Normalization_AimsMIRegister_mni_to_acpc = "/casa/host/build/share/brainvisa-share-5.2/transformation/talairach_TO_spm_template_novoxels.trm"
19041892
self.PrepareSubject_Normalization_Normalization_AimsMIRegister_smoothing = 1.0
@@ -1941,21 +1929,15 @@ def pipeline_definition(self):
19411929
self.Renorm_Normalization_NormalizeFSL_NormalizeFSL_search_cost_function = (
19421930
"corratio"
19431931
)
1944-
self.Renorm_Normalization_NormalizeFSL_ConvertFSLnormalizationToAIMS_standard_template = (
1945-
0
1946-
)
1932+
self.Renorm_Normalization_NormalizeFSL_ConvertFSLnormalizationToAIMS_standard_template = 0
19471933
self.Renorm_Normalization_NormalizeSPM_voxel_size = "[1 1 1]"
19481934
self.Renorm_Normalization_NormalizeSPM_cutoff_option = 25
19491935
self.Renorm_Normalization_NormalizeSPM_nbiteration = 16
19501936
self.Renorm_Normalization_NormalizeSPM_ConvertSPMnormalizationToAIMS_target = (
19511937
"MNI template"
19521938
)
1953-
self.Renorm_Normalization_NormalizeSPM_ConvertSPMnormalizationToAIMS_removeSource = (
1954-
False
1955-
)
1956-
self.Renorm_Normalization_NormalizeBaladin_set_transformation_in_source_volume = (
1957-
True
1958-
)
1939+
self.Renorm_Normalization_NormalizeSPM_ConvertSPMnormalizationToAIMS_removeSource = False
1940+
self.Renorm_Normalization_NormalizeBaladin_set_transformation_in_source_volume = True
19591941
self.Renorm_Normalization_Normalization_AimsMIRegister_mni_to_acpc = "/casa/host/build/share/brainvisa-share-5.2/transformation/talairach_TO_spm_template_novoxels.trm"
19601942
self.Renorm_Normalization_Normalization_AimsMIRegister_smoothing = 1.0
19611943
self.SplitBrain_use_ridges = True

0 commit comments

Comments
 (0)