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

refactor check_linear_fit #154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 utils/fitting/check-linear-fit-tool/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# docker build -f Dockerfile -t mrbrandonwalker/check_linear_fit .
# docker build -f Dockerfile -t polusai/check-linear-fit-tool .
FROM condaforge/mambaforge

ENV EXEC_DIR="/opt/executables"
Expand Down
15 changes: 7 additions & 8 deletions utils/fitting/check-linear-fit-tool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ check_linear_fit

## Options

This plugin takes 6 input arguments and 1 output argument:
This plugin takes 5 input arguments and 1 output argument:

| Name | Description | I/O | Type | Default |
|---------------|-------------------------|--------|--------|---------|
| script | | Input | string | string |
| xs | | Input | {'type': 'array', 'items': 'float'} | {'type': 'array', 'items': 'float'} |
| ys | | Input | {'type': 'array', 'items': 'float'} | {'type': 'array', 'items': 'float'} |
| tol_quad | | Input | float | float |
| slope_min | | Input | float | float |
| slope_max | | Input | float | float |
| success | | Output | boolean | boolean |
| xs | x-axis input array | Input | {'type': 'array', 'items': 'float'} | {'type': 'array', 'items': 'float'} |
| ys | y-axis input array | Input | {'type': 'array', 'items': 'float'} | {'type': 'array', 'items': 'float'} |
| tol_quad | Quadratic tolerance term for determining if fit is linear | Input | float | float |
| slope_min | Min slope cut off | Input | float | float |
| slope_max | Max slope cut off | Input | float | float |
| success | Whether fit was successful or not | Output | boolean | boolean |
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ baseCommand: ["python", "-m", "polus.mm.utils.check_linear_fit"]

requirements:
DockerRequirement:
dockerPull: mrbrandonwalker/check_linear_fit
dockerPull: polusai/check-linear-fit-tool@sha256:20c3056601a244cfde2878cfe04ffc210ee7de6062065cbefe2a8fa0a69d4a0e
InlineJavascriptRequirement: {}

inputs:
Expand Down
4 changes: 2 additions & 2 deletions utils/fitting/check-linear-fit-tool/ict.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ container: check-linear-fit-tool
entrypoint:
title: check_linear_fit
description: check_linear_fit
author: Data Scientist
contact: [email protected]
author: Brandon Walker, Nazanin Donyapour
contact: [email protected], [email protected]
repository:
documentation:
citation:
Expand Down
44 changes: 23 additions & 21 deletions utils/fitting/check-linear-fit-tool/tests/test_check_linear_fit.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
"""Tests for check_linear_fit."""
import sys
from pathlib import Path

from polus.mm.utils.check_linear_fit.check_linear_fit import check_linear_fit

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
from sophios.api.pythonapi import Step
from sophios.api.pythonapi import Workflow


def test_check_linear_fit() -> None:
Expand Down Expand Up @@ -38,20 +31,29 @@ def test_check_linear_fit_out_of_bounds() -> None:

def test_check_linear_fit_cwl() -> None:
"""Test check_linear_fit CWL."""
# Define the input parameters
xs = [1.0, 2.0, 3.0]
ys = [1.0, 2.0, 3.0]
tol_quad = 0.1
slope_min = 0.5
slope_max = 1.5
cwl_file = Path("check_linear_fit.cwl")
input_to_props = parse_cwl_arguments(cwl_file)
input_to_props["xs"] = xs
input_to_props["ys"] = ys
input_to_props["tol_quad"] = tol_quad
input_to_props["slope_min"] = slope_min
input_to_props["slope_max"] = slope_max

input_yaml_path = Path("check_linear_fit-sfct.yml")
create_input_yaml(input_to_props, input_yaml_path)
stdout, stderr = call_cwltool(cwl_file, input_yaml_path)
assert "success" in stdout

# Define paths
cwl_file_str = "check_linear_fit_0@[email protected]"
cwl_file = Path(__file__).resolve().parent.parent / Path(cwl_file_str)

# Create the CWL step
check_linear_fit_step = Step(clt_path=cwl_file)
check_linear_fit_step.xs = xs
check_linear_fit_step.ys = ys
check_linear_fit_step.tol_quad = tol_quad
check_linear_fit_step.slope_min = slope_min
check_linear_fit_step.slope_max = slope_max

# Create the workflow and run it
steps = [check_linear_fit_step]
filename = "check_linear_fit_workflow"
workflow = Workflow(steps, filename)
workflow.run()

# cant check output because it is a boolean and no way to capture stdout
Loading