Skip to content

Commit

Permalink
zip: fix local WDL importing URI (#610 @yunhailuo)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Nov 2, 2022
1 parent 5d35e53 commit 936ae5f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion WDL/Zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def build_zip_paths(
# place outside import under __outside_wdl, vaguely reproducing directory structure
abspath2 = abspath.replace("://", "_")
prefix = os.path.commonprefix([abspath2, main_dir.replace("://", "_")])
assert abspath2.startswith(prefix) and prefix.endswith("/")
assert not prefix or (abspath2.startswith(prefix) and prefix.endswith("/"))
ans[abspath] = "__outside_wdl/" + abspath2[len(prefix) :]
outside_warn = True
logger.info(f"{ans[abspath]} <= {abspath}")
Expand Down
24 changes: 23 additions & 1 deletion tests/zip.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ workflow w {
}
EOF

plan tests 9
plan tests 11

$miniwdl zip -o outer.wdl.zip wdl/wf/outer.wdl --input ' {"w.who": "Alice"}' --debug
is "$?" "0" "build zip"
Expand All @@ -69,3 +69,25 @@ is "$(jq -r '.outputs["w.hello.message"]' out)" "Hello, Bob!" "run zip output 2"
$miniwdl run outer.wdl.zip -i '{"w.who": "Carol"}' | tee out
is "$?" "0" "run zip with input override file"
is "$(jq -r '.outputs["w.hello.message"]' out)" "Hello, Carol!" "run zip output 3"

# issue #610 regression test
mkdir -p issue610/wdl/tasks
curl -Ls https://raw.githubusercontent.com/openwdl/learn-wdl/9d05365/1_script_examples/1_hello_worlds/1_hello/hello.wdl > issue610/hello1.wdl
cp issue610/hello1.wdl issue610/wdl/tasks/hello2.wdl
cat << 'EOF' > issue610/wdl/test_miniwdl_zip.wdl
version 1.0
import "../hello1.wdl"
import "../wdl/tasks/hello2.wdl" as hello_b
import "https://raw.githubusercontent.com/openwdl/learn-wdl/9d05365/1_script_examples/1_hello_worlds/1_hello/hello.wdl"
workflow HelloWorld {
call hello_b.WriteGreeting
}
EOF
$miniwdl zip -o issue610.zip issue610/wdl/test_miniwdl_zip.wdl --debug
is "$?" "0" "issue 610 (zip)"
mkdir __extract610
env -C __extract610 unzip ../issue610.zip
$miniwdl check __extract610/test_miniwdl_zip.wdl
is "$?" "0" "issue 610 (check)"

0 comments on commit 936ae5f

Please sign in to comment.