Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
eleftherioszisis committed Aug 3, 2024
1 parent dcafa86 commit eae9d42
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 39 deletions.
23 changes: 12 additions & 11 deletions src/blue_cwl/connectome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
},
}
Expand Down
23 changes: 7 additions & 16 deletions src/blue_cwl/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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'.
Expand Down
1 change: 0 additions & 1 deletion tests/unit/core/data/use_cases/copy_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def main(input_file, output_file, overwrite):


if __name__ == "__main__":

args = sys.argv[1:]

if "--overwrite" in args:
Expand Down
22 changes: 11 additions & 11 deletions tests/unit/core/test_use_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -130,7 +126,6 @@ def test_array_types_tool__2():


def test_array_types_tool__3():

content = """
cwlVersion: v1.2
id: foo
Expand Down Expand Up @@ -162,7 +157,6 @@ def test_array_types_tool__3():


def test_array_types_tool__4():

content = """
cwlVersion: v1.2
id: foo
Expand Down Expand Up @@ -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):
Expand All @@ -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()
Expand Down

0 comments on commit eae9d42

Please sign in to comment.