Programming Languages#

The templates support a variety of programming languages.

  • Python

  • R

  • Julia

  • Stata

The base language is Python, which works out-of-the-box. In this section we show you how to use the other languages and explain some language specific caveats.

Note

  • When selecting a language in the cookiecutter Customising the template for your needs we install all the necessary software needed to use that language for you.

  • The usage of pytask with your chosen language should be illustrated in the example project that was downloaded. At the moment the example project is not implemented for R, Julia and Stata (but under more or less active development, help appreciated!). This is why we clarify the basics here.

Warning

The use of pytask with Python differs from the other languages. While in Python you do certain manipulations of your objects inside a task-file, in the other languages you only specify dependencies and outputs.

R#

The following is copied from pytask-r.

To create a task which runs a R script, define a task function with the @pytask.mark.r decorator. The script keyword provides an absolute path or path relative to the task module to the R script.

import pytask


@pytask.mark.r(script="script.r")
@pytask.mark.produces("out.rds")
def task_run_r_script():
    pass

Julia#

The following is copied from pytask-julia.

To create a task which runs a Julia script, define a task function with the @pytask.mark.julia decorator. The script keyword provides an absolute path or path relative to the task module to the Julia script.

import pytask


@pytask.mark.julia(script="script.jl")
@pytask.mark.produces("out.csv")
def task_run_jl_script():
    pass

Stata#

The following is copied from pytask-stata.

To create a task which runs a Stata script, define a task function with the @pytask.mark.stata decorator. The script keyword provides an absolute path or path relative to the task module to the Stata script.

import pytask


@pytask.mark.stata(script="script.do")
@pytask.mark.produces("out.dta")
def task_run_do_script():
    pass