Skip to content

Commit dbf4bb1

Browse files
committed
cleaning up other references to output_dir
1 parent ac19f96 commit dbf4bb1

File tree

20 files changed

+105
-76
lines changed

20 files changed

+105
-76
lines changed

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ See the full reference documentation for Pydra
170170
reference/api
171171
genindex
172172
modindex
173+
reference/glossary
173174

174175
.. _FSL: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FSL
175176
.. _ANTs: http://stnava.github.io/ANTs/

docs/source/reference/glossary.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Glossary
2+
========
3+
4+
.. glossary::
5+
6+
Task
7+
A unit of work within the system. It represents one complete processing step in a workflow.
8+
9+
Worker
10+
Encapsulation of a task execution environment. It is responsible for executing
11+
tasks and managing their lifecycle. Workers can be local (e.g., a thread or
12+
process) or remote (e.g., high-performance cluster).
13+
14+
Job
15+
A task that has been instantiated with resolved with concrete inputs.
16+
(i.e. not lazy-values or state-arrays) and assigned to a worker.
17+
18+
Workflow
19+
A series of tasks executed in a specific order.
20+
21+
Node
22+
A single task within the context of a workflow, which is assigned a name and
23+
references a state. Note this task can be nested workflow task.
24+
25+
State
26+
The combination of all upstream splits and combines with any splitters and
27+
combiners for a given node, it is used to track how many jobs, and their
28+
parameterisations, need to be run for a given workflow node.

docs/source/tutorial/2-advanced-execution.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"* `runtime`: information about the peak memory and CPU usage\n",
6767
"* `errored`: the error status of the task\n",
6868
"* `task`: the task object that generated the results\n",
69-
"* `output_dir`: the output directory the results are stored in"
69+
"* `cache_dir`: the output directory the results are stored in"
7070
]
7171
},
7272
{

docs/source/tutorial/5-shell.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@
329329
"to it when it is called\n",
330330
"\n",
331331
"* field: the `Field` object to be provided a value, useful when writing generic callables\n",
332-
"* output_dir: a `Path` object referencing the working directory the command was run within\n",
332+
"* cache_dir: a `Path` object referencing the working directory the command was run within\n",
333333
"* inputs: a dictionary containing all the resolved inputs to the task\n",
334334
"* stdout: the standard output stream produced by the command\n",
335335
"* stderr: the standard error stream produced by the command\n",

pydra/compose/base/task.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Outputs:
3838

3939
RESERVED_FIELD_NAMES = ("inputs",)
4040

41-
_output_dir: Path = attrs.field(default=None, init=False, repr=False)
41+
_cache_dir: Path = attrs.field(default=None, init=False, repr=False)
4242

4343
@property
4444
def inputs(self):
@@ -70,12 +70,12 @@ def _from_task(cls, job: "Job[TaskType]") -> Self:
7070
default = output.default
7171
defaults[output.name] = default
7272
outputs = cls(**defaults)
73-
outputs._output_dir = job.cache_dir
73+
outputs._cache_dir = job.cache_dir
7474
return outputs
7575

7676
@property
7777
def _results(self) -> "Result[Self]":
78-
results_path = self._output_dir / "_job.pklz"
78+
results_path = self._cache_dir / "_job.pklz"
7979
if not results_path.exists():
8080
raise FileNotFoundError(f"Job results file {results_path} not found")
8181
with open(results_path, "rb") as f:

pydra/compose/shell/field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class out(Out):
107107
callable : Callable, optional
108108
If provided the output file name (or list of file names) is created using the
109109
function. The function can take field (the specific output field will be passed
110-
to the function), output_dir (task output_dir will be used), stdout, stderr
110+
to the function), cache_dir (task cache_dir will be used), stdout, stderr
111111
(stdout and stderr of the task will be sent) inputs (entire inputs will be
112112
passed) or any input field name (a specific input field will be sent).
113113
"""

pydra/compose/shell/task.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _from_task(cls, job: "Job[Task]") -> ty.Self:
6464
----------
6565
inputs : Task
6666
The input task of the shell process.
67-
output_dir : Path
67+
cache_dir : Path
6868
The directory where the process was run.
6969
stdout : str
7070
The standard output of the process.
@@ -108,13 +108,13 @@ def _from_task(cls, job: "Job[Task]") -> ty.Self:
108108
return outputs
109109

110110
@classmethod
111-
def _resolve_default_value(cls, fld: field.out, output_dir: Path) -> ty.Any:
111+
def _resolve_default_value(cls, fld: field.out, cache_dir: Path) -> ty.Any:
112112
"""Resolve path and glob expr default values relative to the output dir"""
113113
default = fld.default
114114
if fld.type is Path:
115115
assert isinstance(default, Path)
116116
if not default.is_absolute():
117-
default = output_dir.joinpath(default)
117+
default = cache_dir.joinpath(default)
118118
if "*" not in str(default):
119119
if default.exists():
120120
return default
@@ -174,7 +174,7 @@ def _resolve_value(
174174
return template_update_single(
175175
fld,
176176
task=job.task,
177-
output_dir=job.cache_dir,
177+
cache_dir=job.cache_dir,
178178
spec_type="output",
179179
)
180180
assert fld.callable, (
@@ -191,7 +191,7 @@ def _resolve_value(
191191
for argnm in call_args.args:
192192
if argnm == "field":
193193
call_args_val[argnm] = fld
194-
elif argnm == "output_dir":
194+
elif argnm == "cache_dir":
195195
call_args_val[argnm] = job.cache_dir
196196
elif argnm == "executable":
197197
call_args_val[argnm] = job.task.executable
@@ -209,7 +209,7 @@ def _resolve_value(
209209
except KeyError as e:
210210
e.add_note(
211211
f"arguments of the callable function from {fld.name!r} "
212-
f"has to be in inputs or be field or output_dir, "
212+
f"has to be in inputs or be field or cache_dir, "
213213
f"but {argnm!r} is used"
214214
)
215215
raise
@@ -262,7 +262,7 @@ def cmdline(self) -> str:
262262
the current working directory."""
263263
# Skip the executable, which can be a multi-part command, e.g. 'docker run'.
264264
values = attrs_values(self)
265-
values.update(template_update(self, output_dir=Path.cwd()))
265+
values.update(template_update(self, cache_dir=Path.cwd()))
266266
cmd_args = self._command_args(values=values)
267267
cmdline = cmd_args[0]
268268
for arg in cmd_args[1:]:

pydra/compose/shell/templating.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def template_update(
1717
task,
18-
output_dir: Path | None = None,
18+
cache_dir: Path | None = None,
1919
map_copyfiles: dict[str, Path] | None = None,
2020
):
2121
"""
@@ -45,7 +45,7 @@ def template_update(
4545
fld=fld,
4646
task=task,
4747
values=values,
48-
output_dir=output_dir,
48+
cache_dir=cache_dir,
4949
)
5050
# adding elements from map_copyfiles to fields with templates
5151
if map_copyfiles:
@@ -57,7 +57,7 @@ def template_update_single(
5757
fld: "field.outarg",
5858
task: "Task",
5959
values: dict[str, ty.Any] = None,
60-
output_dir: Path | None = None,
60+
cache_dir: Path | None = None,
6161
spec_type: str = "input",
6262
) -> Path | list[Path | None] | None:
6363
"""Update a single template from the input_spec or output_spec
@@ -96,13 +96,13 @@ def template_update_single(
9696
return None
9797
# inputs_dict[fld.name] is True or spec_type is output
9898
value = _template_formatting(fld, task, values)
99-
if output_dir and value is not None:
100-
# changing path so it is in the output_dir
99+
if cache_dir and value is not None:
100+
# changing path so it is in the cache_dir
101101
# should be converted to str, it is also used for input fields that should be str
102102
if type(value) is list:
103-
value = [output_dir / val.name for val in value]
103+
value = [cache_dir / val.name for val in value]
104104
else:
105-
value = output_dir / value.name
105+
value = cache_dir / value.name
106106
return value
107107

108108

pydra/compose/shell/tests/test_shell_run.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ class Outputs(shell.Outputs):
12891289
def test_shell_cmd_inputspec_copyfile_1(worker, results_function, tmp_path):
12901290
"""shelltask changes a file in place,
12911291
adding copy_mode="copy" to the file-input from input_spec
1292-
hardlink or copy in the output_dir should be created
1292+
hardlink or copy in the cache_dir should be created
12931293
"""
12941294
file = tmp_path / "file_pydra.txt"
12951295
with open(file, "w") as f:
@@ -1329,7 +1329,7 @@ class Outputs(shell.Outputs):
13291329
def test_shell_cmd_inputspec_copyfile_1a(worker, results_function, tmp_path):
13301330
"""shelltask changes a file in place,
13311331
adding copyfile=False to the File-input from input_spec
1332-
hardlink or softlink in the output_dir is created
1332+
hardlink or softlink in the cache_dir is created
13331333
"""
13341334
file = tmp_path / "file_pydra.txt"
13351335
with open(file, "w") as f:
@@ -2076,13 +2076,13 @@ def test_shell_cmd_outputspec_5(worker, results_function, tmp_path):
20762076
"""
20772077
customised output_spec, adding files to the output,
20782078
using a function to collect output, the function is saved in the field metadata
2079-
and uses output_dir and the glob function
2079+
and uses cache_dir and the glob function
20802080
"""
20812081
cmd = ["touch", "newfile_tmp1.txt", "newfile_tmp2.txt"]
20822082

2083-
def gather_output(field, output_dir):
2083+
def gather_output(field, cache_dir):
20842084
if field.name == "newfile":
2085-
return list(Path(output_dir).expanduser().glob("newfile*.txt"))
2085+
return list(Path(cache_dir).expanduser().glob("newfile*.txt"))
20862086

20872087
@shell.define
20882088
class Shelly(shell.Task["Shelly.Outputs"]):
@@ -2107,13 +2107,13 @@ def test_shell_cmd_outputspec_5a(worker, results_function, tmp_path):
21072107
"""
21082108
customised output_spec, adding files to the output,
21092109
using a function to collect output, the function is saved in the field metadata
2110-
and uses output_dir and inputs element
2110+
and uses cache_dir and inputs element
21112111
"""
21122112
cmd = ["touch", "newfile_tmp1.txt", "newfile_tmp2.txt"]
21132113

2114-
def gather_output(executable, output_dir):
2114+
def gather_output(executable, cache_dir):
21152115
files = executable[1:]
2116-
return [Path(output_dir) / file for file in files]
2116+
return [Path(cache_dir) / file for file in files]
21172117

21182118
@shell.define
21192119
class Shelly(shell.Task["Shelly.Outputs"]):
@@ -2141,9 +2141,9 @@ def test_shell_cmd_outputspec_5b_error(tmp_path):
21412141
"""
21422142
cmd = ["touch", "newfile_tmp1.txt", "newfile_tmp2.txt"]
21432143

2144-
def gather_output(executable, output_dir, ble):
2144+
def gather_output(executable, cache_dir, ble):
21452145
files = executable[1:]
2146-
return [Path(output_dir) / file for file in files]
2146+
return [Path(cache_dir) / file for file in files]
21472147

21482148
@shell.define
21492149
class Shelly(shell.Task["Shelly.Outputs"]):
@@ -2173,9 +2173,9 @@ class Shelly(shell.Task["Shelly.Outputs"]):
21732173
class Outputs(shell.Outputs):
21742174

21752175
@staticmethod
2176-
def gather_output(executable, output_dir):
2176+
def gather_output(executable, cache_dir):
21772177
files = executable[1:]
2178-
return [Path(output_dir) / file for file in files]
2178+
return [Path(cache_dir) / file for file in files]
21792179

21802180
newfile: MultiOutputFile = shell.out(callable=gather_output)
21812181

@@ -2478,10 +2478,10 @@ class Outputs(shell.Outputs):
24782478
assert get_output_names(shelly) == ["resultsDir", "return_code", "stderr", "stdout"]
24792479
cache_root = tmp_path / "cache"
24802480
outputs = results_function(shelly, worker=worker, cache_root=cache_root)
2481-
output_dir = next(p for p in cache_root.iterdir() if p.name.startswith("shell-"))
2482-
assert (output_dir / Path("test")).exists()
2481+
cache_dir = next(p for p in cache_root.iterdir() if p.name.startswith("shell-"))
2482+
assert (cache_dir / Path("test")).exists()
24832483
assert get_lowest_directory(outputs.resultsDir) == get_lowest_directory(
2484-
output_dir / Path("test")
2484+
cache_dir / Path("test")
24852485
)
24862486

24872487

pydra/compose/shell/tests/test_shell_templating.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ def test_template_formatting(tmp_path: Path):
104104
field,
105105
task,
106106
values=values,
107-
output_dir=tmp_path,
107+
cache_dir=tmp_path,
108108
spec_type="input",
109109
) == [tmp_path / "file.bvec", tmp_path / "file.bval"]

0 commit comments

Comments
 (0)