Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/ci_send_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ jobs:
sender_repo_owner: ${{ github.event.pull_request.head.repo.owner.login }}
sender_repo_ref: ${{ github.event.pull_request.head.ref }}
commit_message: ${{ env.commit_message }}
target_repository: workflow-inference-compiler
access_token: ${{ steps.generate_token.outputs.token }}
target_repository: sophios
access_token: ${{ steps.generate_token.outputs.token }}
4 changes: 2 additions & 2 deletions .github/workflows/ci_send_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
sender_repo_owner: ${{ github.repository_owner }}
sender_repo_ref: ${{ github.ref_name }}
commit_message: ${{ github.event.head_commit.message }}
target_repository: workflow-inference-compiler
access_token: ${{ steps.generate_token.outputs.token }}
target_repository: sophios
access_token: ${{ steps.generate_token.outputs.token }}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
__pycache__/
*.py[cod]

.mypy_cache/
.pytest_cache/

autogenerated/
provenance/
output_*.json
15 changes: 8 additions & 7 deletions workflows/bbbc.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from pathlib import Path

from sophios.apis.python.api import Step, Workflow
from sophios.api.python.workflow import Step, Workflow


def workflow() -> Workflow:
bbbcdownload = Step(clt_path='../image-workflows/cwl_adapters/bbbcdownload.cwl')
bbbcdownload = Step(clt_path='cwl_adapters/bbbcdownload.cwl')
# NOTE: object fields monkey patched at runtime from *.cwl file
bbbcdownload.name = 'BBBC001'
bbbcdownload.outDir = Path('bbbcdownload.outDir')
Expand All @@ -12,30 +13,30 @@ def workflow() -> Workflow:
subdirectory.directory = bbbcdownload.outDir
subdirectory.glob_pattern = 'bbbcdownload.outDir/BBBC/BBBC001/raw/Images/human_ht29_colon_cancer_1_images/'

filerenaming = Step(clt_path='../image-workflows/cwl_adapters/file-renaming.cwl')
filerenaming = Step(clt_path='cwl_adapters/file-renaming.cwl')
# NOTE: FilePattern {} syntax shadows python f-string {} syntax
filerenaming.filePattern = '.*_{row:c}{col:dd}f{f:dd}d{channel:d}.tif'
filerenaming.inpDir = subdirectory.subdirectory
filerenaming.outDir = Path('file-renaming.outDir')
filerenaming.outFilePattern = 'x{row:dd}_y{col:dd}_p{f:dd}_c{channel:d}.tif'

omeconverter = Step(clt_path='../image-workflows/cwl_adapters/ome-converter.cwl')
omeconverter = Step(clt_path='cwl_adapters/ome-converter.cwl')
omeconverter.inpDir = filerenaming.outDir
omeconverter.filePattern = '.*.tif'
omeconverter.outDir = Path('omeconverter.outDir')

montage = Step(clt_path='../image-workflows/cwl_adapters/montage.cwl')
montage = Step(clt_path='cwl_adapters/montage.cwl')
montage.inpDir = omeconverter.outDir
montage.filePattern = 'x00_y03_p{p:dd}_c0.ome.tif'
montage.layout = 'p'
montage.outDir = Path('montage.outDir')

image_assembler = Step(clt_path='../image-workflows/cwl_adapters/image_assembler.cwl')
image_assembler = Step(clt_path='cwl_adapters/image_assembler.cwl')
image_assembler.stitchPath = montage.outDir
image_assembler.imgPath = omeconverter.outDir
image_assembler.outDir = Path('image_assembler.outDir')

precompute_slide = Step(clt_path='../image-workflows/cwl_adapters/precompute_slide.cwl')
precompute_slide = Step(clt_path='cwl_adapters/precompute_slide.cwl')
precompute_slide.inpDir = image_assembler.outDir
precompute_slide.pyramidType = 'Zarr'
precompute_slide.imageType = 'image'
Expand Down
51 changes: 14 additions & 37 deletions workflows/bbbc_sub.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from pathlib import Path

from sophios import plugins
from sophios.apis.python import api
from sophios.apis.python.api import Step, Workflow
from sophios.api.python.workflow import Step, Workflow


