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

-l language parameter is invalid #66

Open
kimsin98 opened this issue Jul 20, 2023 · 1 comment
Open

-l language parameter is invalid #66

kimsin98 opened this issue Jul 20, 2023 · 1 comment

Comments

@kimsin98
Copy link

$ datalad hello-cmd -l en
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')

It happens because the parameter conflicts with -l LEVEL. This error doesn't appear when the short parameter is -L.

It would be also nice if the error message was less intimidating. Not sure why error for invalid -l is particularly so long.

@jsheunis
Copy link
Member

jsheunis commented Oct 9, 2023

Some more notes after looking into this a bit:

Running with log level set to debug via environment variable, I get Early parsing failed with ArgumentError(argument -l/--log-level: invalid choice: 'en' (choose from 'critical', 'error', 'warning', 'info', 'debug', '1', '2', '3', '4', '5', '6', '7', '8', '9'))

The supposed conflict does not happen for all other common datalad arguments included in https://github.com/datalad/datalad/blob/maint/datalad/cli/common_args.py e.g. if -l is changed to -c in hello_cmd.py (conflicting with c in common_args):

datalad hello-cmd -c en
demo(ok): /Users/jsheunis/Documents/psyinf/datalad-extension-template [Hello!]

However, if args=("-l", "--language"), is changed to args=("--report-type",), in hello_cmd.py (conflicting with --report-type in common_args), the same error occurs (here with the log level set to debug via environment variable):

datalad hello-cmd --report-type en
[DEBUG  ] Run ['git', 'version'] (protocol_class=StdOutErrCapture) (cwd=None)
[DEBUG  ] Finished ['git', 'version'] with status 0
[DEBUG  ] Not retro-fitting GitRepo with deprecated symbols, datalad-deprecated package not found
[DEBUG  ] Processing entrypoints
[DEBUG  ] Done processing entrypoints
[DEBUG  ] Early parsing failed with ArgumentError(argument --report-type: invalid choice: 'en' (choose from 'dataset', 'file'))
[DEBUG  ] Failed to import requests_ftp, thus no ftp support: ModuleNotFoundError(No module named 'requests_ftp')
[DEBUG  ] Building doc for <class 'datalad.distributed.create_sibling_github.CreateSiblingGithub'>
[DEBUG  ] Building doc for <class 'datalad.distribution.update.Update'>
[DEBUG  ] Building doc for <class 'datalad.distribution.siblings.Siblings'>
[DEBUG  ] Building doc for <class 'datalad.local.subdatasets.Subdatasets'>
[DEBUG  ] Building doc for <class 'datalad.distributed.create_sibling_gitlab.CreateSiblingGitlab'>
[DEBUG  ] Building doc for <class 'datalad.distributed.create_sibling_gogs.CreateSiblingGogs'>
[DEBUG  ] Building doc for <class 'datalad.distributed.create_sibling_gin.CreateSiblingGin'>
[DEBUG  ] Building doc for <class 'datalad.distributed.create_sibling_gitea.CreateSiblingGitea'>
[DEBUG  ] Building doc for <class 'datalad.core.distributed.clone.Clone'>
[DEBUG  ] Building doc for <class 'datalad.distributed.create_sibling_ria.CreateSiblingRia'>
[DEBUG  ] Building doc for <class 'datalad.core.local.status.Status'>
[DEBUG  ] Building doc for <class 'datalad.core.local.diff.Diff'>
[DEBUG  ] Building doc for <class 'datalad.distribution.create_sibling.CreateSibling'>
[DEBUG  ] Building doc for <class 'datalad.distributed.drop.Drop'>
[DEBUG  ] Building doc for <class 'datalad.core.local.save.Save'>
[DEBUG  ] Building doc for <class 'datalad.local.remove.Remove'>
[DEBUG  ] Building doc for <class 'datalad.local.addurls.Addurls'>
[DEBUG  ] Building doc for <class 'datalad.local.copy_file.CopyFile'>
[DEBUG  ] Building doc for <class 'datalad.local.download_url.DownloadURL'>
[DEBUG  ] Building doc for <class 'datalad.distribution.get.Get'>
[DEBUG  ] Building doc for <class 'datalad.distribution.install.Install'>
[DEBUG  ] Building doc for <class 'datalad.local.unlock.Unlock'>
[DEBUG  ] Building doc for <class 'datalad.core.local.run.Run'>
[DEBUG  ] Building doc for <class 'datalad.local.foreach_dataset.ForEachDataset'>
[DEBUG  ] Building doc for <class 'datalad.local.rerun.Rerun'>
[DEBUG  ] Building doc for <class 'datalad.local.run_procedure.RunProcedure'>
[DEBUG  ] Building doc for <class 'datalad.core.local.create.Create'>
[DEBUG  ] Building doc for <class 'datalad.core.distributed.push.Push'>
[DEBUG  ] Building doc for <class 'datalad.local.configuration.Configuration'>
[DEBUG  ] Building doc for <class 'datalad.local.wtf.WTF'>
[DEBUG  ] Building doc for <class 'datalad.local.clean.Clean'>
[DEBUG  ] Building doc for <class 'datalad.local.add_archive_content.AddArchiveContent'>
[DEBUG  ] Building doc for <class 'datalad.local.add_readme.AddReadme'>
[DEBUG  ] Building doc for <class 'datalad.local.export_archive.ExportArchive'>
[DEBUG  ] Building doc for <class 'datalad.distributed.export_archive_ora.ExportArchiveORA'>
[DEBUG  ] Building doc for <class 'datalad.distributed.export_to_figshare.ExportToFigshare'>
[DEBUG  ] Building doc for <class 'datalad.local.no_annex.NoAnnex'>
[DEBUG  ] Building doc for <class 'datalad.local.check_dates.CheckDates'>
[DEBUG  ] Building doc for <class 'datalad.distribution.uninstall.Uninstall'>
[DEBUG  ] Building doc for <class 'datalad.distribution.create_test_dataset.CreateTestDataset'>
[DEBUG  ] Building doc for <class 'datalad.support.sshrun.SSHRun'>
[DEBUG  ] Building doc for <class 'datalad.interface.shell_completion.ShellCompletion'>
[DEBUG  ] Parsing known args among ['/Users/jsheunis/opt/miniconda3/envs/sexy/bin/datalad', 'hello-cmd', '--report-type', 'en']
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')

This indicates that the conflict arrises for duplicate parameter options (in common_args and the extension) that also have a choices defined. Perhaps the problem lies in the choices being validated too early in the process of executing the command line?

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