1010[ ![ pre-commit.ci status] ( https://results.pre-commit.ci/badge/github/pytask-dev/pytask-stata/main.svg )] ( https://results.pre-commit.ci/latest/github/pytask-dev/pytask-stata/main )
1111[ ![ image] ( https://img.shields.io/badge/code%20style-black-000000.svg )] ( https://github.com/psf/black )
1212
13- ------------------------------------------------------------------------
13+ ______________________________________________________________________
1414
15- Run Stata\ ' s do-files with pytask.
15+ Run Stata's do-files with pytask.
1616
1717## Installation
1818
19- pytask-stata is available on
20- [ PyPI] ( https://pypi.org/project/pytask-stata ) and
21- [ Anaconda.org] ( https://anaconda.org/conda-forge/pytask-stata ) . Install
22- it with
19+ pytask-stata is available on [ PyPI] ( https://pypi.org/project/pytask-stata ) and
20+ [ Anaconda.org] ( https://anaconda.org/conda-forge/pytask-stata ) . Install it with
2321
24- ``` console
22+ ``` console
2523$ pip install pytask-stata
2624
2725# or
2826
2927$ conda install -c conda-forge pytask-stata
3028```
3129
32- You also need to have Stata installed on your system and have the
33- executable on your system\ ' s PATH. If you do not know how to do it,
34- [ here ] ( https://superuser.com/a/284351 ) is an explanation.
30+ You also need to have Stata installed on your system and have the executable on your
31+ system's PATH. If you do not know how to do it, [ here ] ( https://superuser.com/a/284351 )
32+ is an explanation.
3533
3634## Usage
3735
38- Similarly to normal task functions which execute Python code, you define
39- tasks to execute scripts written in Stata with Python functions. The
40- difference is that the function body does not contain any logic, but the
41- decorator tells pytask how to handle the task.
36+ Similarly to normal task functions which execute Python code, you define tasks to
37+ execute scripts written in Stata with Python functions. The difference is that the
38+ function body does not contain any logic, but the decorator tells pytask how to handle
39+ the task.
4240
4341Here is an example where you want to run ` script.do ` .
4442
45- ``` python
43+ ``` python
4644import pytask
4745
4846
@@ -52,24 +50,23 @@ def task_run_do_file():
5250 pass
5351```
5452
55- When executing a do-file, the current working directory changes to the
56- directory where the script is located. This allows you, for example, to
57- reference every data set you want to read with a relative path from the
58- script.
53+ When executing a do-file, the current working directory changes to the directory where
54+ the script is located. This allows you, for example, to reference every data set you
55+ want to read with a relative path from the script.
5956
6057### Dependencies and Products
6158
62- Dependencies and products can be added as with a normal pytask task
63- using the ` @pytask.mark.depends_on ` and ` @pytask.mark.produces `
64- decorators. which is explained in this
59+ Dependencies and products can be added as with a normal pytask task using the
60+ ` @pytask.mark.depends_on ` and ` @pytask.mark.produces ` decorators. which is explained in
61+ this
6562[ tutorial] ( https://pytask-dev.readthedocs.io/en/stable/tutorials/defining_dependencies_products.html ) .
6663
6764### Accessing dependencies and products in the script
6865
69- The decorator can be used to pass command line arguments to your Stata
70- executable. For example, pass the path of the product with
66+ The decorator can be used to pass command line arguments to your Stata executable. For
67+ example, pass the path of the product with
7168
72- ``` python
69+ ``` python
7370@pytask.mark.stata (script = " script.do" , options = " auto.dta" )
7471@pytask.mark.produces (" auto.dta" )
7572def task_run_do_file ():
@@ -78,22 +75,21 @@ def task_run_do_file():
7875
7976And in your ` script.do ` , you can intercept the value with
8077
81- ``` do
78+ ``` do
8279* Intercept command line argument and save to macro named 'produces'.
8380args produces
8481
8582sysuse auto, clear
8683save "`produces'"
8784```
8885
89- The relative path inside the do-file works only because the pytask-stata
90- switches the current working directory to the directory of the do-file
91- before the task is executed.
86+ The relative path inside the do-file works only because the pytask-stata switches the
87+ current working directory to the directory of the do-file before the task is executed.
9288
93- To make the task independent from the current working directory, pass
94- the full path as an command line argument. Here is an example.
89+ To make the task independent from the current working directory, pass the full path as
90+ an command line argument. Here is an example.
9591
96- ``` python
92+ ``` python
9793# Absolute path to the build directory.
9894from src.config import BLD
9995
@@ -106,14 +102,12 @@ def task_run_do_file():
106102
107103### Repeating tasks with different scripts or inputs
108104
109- You can also parametrize the execution of scripts, meaning executing
110- multiple do-files as well as passing different command line arguments to
111- the same do-file.
105+ You can also parametrize the execution of scripts, meaning executing multiple do-files
106+ as well as passing different command line arguments to the same do-file.
112107
113- The following task executes two do-files which produce different
114- outputs.
108+ The following task executes two do-files which produce different outputs.
115109
116- ``` python
110+ ``` python
117111for i in range (2 ):
118112
119113 @pytask.mark.task
@@ -129,25 +123,22 @@ pytask-stata can be configured with the following options.
129123
130124* ` stata_keep_log ` *
131125
132- Use this option to keep the ` .log ` files which are produced for
133- every task. This option is useful to debug Stata tasks. Set the
134- option via the configuration file with
126+ Use this option to keep the ` .log ` files which are produced for every task. This option
127+ is useful to debug Stata tasks. Set the option via the configuration file with
135128
136129``` toml
137130[tool .pytask .ini_options ]
138131stata_keep_log = true
139132```
140133
141- The option is also available in the command line interface via the
142- ` --stata-keep-log ` flag.
143-
134+ The option is also available in the command line interface via the ` --stata-keep-log `
135+ flag.
144136
145137* ` stata_check_log_lines ` *
146138
147- Use this option to vary the number of lines in the log file which
148- are checked for error codes. It also controls the number of lines
149- displayed on errors. Use any integer greater than zero. Here is the
150- entry in the configuration file
139+ Use this option to vary the number of lines in the log file which are checked for error
140+ codes. It also controls the number of lines displayed on errors. Use any integer greater
141+ than zero. Here is the entry in the configuration file
151142
152143``` toml
153144[tool .pytask .ini_options ]
@@ -156,7 +147,7 @@ stata_check_log_lines = 10
156147
157148and here via the command line interface
158149
159- ``` console
150+ ``` console
160151$ pytask build --stata-check-log-lines 10
161152```
162153
0 commit comments