question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Passing arguments to tasks: need to specify at least one of short or long?

See original GitHub issue

Hey, thanks for this great tool! I just came across the following issue: For passing arguments to tasks, the documentation specifies that “short” and “long” names are optional. However, in my setup it seems as if omitting both gives an error.

dodo.py:

def task_py_param():
    def show_param(param):
        print(param)
    return {'actions':[(show_param,)],
            'params':[{'name':'param',
                       'default':'default value'}],
            'verbosity':2,
            }

Running the task:

$ doit py_param --param=test
ERROR: Error parsing Task: option --param not recognized (parsing options: ['--param=test'])
$ doit help py_param
py_param  

Versions:

$ python --version
Python 3.4.0
$ pip list
doit (0.28.0)
pip (1.5.4)
pyinotify (0.9.6)
setuptools (2.1)
six (1.9.0)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mitchbregscommented, Jun 5, 2019

@schettino72 - I am running into a similar situation when passing parameters through a yield statement instead of return. The documentation only gives examples of passing parameters in one-off tasks with return statement, whereas I am running a task with for loop through a bunch of data and using a yield statement in order to capture the task actions, targets, dependencies, etc. However, I am now trying to add parameters to this task:

doit -f wp/dodo.py external_report --week 1      
ERROR: Error parsing Task: option --week not recognized (parsing options: ['--week', '1'])

This is my yield definition:

            yield {'value': dict(name=output.stem,
                                 actions=[cmd],
                                 file_dep=[(template), (data), (geo)],
                                 targets=[output],
                                 uptodate=[False],
                                 params=[{'name': 'week',
                                          'short': 'wk',
                                          'long': 'week',
                                          'default': '1',
                                          'help': 'Week of reporting.'}]),
                   'log_status': 1}

You can disregard the log_status, I have built a custom logger to log tasks. Read the yield statement as the sub-dictionary of value.

1reaction
schettino72commented, Jun 6, 2019

Thanks a bunch @schettino72 - loving your work on pydoit! smile

Cool, so give it a 🌟 😬

Read more comments on GitHub >

github_iconTop Results From Across the Web

Task parametrization, getting arguments from command line
It is possible to pass option parameters to the task action through the command ... It can optionally define a “short” and “long”...
Read more >
Ruby - how to pass a single argument to a method with long ...
For instance, I want to pass ignoreAlreadyCrawled = true in the method below, and use the default parameter values for everything else. But ......
Read more >
Adding arguments and options to your Bash scripts - Red Hat
Try putting the parameters in a different order to see how that works. These parameters are positional, and that is a key consideration....
Read more >
Invoking tasks
Note that both long and short style flags are supported, and that equals signs are ... List values (which you wouldn't want to...
Read more >
Usage | Task
You can use env to set custom environment variables for a specific task: version: '3' ... If you want a variable in an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found