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

Remove duplicate functions due to libraries merging #18

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/blue_cwl/core/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from blue_cwl.core.exceptions import CWLError
from blue_cwl.core.executor import LocalExecutor, SallocExecutor
from blue_cwl.core.types import PathLike
from blue_cwl.core.utils import load_yaml, resolve_path
from blue_cwl.core.validate import validate_workflow
from blue_cwl.utils import load_yaml, resolve_path

L = logging.getLogger(__name__)

Expand Down
121 changes: 0 additions & 121 deletions src/blue_cwl/core/utils.py

This file was deleted.

8 changes: 8 additions & 0 deletions src/blue_cwl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,11 @@ def get_obj(
if isinstance(obj, str):
return get_entity(resource_id=obj, cls=cls, base=base, org=org, proj=proj, token=token)
return obj


def resolve_path(path: StrOrPath, base_dir: StrOrPath | None = None) -> Path:
"""Resolve path if it's relative wrt base_dir if given."""
if base_dir is not None:
return Path(base_dir, path).resolve()

return Path(path).resolve()
2 changes: 1 addition & 1 deletion tests/unit/core/test_cwl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from blue_cwl.core.cwl_types import File, Directory, CWLType
from blue_cwl.core.exceptions import CWLError

from blue_cwl.core import utils
from blue_cwl import utils
from blue_cwl.core import parse_cwl_file

DATA_DIR = Path(__file__).parent / "data"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/core/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from blue_cwl.core import cwl
from blue_cwl.core.exceptions import CWLError, CWLValidationError
from blue_cwl.core.executor import LocalExecutor, SallocExecutor
from blue_cwl.core import utils
from blue_cwl import utils


TESTS_DIR = Path(__file__).parent
Expand Down
34 changes: 26 additions & 8 deletions tests/unit/core/test_use_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
from blue_cwl.core import parse_cwl_file
from blue_cwl.core.cwl_types import Directory, CWLType, File, NexusResource
from blue_cwl.core.utils import cwd
from blue_cwl.utils import cwd
from blue_cwl.core import cwl

import pytest
Expand Down Expand Up @@ -62,7 +62,10 @@ def test_essential_parameters():
"example_float": 3.2,
}
res = tool.make(input_values=input_values)
assert res.build_command() == "echo -f -i42 -d3.2 --file=whale.txt --example-string hello"
assert (
res.build_command()
== "echo -f -i42 -d3.2 --file=whale.txt --example-string hello"
)


def test_array_types_tool():
Expand Down Expand Up @@ -214,7 +217,9 @@ def test_copy_file_workflow(tmp_path, cwl_file):
)
s3.run()

assert Path(process.outputs["output_file"].path).read_text() == input_file.read_text()
assert (
Path(process.outputs["output_file"].path).read_text() == input_file.read_text()
)


def test_generator_tool():
Expand Down Expand Up @@ -317,15 +322,20 @@ def test_generator_workflow():
"cell_composition": NexusResource(id="my-composition-id"),
"output_dir": Directory(path="my-output-dir"),
}
assert s1.outputs == {"staged_resource": File(path="my-output-dir/staged_resource.json")}
assert s1.outputs == {
"staged_resource": File(path="my-output-dir/staged_resource.json")
}
assert s1.base_command == [
"blue-cwl",
"stage",
"cell-composition",
"my-composition-id",
"my-output-dir",
]
assert s1.environment == {"env_type": "MODULE", "modules": ["unstable", "py-blue-cwl"]}
assert s1.environment == {
"env_type": "MODULE",
"modules": ["unstable", "py-blue-cwl"],
}
assert s1.executor.to_dict() == {
"env_vars": {"FOO": "foo"},
"remote_config": {"host": "bbpv1.epfl.ch"},
Expand Down Expand Up @@ -361,8 +371,13 @@ def test_generator_workflow():
"variant_config": NexusResource(id="my-config-id"),
"output_dir": Directory(path="my-output-dir"),
}
assert s2.outputs == {"staged_resource": File(path="my-output-dir/staged_resource.json")}
assert s2.environment == {"env_type": "MODULE", "modules": ["unstable", "py-blue-cwl"]}
assert s2.outputs == {
"staged_resource": File(path="my-output-dir/staged_resource.json")
}
assert s2.environment == {
"env_type": "MODULE",
"modules": ["unstable", "py-blue-cwl"],
}
assert s2.base_command == [
"blue-cwl",
"stage",
Expand Down Expand Up @@ -408,7 +423,10 @@ def test_generator_workflow():
}

assert s3.outputs == {"partial_circuit": File(path="my-output-dir/circuit.json")}
assert s3.environment == {"env_type": "MODULE", "modules": ["unstable", "py-blue-cwl"]}
assert s3.environment == {
"env_type": "MODULE",
"modules": ["unstable", "py-blue-cwl"],
}
assert s3.base_command == [
"blue-cwl",
"execute",
Expand Down
69 changes: 0 additions & 69 deletions tests/unit/core/test_utils.py

This file was deleted.

12 changes: 3 additions & 9 deletions tests/unit/test_registering.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def test_brain_location(monkeypatch):
mock_region.get_id.return_value = "foo"
mock_region.label = "bar"

monkeypatch.setattr(
AtlasBrainRegion, "from_id", lambda *args, **kwargs: mock_region
)
monkeypatch.setattr(AtlasBrainRegion, "from_id", lambda *args, **kwargs: mock_region)

payload = {
"@id": "foo",
Expand Down Expand Up @@ -424,17 +422,13 @@ def upload_file(name, data, *args, **kwargs):
"@id": "http://bbp.epfl.ch/neurosciencegraph/ontologies/etypes/Foo",
"label": "Foo",
"about": ["https://neuroshapes.org/EType"],
"hasPart": [
{"@type": "METypeDensity", "@id": "foo-id", "_rev": 2}
],
"hasPart": [{"@type": "METypeDensity", "@id": "foo-id", "_rev": 2}],
},
{
"@id": "http://bbp.epfl.ch/neurosciencegraph/ontologies/etypes/Bar",
"label": "Bar",
"about": ["https://neuroshapes.org/EType"],
"hasPart": [
{"@id": "bar-id", "_rev": 1, "@type": "METypeDensity"}
],
"hasPart": [{"@id": "bar-id", "_rev": 1, "@type": "METypeDensity"}],
},
],
}
Expand Down
Loading
Loading