diff --git a/utils/scatter_plot_plugin/.bumpversion.cfg b/utils/plotting/scatter_plot_tool/.bumpversion.cfg similarity index 100% rename from utils/scatter_plot_plugin/.bumpversion.cfg rename to utils/plotting/scatter_plot_tool/.bumpversion.cfg diff --git a/utils/scatter_plot_plugin/.dockerignore b/utils/plotting/scatter_plot_tool/.dockerignore similarity index 100% rename from utils/scatter_plot_plugin/.dockerignore rename to utils/plotting/scatter_plot_tool/.dockerignore diff --git a/utils/scatter_plot_plugin/.gitignore b/utils/plotting/scatter_plot_tool/.gitignore similarity index 100% rename from utils/scatter_plot_plugin/.gitignore rename to utils/plotting/scatter_plot_tool/.gitignore diff --git a/utils/scatter_plot_plugin/CHANGELOG.md b/utils/plotting/scatter_plot_tool/CHANGELOG.md similarity index 100% rename from utils/scatter_plot_plugin/CHANGELOG.md rename to utils/plotting/scatter_plot_tool/CHANGELOG.md diff --git a/utils/scatter_plot_plugin/Dockerfile b/utils/plotting/scatter_plot_tool/Dockerfile similarity index 87% rename from utils/scatter_plot_plugin/Dockerfile rename to utils/plotting/scatter_plot_tool/Dockerfile index c45d2bfd..21ced2ae 100644 --- a/utils/scatter_plot_plugin/Dockerfile +++ b/utils/plotting/scatter_plot_tool/Dockerfile @@ -1,4 +1,4 @@ -# docker build -f Dockerfile -t mrbrandonwalker/scatter_plot . +# docker build -f Dockerfile -t polusai/scatter-plot-tool . FROM condaforge/mambaforge ENV EXEC_DIR="/opt/executables" diff --git a/utils/scatter_plot_plugin/README.md b/utils/plotting/scatter_plot_tool/README.md similarity index 100% rename from utils/scatter_plot_plugin/README.md rename to utils/plotting/scatter_plot_tool/README.md diff --git a/utils/scatter_plot_plugin/VERSION b/utils/plotting/scatter_plot_tool/VERSION similarity index 100% rename from utils/scatter_plot_plugin/VERSION rename to utils/plotting/scatter_plot_tool/VERSION diff --git a/utils/plotting/scatter_plot_tool/build-docker.sh b/utils/plotting/scatter_plot_tool/build-docker.sh new file mode 100644 index 00000000..a9adc3f0 --- /dev/null +++ b/utils/plotting/scatter_plot_tool/build-docker.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +version=$( None: + """scatter_plot.""" + logger.info(f"xs: {xs}") + logger.info(f"ys: {ys}") + logger.info(f"ys2: {ys2}") + logger.info(f"output_png_path: {output_png_path}") + + scatter_plot(xs=xs, ys=ys, ys2=ys2, output_png_path=output_png_path) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="scatter_plot") + parser.add_argument( + "--xs", + type=float, + nargs="+", + required=True, + help="List of x values", + ) + parser.add_argument( + "--ys", + type=float, + nargs="+", + required=True, + help="List of y values", + ) + parser.add_argument( + "--ys2", + type=float, + nargs="+", + help="Optional second list of y values", + ) + parser.add_argument( + "--output_png_path", + type=str, + required=True, + help="Path to the output \ + png file", + ) + + args = parser.parse_args() + + main(xs=args.xs, ys=args.ys, ys2=args.ys2, output_png_path=args.output_png_path) diff --git a/utils/scatter_plot_plugin/src/polus/mm/utils/scatter_plot/scatter_plot.py b/utils/plotting/scatter_plot_tool/src/polus/mm/utils/scatter_plot/scatter_plot.py similarity index 100% rename from utils/scatter_plot_plugin/src/polus/mm/utils/scatter_plot/scatter_plot.py rename to utils/plotting/scatter_plot_tool/src/polus/mm/utils/scatter_plot/scatter_plot.py diff --git a/utils/scatter_plot_plugin/tests/__init__.py b/utils/plotting/scatter_plot_tool/tests/__init__.py similarity index 100% rename from utils/scatter_plot_plugin/tests/__init__.py rename to utils/plotting/scatter_plot_tool/tests/__init__.py diff --git a/utils/plotting/scatter_plot_tool/tests/test_scatter_plot.py b/utils/plotting/scatter_plot_tool/tests/test_scatter_plot.py new file mode 100644 index 00000000..45e2bc5d --- /dev/null +++ b/utils/plotting/scatter_plot_tool/tests/test_scatter_plot.py @@ -0,0 +1,37 @@ +"""Tests for scatter_plot.""" +from pathlib import Path + +from polus.mm.utils.scatter_plot.scatter_plot import scatter_plot +from sophios.api.pythonapi import Step +from sophios.api.pythonapi import Workflow + + +def test_scatter_plot() -> None: + """Test scatter_plot.""" + scatter_plot([1, 2, 3], [1, 2, 3], [], "test.png") + assert Path("test.png").exists() + + +def test_duplicate() -> None: + """Test scatter plot CWL.""" + cwl_file_str = "scatter_plot_0@1@0.cwl" + cwl_file = Path(__file__).resolve().parent.parent / Path(cwl_file_str) + + scatter_plot = Step(clt_path=cwl_file) + scatter_plot.xs = [1, 2, 3] + scatter_plot.ys = [1, 2, 3] + scatter_plot.ys2 = [1, 2, 3] + scatter_plot.output_png_path = "test.png" + + steps = [scatter_plot] + filename = "scatter_plot" + viz = Workflow(steps, filename) + + viz.run() + + outdir = Path("outdir") + files = list(outdir.rglob("test.png")) + + assert ( + files + ), f"The file 'test.png' does not exist in any subdirectory of '{outdir}'." diff --git a/utils/scatter_plot_plugin/src/polus/mm/utils/scatter_plot/__main__.py b/utils/scatter_plot_plugin/src/polus/mm/utils/scatter_plot/__main__.py deleted file mode 100644 index c61bdb85..00000000 --- a/utils/scatter_plot_plugin/src/polus/mm/utils/scatter_plot/__main__.py +++ /dev/null @@ -1,54 +0,0 @@ -"""Package entrypoint for the scatter_plot package.""" - -# Base packages -import logging -from os import environ - -import typer -from polus.mm.utils.scatter_plot.scatter_plot import scatter_plot - -logging.basicConfig( - format="%(asctime)s - %(name)-8s - %(levelname)-8s - %(message)s", - datefmt="%d-%b-%y %H:%M:%S", -) -POLUS_LOG = getattr(logging, environ.get("POLUS_LOG", "INFO")) -logger = logging.getLogger("polus.mm.utils.scatter_plot.") -logger.setLevel(POLUS_LOG) - -app = typer.Typer(help="scatter_plot.") - - -@app.command() -def main( - xs: list[float] = typer.Option( - ..., - "--xs", - help="", - ), - ys: list[float] = typer.Option( - ..., - "--ys", - help="", - ), - ys2: list[float] = typer.Option( - None, - "--ys2", - help="", - ), - output_png_path: str = typer.Option( - ..., - "--output_png_path", - help="Path to the output png file", - ), -) -> None: - """scatter_plot.""" - logger.info(f"xs: {xs}") - logger.info(f"ys: {ys}") - logger.info(f"ys2: {ys2}") - logger.info(f"output_png_path: {output_png_path}") - - scatter_plot(xs=xs, ys=ys, ys2=ys2, output_png_path=output_png_path) - - -if __name__ == "__main__": - app() diff --git a/utils/scatter_plot_plugin/tests/test_scatter_plot.py b/utils/scatter_plot_plugin/tests/test_scatter_plot.py deleted file mode 100644 index 1db6cd08..00000000 --- a/utils/scatter_plot_plugin/tests/test_scatter_plot.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Tests for scatter_plot.""" -import sys -from pathlib import Path - -from polus.mm.utils.scatter_plot.scatter_plot import scatter_plot - -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_scatter_plot() -> None: - """Test scatter_plot.""" - scatter_plot([1, 2, 3], [1, 2, 3], [], "test.png") - assert Path("test.png").exists() - - -def test_duplicate() -> None: - """Test pdb.""" - cwl_file_str = "scatter_plot.cwl" - cwl_file = Path(__file__).resolve().parent.parent / Path(cwl_file_str) - input_to_props = parse_cwl_arguments(cwl_file) - input_to_props["xs"] = [1, 2, 3] - input_to_props["ys"] = [1, 2, 3] - input_to_props["output_png_path"] = "test.png" - input_yaml_path = Path("scatter_plot.yml") - create_input_yaml(input_to_props, input_yaml_path) - - call_cwltool(cwl_file, input_yaml_path) - assert Path("test.png").exists()