def workflow() -> Workflow:
bbbcdownload = Step(clt_path='cwl_adapters/bbbcdownload.cwl')
# NOTE: object fields monkey patched at runtime from *.cwl file
bbbcdownload.name = 'BBBC001'
bbbcdownload.outDir = Path('bbbcdownload.outDir')

subdirectory = Step(clt_path='../workflow-inference-compiler/cwl_adapters/subdirectory.cwl')
subdirectory = Step(clt_path='../sophios/cwl_adapters/subdirectory.cwl')
subdirectory.directory = bbbcdownload.outDir
subdirectory.glob_pattern = 'bbbcdownload.outDir/BBBC/BBBC001/raw/Images/human_ht29_colon_cancer_1_images/'

Expand All @@ -21,14 +20,8 @@ def workflow() -> Workflow:
filerenaming.outDir = Path('file-renaming.outDir')
filerenaming.outFilePattern = 'x{row:dd}_y{col:dd}_p{f:dd}_c{channel:d}.tif'

# Trivially wrap the subdirectory step in a subworkflow.
# But notice that we are still linking the individual Steps above,
# which defeats the whole purpose of having reusable black boxes.
steps = [bbbcdownload,
Workflow([subdirectory], 'bbbc_sub_sub_py'),
filerenaming]
filename = 'bbbc_sub_py' # .yml
return Workflow(steps, filename)
steps = [bbbcdownload, subdirectory, filerenaming]
return Workflow(steps, 'bbbc_sub_py')


def workflow2() -> Workflow:
Expand All @@ -37,40 +30,24 @@ def workflow2() -> Workflow:
bbbcdownload.name = 'BBBC001'
bbbcdownload.outDir = Path('bbbcdownload.outDir')

subdirectory = Step(clt_path='../workflow-inference-compiler/cwl_adapters/subdirectory.cwl')
subworkflow = Workflow([subdirectory], 'bbbc_sub_sub_py') # fails validation, due to
# https://workflow-inference-compiler.readthedocs.io/en/latest/dev/algorithms.html#deferred-satisfaction

# First link all inputs within the subworkflow to the explicit inputs: tag.
# i.e. This is the API for the subworkflow.
subworkflow.steps[0].directory = subworkflow.directory
subworkflow.steps[0].glob_pattern = subworkflow.glob_pattern

# Then apply arguments at the call site.
# Notice how the caller does not need to know about the internal details of the subworkflow
# (For example, that the subdirectory step is index 0)
subworkflow.directory = bbbcdownload.outDir
subworkflow.glob_pattern = 'bbbcdownload.outDir/BBBC/BBBC001/raw/Images/human_ht29_colon_cancer_1_images/'
subdirectory = Step(clt_path='../sophios/cwl_adapters/subdirectory.cwl')
subworkflow = Workflow([subdirectory], 'bbbc_sub_sub_py')
subdirectory.inputs.directory = subworkflow.inputs.directory
subdirectory.inputs.glob_pattern = subworkflow.inputs.glob_pattern
# Intentionally leave directory unbound; Sophios infers it from bbbcdownload.outDir.
subworkflow.inputs.glob_pattern = 'bbbcdownload.outDir/BBBC/BBBC001/raw/Images/human_ht29_colon_cancer_1_images/'

filerenaming = Step(clt_path='cwl_adapters/file-renaming.cwl')
# NOTE: FilePattern {} syntax shadows python f-string {} syntax
filerenaming.filePattern = '.*_{row:c}{col:dd}f{f:dd}d{channel:d}.tif'
filerenaming.inpDir = subworkflow.steps[0].subdirectory # TODO: workflow outputs: tag
# Intentionally leave inpDir unbound; Sophios infers it from the preceding subworkflow output.
filerenaming.outDir = Path('file-renaming.outDir')
filerenaming.outFilePattern = 'x{row:dd}_y{col:dd}_p{f:dd}_c{channel:d}.tif'

steps = [bbbcdownload,
subworkflow,
filerenaming]
filename = 'bbbc_sub_py' # .yml
return Workflow(steps, filename)
steps = [bbbcdownload, subworkflow, filerenaming]
return Workflow(steps, 'bbbc_sub_py')


# viz = workflow()
# viz.compile() # Do NOT .run() here

if __name__ == '__main__':
api.global_config = plugins.get_tools_cwl(str(Path().home())) # Use path fallback

viz = workflow2()
viz.run() # .run() here, inside main
Loading