"Just"
why no invoke?
Doit has a few features invoke doesn't, like file deps and targets. It's also more declarative.
Could you please help me with providing pos_arg to targets? So i want to compile deps using pip-tools and for this task i provide pos_arg as filename. How to dynamically set targets based on filename?
```
def task_compile_deps():
return {
'actions': [
(
'pip-compile -q --allow-unsafe --generate-hashes --strip-extras '
'--output-file=requirements/%(filename)s.txt requirements/%(filename)s.in'
),
],
'pos_arg': 'filename',
'targets': ['requirements/%(filename)s.txt'],
}
It does not work.
Targets are unfortunately not interpolated. The easiest way to do it is to provide an "up_to_date" function:
```python
import os
def task_process_file():
'actions': [f"echo %(filename)s"],
'uptodate': [lambda task: not os.path.exists(task.pos_arg)]
For non positional arguments, task_params is the solution: https://pydoit.org/task-args.html#task-creator-parameters
Wow, those comments are really bad for code
Thanks for the great blog!
You've got a missing comma after 'command two' in the first block of code in the "Scaling down" section.
And because Python automatically concatenate those strings, it would have been very hard to debug for most readers, so thanks for catching that.
At the beginning i didn't open the comments because I didn't want to moderate them, but for now I only had very constructive and helpful ones.
The substack community has been super sweet so far.
why no invoke?
Doit has a few features invoke doesn't, like file deps and targets. It's also more declarative.
Could you please help me with providing pos_arg to targets? So i want to compile deps using pip-tools and for this task i provide pos_arg as filename. How to dynamically set targets based on filename?
```
def task_compile_deps():
return {
'actions': [
(
'pip-compile -q --allow-unsafe --generate-hashes --strip-extras '
'--output-file=requirements/%(filename)s.txt requirements/%(filename)s.in'
),
],
'pos_arg': 'filename',
'targets': ['requirements/%(filename)s.txt'],
}
```
It does not work.
Targets are unfortunately not interpolated. The easiest way to do it is to provide an "up_to_date" function:
```python
import os
def task_process_file():
return {
'actions': [f"echo %(filename)s"],
'pos_arg': 'filename',
'uptodate': [lambda task: not os.path.exists(task.pos_arg)]
}
```
For non positional arguments, task_params is the solution: https://pydoit.org/task-args.html#task-creator-parameters
Wow, those comments are really bad for code
Thanks for the great blog!
You've got a missing comma after 'command two' in the first block of code in the "Scaling down" section.
And because Python automatically concatenate those strings, it would have been very hard to debug for most readers, so thanks for catching that.
At the beginning i didn't open the comments because I didn't want to moderate them, but for now I only had very constructive and helpful ones.
The substack community has been super sweet so far.