From eae9d4294db65a8da2e33e3e617448a1c90c15a6 Mon Sep 17 00:00:00 2001 From: Eleftherios Zisis Date: Sat, 3 Aug 2024 20:54:03 +0300 Subject: [PATCH] Fix lint --- src/blue_cwl/connectome.py | 23 +++++++++++---------- src/blue_cwl/staging.py | 23 +++++++-------------- tests/unit/core/data/use_cases/copy_file.py | 1 - tests/unit/core/test_use_cases.py | 22 ++++++++++---------- 4 files changed, 30 insertions(+), 39 deletions(-) diff --git a/src/blue_cwl/connectome.py b/src/blue_cwl/connectome.py index 241318e..67ea073 100644 --- a/src/blue_cwl/connectome.py +++ b/src/blue_cwl/connectome.py @@ -59,6 +59,8 @@ are added with default values, whereas pathways not in it are removed. """ +# ruff: noqa: D214, D417 + import logging from collections.abc import Callable, Sequence from functools import partial @@ -141,17 +143,14 @@ def assemble_macro_matrix(macro_config: dict) -> pd.DataFrame: Args: macro_config: Materialized macro config with the arrow file paths. + Example: .. code-block:: python { - "initial": { - "connection_strength": "path/to/arrow/file" - }, - "overrides": { - "connection_strength": "path/to/arrow/file" - } + "initial": {"connection_strength": "path/to/arrow/file"}, + "overrides": {"connection_strength": "path/to/arrow/file"}, } Returns: @@ -198,11 +197,12 @@ def assemble_macro_matrix(macro_config: dict) -> pd.DataFrame: @utils.log -def assemble_micro_matrix(micro_config: dict, variant_name) -> pd.DataFrame: +def assemble_micro_matrix(micro_config: dict, variant_name: str) -> pd.DataFrame: """Assemble micro connectome dataframe from the materialized micro config. Args: micro_config: Materialized macro config with the arrow file paths. + Example: .. code-block:: python @@ -257,18 +257,19 @@ def resolve_micro_matrices( Args: micro_config: Materialized macro config with the arrow file paths. + Example: .. code-block:: python { "initial": { - "placeholder__erdos_renyi": path/to/initial/arrow/er_file, - "placeholder__distance_dependent": path/to/initial/arrow/dd_file, + "placeholder__erdos_renyi": path / to / initial / arrow / er_file, + "placeholder__distance_dependent": path / to / initial / arrow / dd_file, }, "overrides": { - "placeholder__erdos_renyi": path/to/overrides/arrow/er_file, - "placeholder__distance_dependent": path/to/overrides/arrow/dd_file, + "placeholder__erdos_renyi": path / to / overrides / arrow / er_file, + "placeholder__distance_dependent": path / to / overrides / arrow / dd_file, }, } diff --git a/src/blue_cwl/staging.py b/src/blue_cwl/staging.py index e40e0c8..3453b09 100644 --- a/src/blue_cwl/staging.py +++ b/src/blue_cwl/staging.py @@ -701,8 +701,8 @@ def materialize_macro_connectome_config( .. code-block:: python { - "initial": {"connection_strength": path/to/initial/arrow/file}, - "overrides": {"connection_strength": path/to/overrides/arrow/file} + "initial": {"connection_strength": path / to / initial / arrow / file}, + "overrides": {"connection_strength": path / to / overrides / arrow / file}, } Note: overrides key is mandatory but can be empty. @@ -768,24 +768,15 @@ def materialize_micro_connectome_config( .. code-block:: python { - "variants": { - "var1": { - "params": { - "weight": { - "default": 1.0 - } - } - } - }, + "variants": {"var1": {"params": {"weight": {"default": 1.0}}}}, "initial": { - "variants": path/to/variants/arrow/file, - "var1": path/to/var1-parameters/arrow/file, + "variants": path / to / variants / arrow / file, + "var1": path / to / var1 - parameters / arrow / file, }, "overrides": { - "variants": path/to/variants-overrides/arrow/file, - "var1": path/to/var1-parameters-overrides/arrow/file, + "variants": path / to / variants - overrides / arrow / file, + "var1": path / to / var1 - parameters - overrides / arrow / file, }, - } Note: overrides key is mandatory but can be empty or include subset of keys in 'initial'. diff --git a/tests/unit/core/data/use_cases/copy_file.py b/tests/unit/core/data/use_cases/copy_file.py index 7084b7a..426021e 100755 --- a/tests/unit/core/data/use_cases/copy_file.py +++ b/tests/unit/core/data/use_cases/copy_file.py @@ -12,7 +12,6 @@ def main(input_file, output_file, overwrite): if __name__ == "__main__": - args = sys.argv[1:] if "--overwrite" in args: diff --git a/tests/unit/core/test_use_cases.py b/tests/unit/core/test_use_cases.py index ba9cc7d..39c5c68 100644 --- a/tests/unit/core/test_use_cases.py +++ b/tests/unit/core/test_use_cases.py @@ -11,18 +11,15 @@ DATA_DIR = Path(__file__).parent / "data" CWL_DIR = DATA_DIR / "use_cases" + @contextlib.contextmanager def definition(definition: str | dict): - with tempfile.NamedTemporaryFile(suffix=".cwl") as tfile: - if isinstance(definition, str): - with open(tfile.name, "w") as file: file.write(definition) else: - write_yaml(data=definition, filepath=tfile.name) yield tfile.name @@ -92,11 +89,10 @@ def test_array_types_tool(): } res = tool.make(input_values=input_values) - assert res.build_command() == 'touch foo.txt -A a b c d -B=c -B=d -B=e -B=f -C=g,h' + assert res.build_command() == "touch foo.txt -A a b c d -B=c -B=d -B=e -B=f -C=g,h" def test_array_types_tool__2(): - content = """ cwlVersion: v1.2 id: foo @@ -130,7 +126,6 @@ def test_array_types_tool__2(): def test_array_types_tool__3(): - content = """ cwlVersion: v1.2 id: foo @@ -162,7 +157,6 @@ def test_array_types_tool__3(): def test_array_types_tool__4(): - content = """ cwlVersion: v1.2 id: foo @@ -209,8 +203,11 @@ def test_array_types_workflow(): s0, s1 = res.steps - assert s0.build_command() == 'touch foo.txt -A a b c d -B=c -B=d -B=e -B=f -C=c_foo,c_bar' - assert s1.build_command() == 'touch foo.txt -A a b c d -B=foo.txt -B=o -B=e.txt -B=f.txt -C=foo.txt,o' + assert s0.build_command() == "touch foo.txt -A a b c d -B=c -B=d -B=e -B=f -C=c_foo,c_bar" + assert ( + s1.build_command() + == "touch foo.txt -A a b c d -B=foo.txt -B=o -B=e.txt -B=f.txt -C=foo.txt,o" + ) def test_copy_file_tool(tmp_path): @@ -236,7 +233,10 @@ def test_copy_file_tool(tmp_path): assert process.outputs == {"output_file": File(path=str(output_file))} - assert process.build_command() == f"python3 {CWL_DIR}/copy_file.py --overwrite {input_file} {output_file}" + assert ( + process.build_command() + == f"python3 {CWL_DIR}/copy_file.py --overwrite {input_file} {output_file}" + ) process.run() assert input_file.read_text() == output_file.read_text()