Skip to content

Instantly share code, notes, and snippets.

@haydenflinner
Last active September 25, 2018 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haydenflinner/d6198596883ebea95c494659a3937c84 to your computer and use it in GitHub Desktop.
Save haydenflinner/d6198596883ebea95c494659a3937c84 to your computer and use it in GitHub Desktop.
maketask.md

An invoke.task replacement that supports make-like file dependencies.

make_task works just like GNU-make: by checking the timestamps on the last update of each file that you depend on against the timestamp of the files you create, we can decide whether or not you need to run.

@param outputs: List of strings that will be used to index into your ctx to determine the filepath that you output to. Example:

@make_task(pre=[my_earlier_task], outputs=['build.outputfilenames'])
def build(ctx, myparam1):
    pass
ns.configure({"build" : {"outputfilenames": ["outfile1"]}})

@param pre: List of tasks that this task depends on. If they are make_tasks, they will only run if needed. Note that you can access the output of a pretask at pretaskname.output regardless of how it configures its output in ctx or with make_task. That is:

 @make_task(pre=[my_earlier_task], outputs=['build.outputfilenames'])
 def build(ctx):
     file.open(my_earlier_task.output)
     return 'Found it!'

will always work as long as my_earlier_task is a make_task and configured at least one output file. Note that output is just a provided shortcut for outputs[0].

pre was chosen to overload the invoke pre because the transition should be seamless; If you specify regular pre's that aren't make_tasks, they will run as they always did. If they are make_tasks, they will skip if they aren't required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment