Skip to content

Commit 0833ea8

Browse files
committed
fixed up psij worker after renaming
1 parent 5c2af82 commit 0833ea8

File tree

8 files changed

+52
-52
lines changed

8 files changed

+52
-52
lines changed

docs/source/tutorial/1-getting-started.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"\n",
9090
"## Running your first task\n",
9191
"\n",
92-
"Pydra allows you to install independent packages with pre-defined tasks (e.g., `pydra-fsl`, `pydra-ants`). The task from the packages are installed under the `pydra.tasks.*`. You always have access to `pydra.tasks.common`, in addition `pydra-mrtrix3.v3_0` was also installed for this tutorial. To use a pre-defined task definition\n",
92+
"Pydra allows you to install independent packages with pre-defined tasks (e.g., `pydra-fsl`, `pydra-ants`). The task from the packages are installed under the `pydra.tasks.*`. You always have access to `pydra.tasks.common`, in addition `pydra-mrtrix3.v3_0` was also installed for this tutorial. To use a pre-defined task\n",
9393
"\n",
9494
"* import the class from the `pydra.tasks.*` package it is in\n",
9595
"* instantiate it with appropriate parameters\n",
@@ -103,7 +103,7 @@
103103
"cell_type": "markdown",
104104
"metadata": {},
105105
"source": [
106-
"Now we can load the JSON contents back from the file using the `LoadJson` task definition\n",
106+
"Now we can load the JSON contents back from the file using the `LoadJson` task\n",
107107
"class"
108108
]
109109
},
@@ -113,10 +113,10 @@
113113
"metadata": {},
114114
"outputs": [],
115115
"source": [
116-
"# Import the task definition\n",
116+
"# Import the task\n",
117117
"from pydra.tasks.common import LoadJson\n",
118118
"\n",
119-
"# Instantiate the task definition, providing the JSON file we want to load\n",
119+
"# Instantiate the task, providing the JSON file we want to load\n",
120120
"load_json = LoadJson(file=json_file)\n",
121121
"\n",
122122
"# Run the task to load the JSON file\n",
@@ -142,7 +142,7 @@
142142
"metadata": {},
143143
"source": [
144144
"Then we can by importing the `MrGrid` shell-command task from the `pydra-mrtrix3` package\n",
145-
"and run it over every NIfTI file in the directory using the `TaskDef.split()` method"
145+
"and run it over every NIfTI file in the directory using the `Task.split()` method"
146146
]
147147
},
148148
{
@@ -153,7 +153,7 @@
153153
"source": [
154154
"from pydra.tasks.mrtrix3.v3_0 import MrGrid\n",
155155
"\n",
156-
"# Instantiate the task definition, \"splitting\" over all NIfTI files in the test directory\n",
156+
"# Instantiate the task, \"splitting\" over all NIfTI files in the test directory\n",
157157
"# by splitting the \"input\" input field over all files in the directory\n",
158158
"mrgrid = MrGrid(operation=\"regrid\", voxel=(0.5, 0.5, 0.5)).split(\n",
159159
" in_file=nifti_dir.iterdir()\n",
@@ -256,7 +256,7 @@
256256
"\n",
257257
"Output and intermediate files are typically generated during the course of a workflow/task run.\n",
258258
"In addition to this, Pydra generates a cache directory for each task, in which\n",
259-
"the task definition, results and any errors are stored in [cloudpickle](https://github.com/cloudpipe/cloudpickle)\n",
259+
"the task, results and any errors are stored in [cloudpickle](https://github.com/cloudpipe/cloudpickle)\n",
260260
"files for future reference (see [Troubleshooting](./troubleshooting.html)).\n",
261261
"By default, these cache directories are stored in a platform-specific application-cache\n",
262262
"directory\n",
@@ -321,7 +321,7 @@
321321
],
322322
"metadata": {
323323
"kernelspec": {
324-
"display_name": "wf12",
324+
"display_name": "wf13",
325325
"language": "python",
326326
"name": "python3"
327327
},
@@ -335,7 +335,7 @@
335335
"name": "python",
336336
"nbconvert_exporter": "python",
337337
"pygments_lexer": "ipython3",
338-
"version": "3.12.5"
338+
"version": "3.13.1"
339339
}
340340
},
341341
"nbformat": 4,

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@
330330
"\n",
331331
"nifti_file = Nifti1.sample(test_dir, seed=0)\n",
332332
"\n",
333-
"# Instantiate the task definition, \"splitting\" over all NIfTI files in the test directory\n",
333+
"# Instantiate the task, \"splitting\" over all NIfTI files in the test directory\n",
334334
"# by splitting the \"input\" input field over all files in the directory\n",
335335
"mrgrid = MrGrid(in_file=nifti_file, operation=\"regrid\", voxel=(0.5, 0.5, 0.5))\n",
336336
"\n",
@@ -352,7 +352,7 @@
352352
"\n",
353353
"It is also possible to specify functions to run at hooks that are immediately before and after\n",
354354
"the task is executed by passing a `pydra.engine.spec.TaskHooks` object to the `hooks`\n",
355-
"keyword arg. The callable should take the `pydra.engine.core.Task` object as its only\n",
355+
"keyword arg. The callable should take the `pydra.engine.core.Job` object as its only\n",
356356
"argument and return None. The available hooks to attach functions are:\n",
357357
"\n",
358358
"* pre_run: before the task cache directory is created\n",
@@ -371,26 +371,26 @@
371371
"metadata": {},
372372
"outputs": [],
373373
"source": [
374-
"from pydra.engine.core import Task\n",
374+
"from pydra.engine.core import Job\n",
375375
"from pydra.engine.specs import TaskHooks, Result\n",
376376
"import os\n",
377377
"import platform\n",
378378
"\n",
379379
"\n",
380-
"def notify_task_completion(task: Task, result: Result):\n",
380+
"def notify_task_completion(task: Job, result: Result):\n",
381381
" # Print a message to the terminal\n",
382-
" print(f\"Task completed! Results are stored in {str(task.output_dir)!r}\")\n",
382+
" print(f\"Job completed! Results are stored in {str(task.output_dir)!r}\")\n",
383383
"\n",
384384
" # Platform-specific notifications\n",
385385
" if platform.system() == \"Darwin\": # macOS\n",
386386
" os.system(\n",
387-
" 'osascript -e \\'display notification \"Task has completed successfully!\" '\n",
388-
" 'with title \"Task Notification\"\\''\n",
387+
" 'osascript -e \\'display notification \"Job has completed successfully!\" '\n",
388+
" 'with title \"Job Notification\"\\''\n",
389389
" )\n",
390390
" elif platform.system() == \"Linux\": # Linux\n",
391-
" os.system('notify-send \"Task Notification\" \"Task has completed successfully!\"')\n",
391+
" os.system('notify-send \"Job Notification\" \"Job has completed successfully!\"')\n",
392392
" elif platform.system() == \"Windows\": # Windows\n",
393-
" os.system('msg * \"Task has completed successfully!\"')\n",
393+
" os.system('msg * \"Job has completed successfully!\"')\n",
394394
"\n",
395395
"\n",
396396
"# Run the task to resample all NIfTI files\n",

docs/source/tutorial/3-troubleshooting.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
" for field_name in result.outputs:\n",
235235
" if result.outputs[field_name] == float(\"nan\"):\n",
236236
" print(\n",
237-
" f\"Task {task_cache_dir.name!r} produced a NaN value for {field_name!r}\"\n",
237+
" f\"Job {task_cache_dir.name!r} produced a NaN value for {field_name!r}\"\n",
238238
" )"
239239
]
240240
}

