Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension command line argument in conflict with datalad level argument #7573

Open
candleindark opened this issue Mar 21, 2024 · 3 comments
Open

Comments

@candleindark
Copy link

https://github.com/datalad/datalad-extension-template/blob/793c5543b8f1385e007ceb2b8cd1db667b9d38e6/datalad_helloworld/hello_cmd.py#L37

The -l command argument above doesn't work. datalad seems to be interpreting it as a datalad level argument instead of an extension level argument.

❯ datalad hello-cmd -l de
usage: datalad [-c (:name|name=value)] [-C PATH] [--cmd] [-l LEVEL] [--on-failure {ignore,continue,stop}] [--report-status {success,failure,ok,notneeded,impossible,error}] [--report-type {dataset,file}]
               [-f {generic,json,json_pp,tailored,disabled,'<template>'}] [--dbg] [--idbg] [--version]
               {create-sibling-github,create-sibling-gitlab,create-sibling-gogs,create-sibling-gin,create-sibling-gitea,create-sibling-ria,create-sibling,siblings,update,subdatasets,drop,remove,addurls,copy-file,download-url,foreach-dataset,install,rerun,run-procedure,create,save,status,clone,get,push,run,diff,configuration,wtf,clean,add-archive-content,add-readme,export-archive,export-archive-ora,export-to-figshare,no-annex,check-dates,unlock,uninstall,create-test-dataset,sshrun,shell-completion}
               ...
datalad: error: argument {create-sibling-github,create-sibling-gitlab,create-sibling-gogs,create-sibling-gin,create-sibling-gitea,create-sibling-ria,create-sibling,siblings,update,subdatasets,drop,remove,addurls,copy-file,download-url,foreach-dataset,install,rerun,run-procedure,create,save,status,clone,get,push,run,diff,configuration,wtf,clean,add-archive-content,add-readme,export-archive,export-archive-ora,export-to-figshare,no-annex,check-dates,unlock,uninstall,create-test-dataset,sshrun,shell-completion}: invalid choice: 'hello-cmd' (choose from 'create-sibling-github', 'create-sibling-gitlab', 'create-sibling-gogs', 'create-sibling-gin', 'create-sibling-gitea', 'create-sibling-ria', 'create-sibling', 'siblings', 'update', 'subdatasets', 'drop', 'remove', 'addurls', 'copy-file', 'download-url', 'foreach-dataset', 'install', 'rerun', 'run-procedure', 'create', 'save', 'status', 'clone', 'get', 'push', 'run', 'diff', 'configuration', 'wtf', 'clean', 'add-archive-content', 'add-readme', 'export-archive', 'export-archive-ora', 'export-to-figshare', 'no-annex', 'check-dates', 'unlock', 'uninstall', 'create-test-dataset', 'sshrun', 'shell-completion')

Changing -l to -x, args=("-x", "--language"), works just fine.

❯ datalad hello-cmd -x de
demo(ok): /Users/isaac/Developer/Dartmouth/workshop/datalad-extension-template [Tachchen!]
@yarikoptic
Copy link
Member

could be -L or even just --language alone. Care to submit a PR with the one you like?

@candleindark
Copy link
Author

candleindark commented Mar 21, 2024

could be -L or even just --language alone. Care to submit a PR with the one you like?

Sure we can do that. But that's not my concern though. Why shouldn't -l work? It should be interpreted as a command argument for the extension.

@yarikoptic
Copy link
Member

I thought it was a generic known issue, but I searched myself into

I think it belongs to the main repo, will transfer

here is some food for thought:

❯ DATALAD_LOG_LEVEL=2 datalad  hello-cmd -l de
[Level 5] Instantiating ssh manager 
...
[Level 8] argument -l/--log-level: invalid choice: 'de' (choose from 'critical', 'error', 'warning', 'info', 'debug', '1', '2', '3', '4', '5', '6', '7', '8', '9') [parser.py:single_subparser_possible:356,argparse.py:_parse_known_args:2126,argparse.py:consume_optional:2066,argparse.py:take_action:1974,argparse.py:_get_values:2509,argparse.py:_check_value:2565] 
[DEBUG  ] Early parsing failed with ArgumentError(argument -l/--log-level: invalid choice: 'de' (choose from 'critical', 'error', 'warning', 'info', 'debug', '1', '2', '3', '4', '5', '6', '7', '8', '9')) 
...

and

❯ DATALAD_LOG_LEVEL=2 datalad hello-cmd 2>&1 | grep hellow
[DEBUG] Loading entrypoint helloworld from datalad.extensions 
[DEBUG] Loaded entrypoint helloworld from datalad.extensions 
[Level 5] Importing module datalad_helloworld.hello_cmd  
[DEBUG] Building doc for <class 'datalad_helloworld.hello_cmd.HelloWorld'> 
[DEBUG] Determined class of decorated function: <class 'datalad_helloworld.hello_cmd.HelloWorld'> 
[Level 2] Returning generator_func from eval_func for <class 'datalad_helloworld.hello_cmd.HelloWorld'> 
❯ DATALAD_LOG_LEVEL=2 datalad hello-cmd -l de 2>&1 | grep hellow
❯ 

so if we get that early fail - we seems to not bother importing extensions via entry points.

@yarikoptic yarikoptic transferred this issue from datalad/datalad-extension-template Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants