Skip to content
Open
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
8 changes: 6 additions & 2 deletions acclimatise/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def explore(
for format in formats:
converter_cls = WrapperGenerator.choose_converter(format)
converter = converter_cls(
generate_names=generate_names, ignore_positionals=not pos, case=case,
generate_names=generate_names,
ignore_positionals=not pos,
case=case,
)
list(converter.generate_tree(command, out_dir))

Expand All @@ -133,7 +135,9 @@ def pipe(cmd, pos, generate_names, case, format):

converter_cls = WrapperGenerator.choose_converter(format)
converter = converter_cls(
generate_names=generate_names, ignore_positionals=not pos, case=case,
generate_names=generate_names,
ignore_positionals=not pos,
case=case,
)
output = converter.save_to_string(command)
print(output)
Expand Down
7 changes: 6 additions & 1 deletion acclimatise/converter/wdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ def flag_to_command_input(
if isinstance(named_flag.arg, model.Flag):
args.update(dict(optional=named_flag.arg.optional))
if isinstance(named_flag.arg.args, model.EmptyFlagArg):
args.update(dict(true=named_flag.arg.longest_synonym, false=""))
args.update(
dict(
true=named_flag.arg.longest_synonym,
false=""
)
)
else:
args.update(dict(prefix=named_flag.arg.longest_synonym,))
elif isinstance(named_flag, model.Positional):
Expand Down
24 changes: 15 additions & 9 deletions acclimatise/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,21 @@ def _name_from_arg(self) -> typing.Iterable[str]:

def get_type(self) -> cli_types.CliType:
# Try the argument name, then the flag name, then the description in that order
arg_type = self.args.get_type()
if arg_type is not None:
return arg_type

flag_type = infer_type(self.full_name())
if flag_type is not None:
return flag_type

return infer_type(self.description) or cli_types.CliString()
tpe = None
tpe_cand = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer descriptive variable names where possible. typ and type_candidates please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have though your example in #37 would predict None, then CliFile() then CliFile() respectively, and then return CliFile(). We only use subclasses for CliFileSystemType, and only recently, but the inference will never return CliFileSystemType, so it seems irrelevant.

True. I already forgot that we implemented the distinction between in/output files/dirs by properties and not subclasses.Then I will check for isinstance.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that makes more sense

self.args.get_type(),
infer_type(self.full_name()),
infer_type(self.description),
cli_types.CliString(),
]
for c in tpe_cand:
if tpe is None:
if c is not None:
tpe = c
else:
if isinstance(type(c), type(tpe)):
tpe = c
return tpe

def full_name(self) -> str:
"""
Expand Down
6 changes: 5 additions & 1 deletion acclimatise/usage_parser/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ def action(s, loc, toks):

mandatory_element = (
element_char.copy()
.setParseAction(lambda s, loc, toks: UsageElement(text=toks[0],))
.setParseAction(
lambda s, loc, toks: UsageElement(
text=toks[0],
)
)
.setName("MandatoryElement")
)
"""
Expand Down
12 changes: 9 additions & 3 deletions test/executors/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
def test_docker(bwamem_help):
client = docker.from_env()
container = client.containers.run(
"biocontainers/bwa:v0.7.17_cv1", entrypoint=["sleep", "999999999"], detach=True,
"biocontainers/bwa:v0.7.17_cv1",
entrypoint=["sleep", "999999999"],
detach=True,
)

exec = DockerExecutor(container)
Expand All @@ -23,7 +25,9 @@ def test_docker_kill():
"""
client = docker.from_env(timeout=99999)
container = client.containers.run(
"ubuntu:latest", entrypoint=["sleep", "999999999"], detach=True,
"ubuntu:latest",
entrypoint=["sleep", "999999999"],
detach=True,
)

exec = DockerExecutor(container)
Expand Down Expand Up @@ -54,7 +58,9 @@ def test_infinite_output():
"""
client = docker.from_env(timeout=99999)
container = client.containers.run(
"ubuntu:latest", entrypoint=["sleep", "999999999"], detach=True,
"ubuntu:latest",
entrypoint=["sleep", "999999999"],
detach=True,
)

exec = DockerExecutor(container)
Expand Down
6 changes: 5 additions & 1 deletion test/name_generation/test_single_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def test_name_to_words(gen):
"""
Check that we can get an argument name even if the argument's flag is a symbol
"""
arg = Flag(synonyms=["--genomepaths"], description="", args=EmptyFlagArg(),)
arg = Flag(
synonyms=["--genomepaths"],
description="",
args=EmptyFlagArg(),
)

name = gen.choose_variable_names([arg])[0].name
assert "genome" in name
Expand Down
9 changes: 8 additions & 1 deletion test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ def test_explore_samtools_no_subcommands(runner, caplog):
caplog.set_level(100000)
with tempfile.TemporaryDirectory() as tempdir:
result = runner.invoke(
main, ["explore", "samtools", "--no-subcommands", "--out-dir", tempdir,],
main,
[
"explore",
"samtools",
"--no-subcommands",
"--out-dir",
tempdir,
],
)
cli_worked(result)
# Since we aren't looking at subcommands, there should be one file for each format
Expand Down