Skip to content

Commit

Permalink
Add flag to only compile workflow to cwl without running (#272)
Browse files Browse the repository at this point in the history
* Add flag to only compile workflow to cwl without running

* Switch --generate_cwl_workflow to group_run

* Add test for --generate_cwl_workflow

* Update generate cwl test to use helloworld from tutorials

---------

Co-authored-by: Sameeul Bashir Samee <sameeul@gmail.com>
  • Loading branch information
JesseMckinzie and sameeul authored Oct 3, 2024
1 parent e889cfa commit 1e797b5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/sophios/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
help='After generating the cwl file(s), run it on your local machine.')
group_run.add_argument('--generate_cwl_workflow', required=False, default=False, action="store_true",
help='Compile the workflow without pulling the docker image')

parser.add_argument('--cwl_inline_subworkflows', default=False, action="store_true",
help='Before generating the cwl file, inline all subworkflows.')
parser.add_argument('--inference_disable', default=False, action="store_true",
Expand Down
24 changes: 24 additions & 0 deletions tests/data/cwl/helloworld.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env cwl-runner
# This file was autogenerated using the Workflow Inference Compiler, version 0+unknown
# https://github.com/PolusAI/workflow-inference-compiler
steps:
- id: helloworld__step__1__echo
in:
message:
source: helloworld__step__1__echo___message
run: helloworld__step__1__echo/echo.cwl
out:
- stdout
cwlVersion: v1.2
class: Workflow
$namespaces:
edam: https://edamontology.org/
$schemas:
- https://raw.githubusercontent.com/edamontology/edamontology/master/EDAM_dev.owl
inputs:
helloworld__step__1__echo___message:
type: string
outputs:
helloworld__step__1__echo___stdout:
type: File
outputSource: helloworld__step__1__echo/stdout
35 changes: 35 additions & 0 deletions tests/test_cli_flags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pathlib
import subprocess
import yaml
import shutil

from sophios.main import main
from sophios.cli import get_args


def test_generate_cwl_workflow() -> None:
"""
Test that running sophios with --generate_cwl_workflow produces the correct cwl file
"""
# remove output directory in case it exists to avoid false test pass
out_path = pathlib.Path('autogenerated')

if out_path.exists() and out_path.is_dir():
shutil.rmtree(out_path)

yaml_path = str(pathlib.Path(__file__).parent.parent.resolve() / "docs/tutorials/helloworld.wic")

args = ["sophios", "--yaml", yaml_path, "--generate_cwl_workflow"]

# run sophios with args
subprocess.run(args)

with open("autogenerated/helloworld.cwl", "r") as cwl_file:
result_dict = yaml.safe_load(cwl_file)

with open(
str(pathlib.Path(__file__).parent.resolve() / "data/cwl/helloworld.cwl"), "r"
) as cwl_file:
actual_dict = yaml.safe_load(cwl_file)

assert result_dict == actual_dict

0 comments on commit 1e797b5

Please sign in to comment.