@@ -50,10 +50,12 @@ task module to the Julia script.
5050
5151``` python
5252import pytask
53+ from pathlib import Path
54+ from pytask import task
5355
5456
57+ @task (kwargs = {" path" : Path(" out.csv" )})
5558@pytask.mark.julia (script = " script.jl" )
56- @pytask.mark.produces (" out.csv" )
5759def task_run_jl_script ():
5860 pass
5961```
@@ -64,11 +66,12 @@ more information.
6466
6567### Dependencies and Products
6668
67- Dependencies and products can be added as with a normal pytask task using the
68- ` @pytask.mark.depends_on ` and ` @pytask.mark.produces ` decorators. which is explained in
69- this
69+ Dependencies and products can be added as usual. Read this
7070[ tutorial] ( https://pytask-dev.readthedocs.io/en/stable/tutorials/defining_dependencies_products.html ) .
7171
72+ For example, with the ` @pytask.task ` decorator as shown before. (The choice of the kwarg
73+ name, here ` path ` , is arbitrary.)
74+
7275### Accessing dependencies and products in the script
7376
7477To access the paths of dependencies and products in the script, pytask-julia stores the
@@ -82,21 +85,19 @@ path_to_json = ARGS[1] # Contains the path to the .json file.
8285
8386config = JSON. parse (read (path_to_json, String)) # A dictionary.
8487
85- config[" produces " ] # Is the path to the output file "../out.csv".
88+ config[" path " ] # Is the path to the output file "../out.csv".
8689```
8790
8891The ` .json ` file is stored in the same folder as the task in a ` .pytask ` directory.
8992
9093To parse the JSON file, you need to install
9194[ JSON.jl] ( https://github.com/JuliaIO/JSON.jl ) .
9295
93- You can also pass any other information to your script by using the ` @pytask.mark.task `
94- decorator.
96+ You can also pass any other information to your script by using the ` @task ` decorator.
9597
9698``` python
97- @pytask.mark. task (kwargs = {" number" : 1 })
99+ @task (kwargs = {" path " : Path( " out.csv " ), " number" : 1 })
98100@pytask.mark.julia (script = " script.jl" )
99- @pytask.mark.produces (" out.csv" )
100101def task_run_jl_script ():
101102 pass
102103```
@@ -141,8 +142,8 @@ You can also define environments for each task which will overwrite any other de
141142with the ` project ` keyword argument. Pass a path to the task module.
142143
143144``` python
145+ @task (kwargs = {" path" : Path(" out.csv" )})
144146@pytask.mark.julia (script = " script.jl" , project = " ." )
145- @pytask.mark.produces (" out.csv" )
146147def task_run_jl_script ():
147148 pass
148149```
@@ -152,8 +153,8 @@ def task_run_jl_script():
152153Command line options can be pass via the ` options ` keyword argument.
153154
154155``` python
156+ @task (kwargs = {" path" : Path(" out.csv" )})
155157@pytask.mark.julia (script = " script.jl" , options = [" --threads" , " 2" ])
156- @pytask.mark.produces (" out.csv" )
157158def task_run_jl_script ():
158159 pass
159160```
@@ -171,22 +172,20 @@ produce different outputs.
171172``` python
172173for i in range (2 ):
173174
174- @pytask.mark. task
175+ @task ( kwargs = { " path " : Path( f " out_ { i } .csv " )})
175176 @pytask.mark.julia (script = f " script_ { i} .jl " )
176- @pytask.mark.produces (f " out_ { i} .csv " )
177177 def task_execute_julia_script ():
178178 pass
179179```
180180
181181If you want to pass different inputs to the same Julia script, pass these arguments with
182- the ` kwargs ` keyword of the ` @pytask.mark. task ` decorator.
182+ the ` kwargs ` keyword of the ` @task ` decorator.
183183
184184``` python
185185for i in range (2 ):
186186
187- @pytask.mark. task (kwargs = {" i" : i})
187+ @task (kwargs = {" path " : Path( f " out_ { i } .csv " ), " i" : i})
188188 @pytask.mark.julia (script = " script.jl" )
189- @pytask.mark.produces (f " output_ { i} .csv " )
190189 def task_execute_julia_script ():
191190 pass
192191```
@@ -200,7 +199,7 @@ path_to_json = ARGS[1] # Contains the path to the .json file.
200199
201200config = JSON. parse (read (path_to_json, String)) # A dictionary.
202201
203- config[" produces " ] # Is the path to the output file "../output_{i}.csv".
202+ config[" path " ] # Is the path to the output file "../output_{i}.csv".
204203
205204config[" i" ] # Is the number.
206205```
0 commit comments