Skip to content

Commit

Permalink
plugins & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Oct 27, 2020
1 parent 1fc5e3e commit 15f07fb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
17 changes: 14 additions & 3 deletions WDL/runtime/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,24 @@ def _parse_list(v: str) -> List[Any]:

DEFAULT_PLUGINS = {
"file_download": [
importlib_metadata.EntryPoint(
group="miniwdl.plugin.file_download",
name="s3",
value="WDL.runtime.download:awscli_downloader",
),
importlib_metadata.EntryPoint(
group="miniwdl.plugin.file_download",
name="gs",
value="WDL.runtime.download:gsutil_downloader",
),
],
"directory_download": [
importlib_metadata.EntryPoint(
group="miniwdl.plugin.directory_download",
name="s3",
value="WDL.runtime.download:awscli_directory_downloader",
)
],
"directory_download": [],
"task": [],
"workflow": [],
"container_backend": [
Expand All @@ -331,8 +342,8 @@ def load_all_plugins(cfg: Loader, group: str) -> Iterable[Tuple[bool, Any]]:
assert group in DEFAULT_PLUGINS.keys(), group
enable_patterns = cfg["plugins"].get_list("enable_patterns")
disable_patterns = cfg["plugins"].get_list("disable_patterns")
for plugin in importlib_metadata.entry_points().get(
f"miniwdl.plugin.{group}", DEFAULT_PLUGINS[group]
for plugin in DEFAULT_PLUGINS[group] + list(
importlib_metadata.entry_points().get(f"miniwdl.plugin.{group}", [])
):
enabled = next(
(pat for pat in enable_patterns if fnmatchcase(plugin.value, pat)), False
Expand Down
3 changes: 1 addition & 2 deletions WDL/runtime/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ def _load(cfg: config.Loader):
"https": aria2c_downloader,
"http": aria2c_downloader,
"ftp": aria2c_downloader,
"s3": awscli_downloader,
}
directory_downloaders = {"s3": awscli_directory_downloader}
directory_downloaders = {}

# plugins
for plugin_name, plugin_fn in config.load_plugins(cfg, "file_download"):
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ packages =
[entry_points]
console_scripts =
miniwdl = WDL.CLI:main
miniwdl.plugin.file_download =
gs = WDL.runtime.download:gsutil_downloader

[pbr]
skip_authors = True
Expand Down
29 changes: 29 additions & 0 deletions tests/test_7runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,35 @@ def test_directory_output(self):
""", {})
assert outp["d_out"] is None

def test_output_input(self):
# test outputting files/subdirectories inside input Directory
wdl = R"""
version development
task t {
input {
Directory d
}
command {}
output {
Array[File] files = ["~{d}/alice.txt", "~{d}/sub/bob.txt"]
Array[Directory] dirs = ["~{d}/sub/dir"]
}
}
"""
os.makedirs(os.path.join(self._dir, "d/sub/dir"))
with open(os.path.join(self._dir, "d/alice.txt"), mode="w") as outfile:
print("Alice", file=outfile)
with open(os.path.join(self._dir, "d/sub/bob.txt"), mode="w") as outfile:
print("Bob", file=outfile)
with open(os.path.join(self._dir, "d/sub/dir/carol.txt"), mode="w") as outfile:
print("Carol", file=outfile)
outp = self._run(wdl, {"d": os.path.join(self._dir, "d")})
assert len(outp["files"]) == 2
for fn in outp["files"]:
assert os.path.isfile(fn)
assert len(outp["dirs"]) == 1
assert os.path.isdir(outp["dirs"][0])

def test_errors(self):
self._run(R"""
version development
Expand Down

0 comments on commit 15f07fb

Please sign in to comment.