common-workflow-lab / gxargparse Goto Github PK
View Code? Open in Web Editor NEWThis project forked from hexylena/argparse2tool
Automated CWL and Galaxy XML generation for Python tools that use argparse and click
License: Apache License 2.0
This project forked from hexylena/argparse2tool
Automated CWL and Galaxy XML generation for Python tools that use argparse and click
License: Apache License 2.0
Seems to be added to all files, regardless of being needed
requirements:
- class: InlineJavascriptRequirement
It can be a "standing" or "[WIP]" (work in progress) pull request.
type: ["null", str]
-> type: str?
If an array of a single type then type: string[]
is simpler
I'd like to convert click commands to cwl command line tools. After installing gxargparse
I get an error if I run the command with or without --generate_cwl_tool
:
> python -m nlppln.replace_ner --generate_cwl_tool
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/jvdzwaan/code/nlppln/nlppln/replace_ner.py", line 2, in <module>
import click
File "/home/jvdzwaan/code/gxargparse/click/__init__.py", line 20, in <module>
setattr(__selfmodule__, x, getattr(click, x))
AttributeError: module 'random_name_1' has no attribute 'cwlt'
> python -m nlppln.replace_ner
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/jvdzwaan/code/nlppln/nlppln/replace_ner.py", line 2, in <module>
import click
File "/home/jvdzwaan/code/gxargparse/click/__init__.py", line 20, in <module>
setattr(__selfmodule__, x, getattr(click, x))
AttributeError: module 'random_name_1' has no attribute 'cwlt'
(cwl3) jvdzwaan@ESLT0062:~/code/gxargparse$
The error also occurs in Python 2.7:
> python -m nlppln.replace_ner --generate_cwl_tool
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/jvdzwaan/code/nlppln/nlppln/replace_ner.py", line 2, in <module>
import click
File "click/__init__.py", line 20, in <module>
setattr(__selfmodule__, x, getattr(click, x))
AttributeError: 'module' object has no attribute 'cwlt'
> python -m nlppln.replace_ner
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/jvdzwaan/code/nlppln/nlppln/replace_ner.py", line 2, in <module>
import click
File "click/__init__.py", line 20, in <module>
setattr(__selfmodule__, x, getattr(click, x))
AttributeError: 'module' object has no attribute 'cwlt'
In both instances gxargparse_check_path
gives Ready to go!
Took me a few minutes to understand why my changes weren't sticking as I had created an example.cwl
for testing.
When example.py
is run, it outputs the CWL tool to both stdout + example.cwl
(one also has an extra newline). This seems like odd behaviour to me (a linux admin). If it outputs to stdout, I don't expect it to also be writing to a file.
$ strace -e open python example.py --generate_cwl_tool 2>&1 | grep example.cwl
open("example.cwl", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
Additionally one of them has an extra newline at the end (stdout vs updated file).
cwlVersion: v1.0
As @mr-c mentioned in a private conversation, Galaxy will be gaining CWL support, and the development of the original gxargparse basically stopped, so Galaxy specific parts can be ripped off. I need them now as a sample, but as soon as CWL tool wrapper will be finished, I'll remove them as much as the docs. Should the repository bear the old name along with that?
/cc @brainstorm
Hi,
I looked through the issues before posting, apologies if this has been asked or explained elsewhere or I missed it...
I noticed that if my argparse objects call parse_known_args instead of parse_args, the --generate_cwl_tool doesn't fire. Is that by design? I can see the logic if so, just wondering.
doesn't mention CWL until several paragraphs later
Hey @anton-khodak, this is looking great!
In the resulting CWL tool definition I see that the output sections are all blank.
One way to fix that is to accept a file with the definitions written by hand.
I get an error when I run python example.py --generate_cwl_tool
:
Traceback (most recent call last):
File "example.py", line 29, in <module>
args = parser.parse_args()
File "/home/jvdzwaan/code/gxargparse/argparse/__init__.py", line 78, in parse_args
self.parse_args_cwl(*args, **kwargs)
File "/home/jvdzwaan/code/gxargparse/argparse/__init__.py", line 115, in parse_args_cwl
cwlt_parameter = methodToCall(result)
File "/home/jvdzwaan/code/gxargparse/argparse/argparse_cwl_translation.py", line 85, in _StoreAction
cwlparam = self.__cwl_param_from_type(param)
File "/home/jvdzwaan/code/gxargparse/argparse/argparse_cwl_translation.py", line 58, in __cwl_param_from_type
'type': self.get_cwl_type(param.type) or 'str'}
File "/home/jvdzwaan/code/gxargparse/argparse/argparse_cwl_translation.py", line 131, in get_cwl_type
return PY_TO_CWL_TYPES[py_type]
KeyError: <class 'io.IOBase'>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.