From fac8b9af51fb80f45ea2607a0041621730c82756 Mon Sep 17 00:00:00 2001 From: Brandon Duane Walker Date: Mon, 3 Jun 2024 13:44:08 -0400 Subject: [PATCH] refactor filter-array --- .../tests/test_filter_array.py | 28 ------------------- .../filter-array-tool}/.bumpversion.cfg | 0 .../filter-array-tool}/.dockerignore | 0 .../filter-array-tool}/.gitignore | 0 .../filter-array-tool}/CHANGELOG.md | 0 .../array-subset/filter-array-tool}/README.md | 0 .../array-subset/filter-array-tool}/VERSION | 0 .../filter-array-tool/filter_array_0@1@0.cwl} | 0 .../array-subset/filter-array-tool}/ict.yml | 6 ++-- .../filter-array-tool}/pyproject.toml | 3 +- .../filter-array-tool}/tests/__init__.py | 0 .../tests/test_filter_array.py | 27 ++++++++++++++++++ 12 files changed, 31 insertions(+), 33 deletions(-) delete mode 100644 utils/filter-array-plugin/tests/test_filter_array.py rename utils/{filter-array-plugin => post-process/array-subset/filter-array-tool}/.bumpversion.cfg (100%) rename utils/{filter-array-plugin => post-process/array-subset/filter-array-tool}/.dockerignore (100%) rename utils/{filter-array-plugin => post-process/array-subset/filter-array-tool}/.gitignore (100%) rename utils/{filter-array-plugin => post-process/array-subset/filter-array-tool}/CHANGELOG.md (100%) rename utils/{filter-array-plugin => post-process/array-subset/filter-array-tool}/README.md (100%) rename utils/{filter-array-plugin => post-process/array-subset/filter-array-tool}/VERSION (100%) rename utils/{filter-array-plugin/filter_array.cwl => post-process/array-subset/filter-array-tool/filter_array_0@1@0.cwl} (100%) rename utils/{filter-array-plugin => post-process/array-subset/filter-array-tool}/ict.yml (81%) rename utils/{filter-array-plugin => post-process/array-subset/filter-array-tool}/pyproject.toml (91%) rename utils/{filter-array-plugin => post-process/array-subset/filter-array-tool}/tests/__init__.py (100%) create mode 100644 utils/post-process/array-subset/filter-array-tool/tests/test_filter_array.py diff --git a/utils/filter-array-plugin/tests/test_filter_array.py b/utils/filter-array-plugin/tests/test_filter_array.py deleted file mode 100644 index 4c3fa105..00000000 --- a/utils/filter-array-plugin/tests/test_filter_array.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Tests for filter_array.""" -import json -import sys -from pathlib import Path - -current_dir = Path(__file__).resolve().parent -target_dir = current_dir.parent.parent.parent / "cwl_utils" -sys.path.append(str(target_dir)) - -from cwl_utilities import call_cwltool # noqa: E402 -from cwl_utilities import create_input_yaml # noqa: E402 -from cwl_utilities import parse_cwl_arguments # noqa: E402 - - -def test_filter_array() -> None: - """Test filter_array.""" - cwl_file_str = "filter_array.cwl" - cwl_file = Path(__file__).resolve().parent.parent / Path(cwl_file_str) - input_to_props = parse_cwl_arguments(cwl_file) - input_to_props["input_array"] = [1, 2, 3] - input_to_props["input_bool_array"] = [False, True, False] - input_yaml_path = Path("filter_array.yml") - create_input_yaml(input_to_props, input_yaml_path) - - stdout_output, stderr = call_cwltool(cwl_file, input_yaml_path) - output_dict = json.loads(stdout_output) - output_array = output_dict.get("output_array", []) - assert output_array == [2] diff --git a/utils/filter-array-plugin/.bumpversion.cfg b/utils/post-process/array-subset/filter-array-tool/.bumpversion.cfg similarity index 100% rename from utils/filter-array-plugin/.bumpversion.cfg rename to utils/post-process/array-subset/filter-array-tool/.bumpversion.cfg diff --git a/utils/filter-array-plugin/.dockerignore b/utils/post-process/array-subset/filter-array-tool/.dockerignore similarity index 100% rename from utils/filter-array-plugin/.dockerignore rename to utils/post-process/array-subset/filter-array-tool/.dockerignore diff --git a/utils/filter-array-plugin/.gitignore b/utils/post-process/array-subset/filter-array-tool/.gitignore similarity index 100% rename from utils/filter-array-plugin/.gitignore rename to utils/post-process/array-subset/filter-array-tool/.gitignore diff --git a/utils/filter-array-plugin/CHANGELOG.md b/utils/post-process/array-subset/filter-array-tool/CHANGELOG.md similarity index 100% rename from utils/filter-array-plugin/CHANGELOG.md rename to utils/post-process/array-subset/filter-array-tool/CHANGELOG.md diff --git a/utils/filter-array-plugin/README.md b/utils/post-process/array-subset/filter-array-tool/README.md similarity index 100% rename from utils/filter-array-plugin/README.md rename to utils/post-process/array-subset/filter-array-tool/README.md diff --git a/utils/filter-array-plugin/VERSION b/utils/post-process/array-subset/filter-array-tool/VERSION similarity index 100% rename from utils/filter-array-plugin/VERSION rename to utils/post-process/array-subset/filter-array-tool/VERSION diff --git a/utils/filter-array-plugin/filter_array.cwl b/utils/post-process/array-subset/filter-array-tool/filter_array_0@1@0.cwl similarity index 100% rename from utils/filter-array-plugin/filter_array.cwl rename to utils/post-process/array-subset/filter-array-tool/filter_array_0@1@0.cwl diff --git a/utils/filter-array-plugin/ict.yml b/utils/post-process/array-subset/filter-array-tool/ict.yml similarity index 81% rename from utils/filter-array-plugin/ict.yml rename to utils/post-process/array-subset/filter-array-tool/ict.yml index a8716eed..dc9d2c8e 100644 --- a/utils/filter-array-plugin/ict.yml +++ b/utils/post-process/array-subset/filter-array-tool/ict.yml @@ -1,12 +1,12 @@ specVersion: "0.1.0" name: filter_array version: 0.1.0 -container: filter-array-plugin +container: filter-array-tool entrypoint: title: filter_array description: Filter array based on input boolean array -author: Data Scientist -contact: data.scientist@labshare.org +author: Brandon Walker, Nazanin Donyapour +contact: brandon.walker@axleinfo.com, nazanin.donyapour@axleinfo.com repository: documentation: citation: diff --git a/utils/filter-array-plugin/pyproject.toml b/utils/post-process/array-subset/filter-array-tool/pyproject.toml similarity index 91% rename from utils/filter-array-plugin/pyproject.toml rename to utils/post-process/array-subset/filter-array-tool/pyproject.toml index d0c48084..f5b81e45 100644 --- a/utils/filter-array-plugin/pyproject.toml +++ b/utils/post-process/array-subset/filter-array-tool/pyproject.toml @@ -7,8 +7,7 @@ readme = "README.md" [tool.poetry.dependencies] python = ">=3.9,<3.12" -cwl-utils = "0.33" -cwltool = "3.1.20240404144621" +sophios = "0.1.1" [tool.poetry.group.dev.dependencies] bump2version = "^1.0.1" diff --git a/utils/filter-array-plugin/tests/__init__.py b/utils/post-process/array-subset/filter-array-tool/tests/__init__.py similarity index 100% rename from utils/filter-array-plugin/tests/__init__.py rename to utils/post-process/array-subset/filter-array-tool/tests/__init__.py diff --git a/utils/post-process/array-subset/filter-array-tool/tests/test_filter_array.py b/utils/post-process/array-subset/filter-array-tool/tests/test_filter_array.py new file mode 100644 index 00000000..77b227b2 --- /dev/null +++ b/utils/post-process/array-subset/filter-array-tool/tests/test_filter_array.py @@ -0,0 +1,27 @@ +"""Tests for filter_array.""" +from pathlib import Path + +from sophios.api.pythonapi import Step +from sophios.api.pythonapi import Workflow + + +def test_filter_array() -> None: + """Test filter_array.""" + # Define paths and input properties + cwl_file_str = "filter_array_0@1@0.cwl" + cwl_file = Path(__file__).resolve().parent.parent / Path(cwl_file_str) + input_array = [1, 2, 3] + input_bool_array = [False, True, False] + + # Create the CWL step + filter_array_step = Step(clt_path=cwl_file) + filter_array_step.input_array = input_array + filter_array_step.input_bool_array = input_bool_array + + # Create the workflow and run it + steps = [filter_array_step] + filename = "filter_array_workflow" + workflow = Workflow(steps, filename) + workflow.run() + + # cant parse stdout