docs/source/tutorial/4-python.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"source": [
77
"# Python-tasks\n",
88
"\n",
9-
"Python task definitions are Python functions that are parameterised in a separate step before\n",
9+
"Python tasks are Python functions that are parameterised in a separate step before\n",
1010
"they are executed or added to a workflow.\n",
1111
"\n",
1212
"## Define decorator\n",
@@ -113,7 +113,7 @@
113113
"source": [
114114
"## Type annotations\n",
115115
"\n",
116-
"If provided, type annotations are included in the task definition, and are checked at\n",
116+
"If provided, type annotations are included in the task, and are checked at\n",
117117
"the time of parameterisation."
118118
]
119119
},
@@ -194,7 +194,7 @@
194194
"## Wrapping external functions\n",
195195
"\n",
196196
"Like all decorators, `python.define` is just a function, so can also be used to convert\n",
197-
"a function that is defined separately into a Python task definition."
197+
"a function that is defined separately into a Python task."
198198
]
199199
},
200200
{

docs/source/tutorial/5-shell.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"with open(test_file, \"w\") as f:\n",
5252
" f.write(\"Contents to be copied\")\n",
5353
"\n",
54-
"# Parameterise the task definition\n",
54+
"# Parameterise the task\n",
5555
"cp = Cp(in_file=test_file, destination=test_dir / \"out.txt\")\n",
5656
"\n",
5757
"# Print the cmdline to be run to double check\n",
@@ -312,7 +312,7 @@
312312
" outputs={\"out_file_size\": get_file_size},\n",
313313
")\n",
314314
"\n",
315-
"# Parameterise the task definition\n",
315+
"# Parameterise the task\n",
316316
"cp_with_size = CpWithSize(in_file=File.sample())\n",
317317
"\n",
318318
"# Run the command\n",
@@ -355,13 +355,13 @@
355355
"metadata": {},
356356
"outputs": [],
357357
"source": [
358-
"from pydra.engine.specs import ShellDef, ShellOutputs\n",
358+
"from pydra.engine.specs import ShellTask, ShellOutputs\n",
359359
"from pydra.utils.typing import MultiInputObj\n",
360360
"from fileformats.generic import FsObject, Directory\n",
361361
"\n",
362362
"\n",
363363
"@shell.define\n",
364-
"class Cp(ShellDef[\"Cp.Outputs\"]):\n",
364+
"class Cp(ShellTask[\"Cp.Outputs\"]):\n",
365365
"\n",
366366
" executable = \"cp\"\n",
367367
"\n",

docs/source/tutorial/6-workflow.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"from pydra.design import workflow, python\n",
3232
"\n",
3333
"\n",
34-
"# Example python task definitions\n",
34+
"# Example python tasks\n",
3535
"@python.define\n",
3636
"def Add(a, b):\n",
3737
" return a + b\n",
@@ -264,9 +264,9 @@
264264
"## Type-checking between nodes\n",
265265
"\n",
266266
"Pydra utilizes Python type annotations to implement strong type-checking, which is performed\n",
267-
"when values or upstream outputs are assigned to task definition inputs.\n",
267+
"when values or upstream outputs are assigned to task inputs.\n",
268268
"\n",
269-
"Task input and output fields do not need to be assigned types, since they will default to `typing.Any`.\n",
269+
"Job input and output fields do not need to be assigned types, since they will default to `typing.Any`.\n",
270270
"However, if they are assigned a type and a value or output from an upstream node conflicts\n",
271271
"with the type, a `TypeError` will be raised at construction time.\n",
272272
"\n",

docs/source/tutorial/7-canonical-form.ipynb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
"source": [
77
"# Canonical task form\n",
88
"\n",
9-
"Under the hood, all Python, shell and workflow task definitions generated by the\n",
9+
"Under the hood, all Python, shell and workflow tasks generated by the\n",
1010
"`pydra.design.*.define` decorators/functions are translated to\n",
1111
"[dataclasses](https://docs.python.org/3/library/dataclasses.html) by the\n",
1212
"[Attrs](https://www.attrs.org/en/stable/). While the more compact syntax described\n",
1313
"in the [Python-tasks](./4-python.html), [Shell-tasks](./5-shell.html) and [Workflow](./6-workflow.html)\n",
1414
"tutorials is convenient when designing tasks for specific use cases, it is too magical\n",
15-
"for linters follow. Therefore, when designing task definitions to be used by third\n",
15+
"for linters follow. Therefore, when designing tasks to be used by third\n",
1616
"parties (e.g. `pydra-fsl`, `pydra-ants`) it is recommended to favour the, more\n",
1717
"explicit, \"canonical\" dataclass form.\n",
1818
"\n",
@@ -26,17 +26,17 @@
2626
"cell_type": "markdown",
2727
"metadata": {},
2828
"source": [
29-
"## Python-task definitions\n",
29+
"## Python-tasks\n",
3030
"\n",
3131
"Python tasks in dataclass form are decorated by `pydra.design.python.define`\n",
3232
"with inputs listed as type annotations. Outputs are similarly defined in a nested class\n",
3333
"called `Outputs`. The function to be executed should be a staticmethod called `function`.\n",
3434
"Default values can also be set directly, as with Attrs classes.\n",
3535
"\n",
3636
"In order to allow static type-checkers to check the type of outputs of tasks added\n",
37-
"to workflows, it is also necessary to explicitly extend from the `pydra.engine.specs.PythonDef`\n",
37+
"to workflows, it is also necessary to explicitly extend from the `pydra.engine.specs.PythonTask`\n",
3838
"and `pydra.engine.specs.PythonOutputs` classes (they are otherwise set as bases by the\n",
39-
"`define` method implicitly). Thus the \"canonical form\" of Python task definition is as\n",
39+
"`define` method implicitly). Thus the \"canonical form\" of Python task is as\n",
4040
"follows"
4141
]
4242
},
@@ -48,13 +48,13 @@
4848
"source": [
4949
"from pprint import pprint\n",
5050
"from pydra.engine.helpers import fields_dict\n",
51-
"from pydra.engine.specs import PythonDef, PythonOutputs\n",
51+
"from pydra.engine.specs import PythonTask, PythonOutputs\n",
5252
"from pydra.design import python\n",
5353
"\n",
5454
"\n",
5555
"@python.define\n",
56-
"class CanonicalPythonDef(PythonDef[\"CanonicalPythonDef.Outputs\"]):\n",
57-
" \"\"\"Canonical Python task definition class for testing\n",
56+
"class CanonicalPythonTask(PythonTask[\"CanonicalPythonTask.Outputs\"]):\n",
57+
" \"\"\"Canonical Python task class for testing\n",
5858
"\n",
5959
" Args:\n",
6060
" a: First input\n",
@@ -80,8 +80,8 @@
8080
" return a + b, a / b\n",
8181
"\n",
8282
"\n",
83-
"pprint(fields_dict(CanonicalPythonDef))\n",
84-
"pprint(fields_dict(CanonicalPythonDef.Outputs))"
83+
"pprint(fields_dict(CanonicalPythonTask))\n",
84+
"pprint(fields_dict(CanonicalPythonTask.Outputs))"
8585
]
8686
},
8787
{
@@ -102,8 +102,8 @@
102102
"\n",
103103
"\n",
104104
"@python.define\n",
105-
"class CanonicalPythonDef(PythonDef[\"CanonicalPythonDef.Outputs\"]):\n",
106-
" \"\"\"Canonical Python task definition class for testing\n",
105+
"class CanonicalPythonTask(PythonTask[\"CanonicalPythonTask.Outputs\"]):\n",
106+
" \"\"\"Canonical Python task class for testing\n",
107107
"\n",
108108
" Args:\n",
109109
" a: First input\n",
@@ -129,15 +129,15 @@
129129
" return a + b, a / b\n",
130130
"\n",
131131
"\n",
132-
"pprint(fields_dict(CanonicalPythonDef))\n",
133-
"pprint(fields_dict(CanonicalPythonDef.Outputs))"
132+
"pprint(fields_dict(CanonicalPythonTask))\n",
133+
"pprint(fields_dict(CanonicalPythonTask.Outputs))"
134134
]
135135
},
136136
{
137137
"cell_type": "markdown",
138138
"metadata": {},
139139
"source": [
140-
"## Shell-task definitions\n",
140+
"## Shell-tasks\n",
141141
"\n",
142142
"The canonical form of shell tasks is the same as for Python tasks, except a string `executable`\n",
143143
"attribute replaces the `function` staticmethod."
@@ -153,12 +153,12 @@
153153
"from pathlib import Path\n",
154154
"from fileformats import generic\n",
155155
"from pydra.design import shell\n",
156-
"from pydra.engine.specs import ShellDef, ShellOutputs\n",
156+
"from pydra.engine.specs import ShellTask, ShellOutputs\n",
157157
"from pydra.utils.typing import MultiInputObj\n",
158158
"\n",
159159
"\n",
160160
"@shell.define\n",
161-
"class CpWithSize(ShellDef[\"CpWithSize.Outputs\"]):\n",
161+
"class CpWithSize(ShellTask[\"CpWithSize.Outputs\"]):\n",
162162
"\n",
163163
" executable = \"cp\"\n",
164164
"\n",
@@ -201,10 +201,10 @@
201201
"outputs": [],
202202
"source": [
203203
"from pydra.design import python, workflow\n",
204-
"from pydra.engine.specs import WorkflowDef, WorkflowOutputs\n",
204+
"from pydra.engine.specs import WorkflowTask, WorkflowOutputs\n",
205205
"\n",
206206
"\n",
207-
"# Example python task definitions\n",
207+
"# Example python tasks\n",
208208
"@python.define\n",
209209
"def Add(a, b):\n",
210210
" return a + b\n",
@@ -216,7 +216,7 @@
216216
"\n",
217217
"\n",
218218
"@workflow.define\n",
219-
"class CanonicalWorkflowDef(WorkflowDef[\"CanonicalWorkflowDef.Outputs\"]):\n",
219+
"class CanonicalWorkflowTask(WorkflowTask[\"CanonicalWorkflowTask.Outputs\"]):\n",
220220
"\n",
221221
" @staticmethod\n",
222222
" def a_converter(value):\n",

pydra/engine/workers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -948,9 +948,9 @@ async def run(
948948
spec.stdout_path = cache_dir / "demo.stdout"
949949
spec.stderr_path = cache_dir / "demo.stderr"
950950

951-
job = self.make_job(spec, None)
952-
jex.submit(job)
953-
job.wait()
951+
psij_job = self.make_job(spec, None)
952+
jex.submit(psij_job)
953+
psij_job.wait()
954954

955955
if spec.stderr_path.stat().st_size > 0:
956956
with open(spec.stderr_path, "r") as stderr_file:

0 commit comments

Comments
 (0)