-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6797543
commit 228aa4e
Showing
10 changed files
with
401 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM docker.io/eoepca/cwl-wrapper@sha256:066566ab6dcee685bb95d4eeab20ef07eefc5aaaf320857a251a3a608c81e694 | ||
|
||
COPY cwl-wrapper/templates /templates | ||
|
||
COPY cwl-wrapper/default.conf /home/jovyan/.cwlwrapper/default.conf | ||
|
||
ENTRYPOINT [ "cwl-wrapper" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
docker run --rm -i cwl-wrapper:latest $PWD:/app-package eoepca/ | ||
|
||
docker run --rm -i -v $PWD:/app cwl-wrapper:latest --stagein /app/stage/stage-in.yaml --stageout /app/stage/stage-out.yaml app/app-water-bodies.1.3.1.cwl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
maincwl="/templates/main.yaml" | ||
rulez="/templates/rules.yaml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class: Workflow | ||
doc: Main stage manager | ||
id: main | ||
label: macro-cwl | ||
inputs: {} | ||
outputs: {} | ||
|
||
requirements: | ||
SubworkflowFeatureRequirement: {} | ||
ScatterFeatureRequirement: {} | ||
InlineJavascriptRequirement: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
rulez: | ||
version: 1 | ||
|
||
parser: | ||
type: $graph | ||
driver: cwl | ||
|
||
onstage: | ||
driver: cwl | ||
|
||
stage_in: | ||
connection_node: node_stage_in | ||
if_scatter: | ||
scatterMethod: dotproduct | ||
input: | ||
template: | ||
overwrite: True | ||
|
||
on_stage: | ||
connection_node: on_stage | ||
|
||
stage_out: | ||
connection_node: node_stage_out | ||
scatter: False | ||
if_scatter: | ||
scatterMethod: dotproduct | ||
follow_node: node_metrics_out | ||
|
||
|
||
output: | ||
driver: cwl | ||
name: '-' | ||
type: $graph | ||
|
||
|
||
cwl: | ||
GlobalInput: | ||
Directory: string | ||
Directory[]: string[] | ||
|
||
OptionalInput: | ||
Directory: string? | ||
Directory[]: string[]? | ||
|
||
stage_in: | ||
Directory?: | ||
type: string? | ||
|
||
Directory: | ||
type: string? | ||
|
||
Directory[]: | ||
type: string[] | ||
|
||
stage_out: | ||
Directory: | ||
type: Directory | ||
|
||
Directory[]: | ||
type: Directory[] | ||
|
||
outputBindingResult: | ||
command: | ||
Directory: | ||
outputBinding: | ||
glob: . | ||
type: Directory | ||
Directory[]: | ||
outputBinding: | ||
glob: . | ||
type: Directory[] | ||
Directory?: | ||
outputBinding: | ||
glob: ${ if (inputs.input == null) {return null } else {return ".";} } | ||
type: Directory? | ||
stepOut: | ||
type: | ||
items: Directory | ||
type: array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
cwlVersion: v1.0 | ||
doc: "Run Stars for staging input data" | ||
class: CommandLineTool | ||
hints: | ||
DockerRequirement: | ||
dockerPull: ghcr.io/terradue/stars:2.14.5 | ||
"cwltool:Secrets": | ||
secrets: [] | ||
|
||
id: stars | ||
requirements: | ||
EnvVarRequirement: | ||
envDef: | ||
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
ResourceRequirement: {} | ||
InlineJavascriptRequirement: {} | ||
InitialWorkDirRequirement: | ||
listing: | ||
- entryname: stagein.sh | ||
entry: |- | ||
#!/bin/bash | ||
set -x | ||
res=0 | ||
input='$( inputs.input )' | ||
usersettings='$( inputs.usersettings.path )' | ||
|
||
[ "\${input}" != "null" ] && { | ||
|
||
IFS='#' read -r -a reference <<< '$( inputs.input )' | ||
input_len=\${#reference[@]} | ||
|
||
[[ \${input_len} == 2 ]] && { | ||
IFS=',' read -r -a assets <<< \${reference[1]} | ||
af=" " | ||
for asset in \${assets[@]} | ||
do | ||
af="\${af} -af \${asset}" | ||
done | ||
} || { | ||
af="--empty" | ||
} | ||
Stars copy -conf \${usersettings} -v -rel -r '4' \${af} -o ./ \${reference[0]} | ||
res=$? | ||
} | ||
rm -fr stagein.sh | ||
exit 0 | ||
|
||
baseCommand: ['/bin/bash', 'stagein.sh'] | ||
|
||
inputs: {} | ||
|
||
outputs: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM docker.io/python:3.9.18-slim-bullseye | ||
|
||
RUN pip install --no-cache-dir --upgrade pip stac-asset boto3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env cwl-runner | ||
|
||
cwlVersion: v1.0 | ||
|
||
class: CommandLineTool | ||
id: stage | ||
|
||
inputs: {} | ||
|
||
outputs: {} | ||
|
||
baseCommand: | ||
- python | ||
- stage.py | ||
arguments: | ||
- $( inputs.input ) | ||
|
||
requirements: | ||
DockerRequirement: | ||
dockerPull: stac-asset:latest | ||
EnvVarRequirement: | ||
envDef: | ||
A: "2" | ||
InlineJavascriptRequirement: {} | ||
InitialWorkDirRequirement: | ||
listing: | ||
- entryname: stage.py | ||
entry: |- | ||
import pystac | ||
import stac_asset | ||
import asyncio | ||
import os | ||
import sys | ||
|
||
config = stac_asset.Config(warn=True) | ||
|
||
async def main(href: str): | ||
|
||
item = pystac.read_file(href) | ||
|
||
os.makedirs(item.id, exist_ok=True) | ||
cwd = os.getcwd() | ||
|
||
os.chdir(item.id) | ||
item = await stac_asset.download_item(item=item, directory=".", config=config) | ||
os.chdir(cwd) | ||
|
||
cat = pystac.Catalog( | ||
id="catalog", | ||
description=f"catalog with staged {item.id}", | ||
title=f"catalog with staged {item.id}", | ||
) | ||
cat.add_item(item) | ||
|
||
cat.normalize_hrefs("./") | ||
cat.save(catalog_type=pystac.CatalogType.SELF_CONTAINED) | ||
|
||
return cat | ||
|
||
href = sys.argv[1] | ||
|
||
cat = asyncio.run(main(href)) | ||
|
||
|
||
|
Oops, something went wrong.