Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft implementation of proposed syntax changes (feedback requested) #766

Draft
wants to merge 167 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
8f06ac4
reworked collect outputs so callable's are used over simply copying v…
tclose Jun 3, 2024
f06171d
if bool field argstr includes a string template, do templating instea…
tclose Jun 5, 2024
2b33473
bugfix for argstr formatting for bool types
tclose Jul 23, 2024
b177091
wrote cmd_out arg and unittest based on "ls" for shell_cmd
tclose Jul 23, 2024
5758eb3
added small note to docs
tclose Jul 23, 2024
0f0485c
renamed cmd_arg and cmd_out to shell_arg and shell_out
tclose Jul 23, 2024
16cecf1
touched up docs
tclose Jul 23, 2024
6ee5b86
pass through kwargs to attrs.field in shell_arg and shell_out
tclose Jul 23, 2024
47806ff
added shell_task decorator
tclose Jul 23, 2024
c0d7011
implemented shell_task and basic unittests. Generated tasks do not wo…
tclose Jul 23, 2024
0da3b46
shell command unittests pass
tclose Jul 23, 2024
c4d1875
renamed pydra.mark.shell_commands to pydra.mark.shell
tclose Jul 23, 2024
d25eab0
fixed up inheritance of Inputs and Outputs
tclose Jul 23, 2024
e4095a7
added tests for output_file_template/output_field_name and various un…
tclose Jul 23, 2024
e9a58bc
converted to hatch build system and made proper namespace package
tclose Jul 23, 2024
e8bce86
initial structure of 'design' sub-package
tclose Aug 1, 2024
e1b677e
implementing new decorator syntax
tclose Nov 9, 2024
1a0ffff
got all new python interface unittests to pass
tclose Nov 9, 2024
3a159bb
fixed up checking of wrapped type in python.task decorator
tclose Nov 11, 2024
dabe2ef
added shell.task decorator implementation and working through tests
tclose Nov 11, 2024
0aa12cf
debugging shell interface syntax
tclose Nov 12, 2024
8581f55
debugging type hints
tclose Nov 12, 2024
4b408a3
debugged test_shell unittests
tclose Nov 14, 2024
6cf4e1b
added tests for shell command templates
tclose Nov 15, 2024
8cbeade
cleaning up shell tests
tclose Nov 15, 2024
79e98f6
capture defaults in pydra.design
tclose Nov 16, 2024
bba8be7
added function to python.interface fields instead of static
tclose Nov 16, 2024
7ab7713
reworked and debugged shell design tests
tclose Nov 16, 2024
e606459
all python and shell design tests pass
tclose Nov 16, 2024
b38ced6
added initialization tests to test_python
tclose Nov 16, 2024
a9356d1
renamed Interface->TaskSpec and interface->define
tclose Nov 16, 2024
b9594ee
converted to inputs and outputs to dicts from lists within design mak…
tclose Nov 17, 2024
91b4116
added workflow design module
tclose Nov 17, 2024
8130802
added check for symbols defined outside to the scope of the function
tclose Nov 17, 2024
5aa9fbf
enhanced get_undefined_symbols to skip decorator and signature type h…
tclose Nov 17, 2024
e4da149
debugged workflow construction tests
tclose Nov 18, 2024
acde206
added check for NOTHING values and auto added to ext
tclose Nov 18, 2024
07cf5a8
added new workflow tests
tclose Nov 18, 2024
9f7a42e
added check for unrecognised inputs
tclose Nov 18, 2024
2d4f030
added custom hash for function types based on function source
tclose Nov 18, 2024
35c952d
added shell workflow and debugged shell task definitions
tclose Nov 18, 2024
ac08c18
added cononical workflow test
tclose Nov 19, 2024
a77be6a
added lazy inputs test
tclose Nov 19, 2024
476f7db
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2024
cd97c11
Debugged splitting and combining of lazy fields
tclose Dec 3, 2024
d825056
updated python versions to include 3.13 and drop <3.10
tclose Dec 4, 2024
03e6951
resolved gnarly circular imports
tclose Dec 5, 2024
384e57d
fixed up lazy out splitting
tclose Dec 5, 2024
553bb2f
fixing up state maintenance in workflow nodes
tclose Dec 6, 2024
032fd4e
restored functionality from specs
tclose Dec 8, 2024
bdee4c8
cleaned up specs.py so that it works with new syntax
tclose Dec 9, 2024
d2f0bf3
updated attrs required version to latest
tclose Dec 9, 2024
35f489c
debugged reworking of specs module
tclose Dec 9, 2024
a9071e4
renamed OutSpec to Outputs
tclose Dec 9, 2024
1b50350
renamed FunctionTask -> PythonTask and ShellCommandTask -> ShellTask …
tclose Dec 9, 2024
51c911b
debugged design unittests
tclose Dec 9, 2024
f227987
added dataclass_transform decorators to define and outputs
tclose Dec 9, 2024
0cf7d35
Added the use of '?' to signify optional shell template fields
tclose Dec 9, 2024
4be0945
added in "modify|" syntax as discussed with @satra
tclose Dec 10, 2024
328e0b1
implemented defaults in shell command template using '=' syntax
tclose Dec 10, 2024
cf7b331
cleaned up insertion of special stdout, stderr and return_code output…
tclose Dec 10, 2024
c6b7cd7
debugged setting of state in split and combine
tclose Dec 10, 2024
0b8ac66
added tests to demonstrate nested workflows
tclose Dec 10, 2024
000140e
added check for lazy vals to non-lazy inputs in workflow construct
tclose Dec 10, 2024
5e898af
shell tasks now execute
tclose Dec 13, 2024
7df9a2b
implemented python task execution
tclose Dec 13, 2024
860002f
moved boutiques into design pacakge
tclose Dec 16, 2024
5d08b0e
added typing to Result to specify output type
tclose Dec 16, 2024
70d0e06
reworked dockertask test
tclose Dec 16, 2024
1daec25
got tests to load
tclose Dec 16, 2024
0dc7ec6
renamed docs to old-docs
tclose Dec 16, 2024
e254177
added new docs structure
tclose Dec 16, 2024
0077f68
added simple installation instructions
tclose Dec 16, 2024
c79905c
touched up new docs
tclose Dec 16, 2024
8c08f9e
more docs restructuring
tclose Dec 16, 2024
718e42a
reworked new docs structure
tclose Dec 18, 2024
8e1d83c
Update pydra/engine/tests/test_boutiques.py
tclose Dec 19, 2024
c3f8249
touching up docs structure
tclose Dec 19, 2024
602c8fe
fixing up docs
tclose Dec 21, 2024
b4d2b16
removed state references from execution code (they will be handled be…
tclose Dec 21, 2024
fb86964
debugging test utils
tclose Dec 21, 2024
97c6f11
removed implicit extraction of output names from return values
tclose Dec 21, 2024
0cfcc5f
cleaned up all @mark.task to @python.define
tclose Dec 21, 2024
4908d21
changed supported version to Py3.11, use Exception.add_note instead o…
tclose Dec 24, 2024
44d8b67
got execution notebook example to work
tclose Dec 24, 2024
e193bb8
reworking testing tasks
tclose Dec 24, 2024
53f28bd
Added shell-task tutorial
tclose Dec 24, 2024
75d429b
fixed up templating defaults
tclose Dec 26, 2024
92fe97c
debugged shell and python task tutorias
tclose Dec 26, 2024
78f51eb
moved docs back to original location, renamed new docs to "new-docs"
tclose Dec 26, 2024
363ac5d
fixed import of version
tclose Dec 26, 2024
bc030f5
added rtd theme to docs deps
tclose Dec 26, 2024
a3724bd
fixing up new docs build action
tclose Dec 26, 2024
9383ccd
added docs dep
tclose Dec 27, 2024
ee6844a
revert main docs to latest tag
tclose Dec 27, 2024
137965b
reworking docs CI
tclose Dec 27, 2024
2574d8e
touching up docs deps
tclose Dec 27, 2024
be5d8b5
more docs deps
tclose Dec 27, 2024
6491756
fixed docs ci
tclose Dec 27, 2024
571ba9c
docs ci touch up
tclose Dec 27, 2024
c4d7468
removed restriction on release for docs deploy
tclose Dec 27, 2024
4a8c42d
include ipython in docs deps
tclose Dec 27, 2024
1a6b067
renamed Outputs to TaskOutputs
tclose Dec 27, 2024
a8ed05e
finished workflow tutorial and reworked some of the docs structure
tclose Dec 28, 2024
8e88ed2
finished off the workflow tutorial for now
tclose Dec 28, 2024
6f1c8e3
restructuring new docs
tclose Dec 28, 2024
03546ed
more restructuring of new docs
tclose Dec 29, 2024
35641b1
writing getting-starting notebook
tclose Dec 29, 2024
ffdfce1
renamed Spec and specification to Def and definition
tclose Dec 29, 2024
e317e8e
finished getting-started (apart from debugging) tutorial
tclose Dec 29, 2024
720efdb
imported examples from tutorials
tclose Dec 29, 2024
7a7cffd
touched up errors in first-level-glm
tclose Dec 29, 2024
edd682f
reinstated changes to getting-started
tclose Dec 29, 2024
f5276b9
touched up getting-started
tclose Dec 29, 2024
8170777
converted two-level glm to new syntax
tclose Dec 30, 2024
02f6a1c
more touching up of documentation
tclose Dec 31, 2024
4502260
finished python task and canonical form tuts
tclose Dec 31, 2024
d71542f
added dependencies required for examples
tclose Dec 31, 2024
70edf85
touching up tutorials
tclose Dec 31, 2024
9594e75
renamed spec to definition across the board
tclose Dec 31, 2024
940f004
fixed mrtrix import
tclose Dec 31, 2024
e15cb35
finished playing with tutorials for now
tclose Dec 31, 2024
96e0b92
fixed doc dependency
tclose Dec 31, 2024
3495b50
download tags to docs build
tclose Dec 31, 2024
ec669e1
more fixes to docs CI
tclose Dec 31, 2024
e95e8ff
commented out pydra-mrtrix3 dep for docs until new release
tclose Jan 1, 2025
b5b95d3
combined typing and hashing
tclose Jan 1, 2025
1e81774
renamed help_string to help
tclose Jan 1, 2025
ac7ab7f
renamed make_task_spec to make_task_def
tclose Jan 4, 2025
7c47eef
touch up docs
tclose Jan 6, 2025
83cbbb6
touching up docs
tclose Jan 7, 2025
e6c488f
renamed tutorials to give natural order
tclose Jan 7, 2025
88a05bb
filled out explanation sections with subheadings
tclose Jan 7, 2025
efa668a
more docs touch ups
tclose Jan 9, 2025
9f7aa2b
connecting workflow logic to new api syntax
tclose Jan 14, 2025
5cbb4df
added section on workers
tclose Jan 17, 2025
f639b21
renamed execution options
tclose Jan 17, 2025
69b72c9
debugging workflow and shell architecture refactoring
tclose Jan 21, 2025
abcf93f
moved run into PythonDef
tclose Jan 21, 2025
e5c2556
implemented non-asynchronous "debug" worker that avoids async/await f…
tclose Jan 23, 2025
03c7438
touching up typing of tasks to include TaskDef template
tclose Jan 23, 2025
076dc84
debugged getting-started tutorial
tclose Jan 23, 2025
c3a144e
debugging workflow execution internals
tclose Jan 24, 2025
6a590e9
moved resolution of lazy fields to point where tasks are initialised
tclose Jan 24, 2025
e3418b3
got concurrent futures worker to work
tclose Jan 24, 2025
e59d86e
debugging cf worker
tclose Jan 24, 2025
834024e
debugging cf execution within notebooks, implemented byte-code hashin…
tclose Jan 25, 2025
142a58d
added troubleshooting tutorial stub
tclose Jan 27, 2025
544bbc2
touched up getting started tutorial
tclose Jan 29, 2025
7d89bb4
cleaning up new docs
tclose Jan 29, 2025
94cee3e
fixed test import errors
tclose Jan 29, 2025
2d37331
fixing broken unittests pt1
tclose Jan 29, 2025
4da2eef
debugging unittests
tclose Jan 29, 2025
0a32bfa
more debugging of unittests
tclose Jan 29, 2025
4ff7303
fixed up setting of state in workflow constructors
tclose Jan 29, 2025
0e0a02d
changed under_construction so it investigates the call stack instead …
tclose Jan 29, 2025
9c11add
implemented AST based function bytes_repr
tclose Jan 30, 2025
b8ba7f8
trimmed some unnecessary attributes from the byte-code based function…
tclose Jan 30, 2025
1cacaa0
debugging test_functions
tclose Jan 30, 2025
2da62fd
debugging test_helpers_file
tclose Jan 30, 2025
ff8069f
debugged test_helpers_file
tclose Jan 30, 2025
290bdca
renamed test tasks and workflows to PascalCase
tclose Jan 30, 2025
d584074
debugged test_hash and test_typing
tclose Jan 30, 2025
e015f8c
fixed test_hash error
tclose Jan 30, 2025
61e6439
debugging test_tasks
tclose Jan 30, 2025
3cc5232
debugging workflows
tclose Jan 31, 2025
d2ab96f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
got concurrent futures worker to work
  • Loading branch information
tclose committed Jan 24, 2025
commit e3418b3f4f5fad637d2d96e245f5978c8ff8bb7f
18 changes: 9 additions & 9 deletions new-docs/source/tutorial/tst.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from pydra.design import python

if __name__ == "__main__":

@python.define
def TenToThePower(p: int) -> int:
return 10**p
@python.define
def TenToThePower(p: int) -> int:
return 10**p

ten_to_the_power = TenToThePower().split(p=[1, 2, 3, 4, 5])

ten_to_the_power = TenToThePower().split(p=[1, 2, 3, 4, 5])
# Run the 5 tasks in parallel split across 3 processes
outputs = ten_to_the_power(worker="cf", n_procs=3)

# Run the 5 tasks in parallel split across 3 processes
outputs = ten_to_the_power(worker="debug")
p1, p2, p3, p4, p5 = outputs.out

p1, p2, p3, p4, p5 = outputs.out

print(f"10^5 = {p5}")
print(f"10^5 = {p5}")
4 changes: 3 additions & 1 deletion pydra/engine/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ def _populate_filesystem(self):
if not self.can_resume and self.output_dir.exists():
shutil.rmtree(self.output_dir)
self.output_dir.mkdir(parents=False, exist_ok=self.can_resume)
# Save task pkl into the output directory for future reference
save(self.output_dir, task=self)

def run(self, rerun: bool = False):
"""Prepare the task working directory, execute the task definition, and save the
Expand Down Expand Up @@ -382,7 +384,7 @@ def run(self, rerun: bool = False):
self._check_for_hash_changes()
return result

async def run_async(self, rerun: bool = False):
async def run_async(self, rerun: bool = False) -> Result:
"""Prepare the task working directory, execute the task definition asynchronously,
and save the results. NB: only workflows are run asynchronously at the moment.

Expand Down
18 changes: 9 additions & 9 deletions pydra/engine/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ def load_and_run(task_pkl: Path, rerun: bool = False) -> Path:

resultfile = task.output_dir / "_result.pklz"
try:
task(rerun=rerun)
task.run(rerun=rerun)
except Exception as e:
# creating result and error files if missing
errorfile = task.output_dir / "_error.pklz"
Expand All @@ -479,16 +479,16 @@ def load_and_run(task_pkl: Path, rerun: bool = False) -> Path:
return resultfile


async def load_and_run_async(task_pkl):
"""
loading a task from a pickle file, settings proper input
and running the workflow
"""
task = load_task(task_pkl=task_pkl)
await task()
# async def load_and_run_async(task_pkl):
# """
# loading a task from a pickle file, settings proper input
# and running the workflow
# """
# task = load_task(task_pkl=task_pkl)
# await task()


def load_task(task_pkl):
def load_task(task_pkl: Path | str) -> "Task[DefType]":
"""loading a task from a pickle file, settings proper input for the specific ind"""
if isinstance(task_pkl, str):
task_pkl = Path(task_pkl)
Expand Down
9 changes: 8 additions & 1 deletion pydra/engine/specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,11 @@ def _resolve_value(

class ShellDef(TaskDef[ShellOutputsType]):

arguments: ty.List[str] = shell.arg(
default=attrs.Factory(list),
help="Additional arguments to pass to the command.",
)

RESERVED_FIELD_NAMES = TaskDef.RESERVED_FIELD_NAMES + ("cmdline",)

def _run(self, task: "Task[ShellDef]") -> None:
Expand Down Expand Up @@ -952,7 +957,9 @@ def _command_args(
# Sort command and arguments by position
cmd_args = position_sort(pos_args)
# pos_args values are each a list of arguments, so concatenate lists after sorting
return sum(cmd_args, [])
command_args = sum(cmd_args, [])
command_args += self.arguments
return command_args

def _command_shelltask_executable(
self, field: shell.arg, value: ty.Any
Expand Down
11 changes: 5 additions & 6 deletions pydra/engine/submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from copy import copy
from collections import defaultdict
from .workers import Worker, WORKERS
from .core import is_workflow
from .graph import DiGraph
from .helpers import (
get_open_loop,
Expand Down Expand Up @@ -153,10 +152,10 @@ def Split(defn: TaskDef) -> tuple:
"Use the `split` method to split the task before combining."
)
task = Task(task_def, submitter=self, name="task", environment=self.environment)
if task.is_async:
self.loop.run_until_complete(task.run_async(rerun=self.rerun))
if task.is_async: # Only workflow tasks can be async
self.loop.run_until_complete(self.worker.run_async(task, rerun=self.rerun))
else:
task.run(rerun=self.rerun)
self.worker.run(rerun=self.rerun)
PersistentCache().clean_up()
result = task.result()
if result is None:
Expand Down Expand Up @@ -285,8 +284,8 @@ async def expand_workflow_async(self, workflow_task: "Task[WorkflowDef]") -> Non
)
raise RuntimeError(msg)
for task in tasks:
if is_workflow(task):
await task.run_async(rerun=self.rerun)
if task.is_async:
await self.worker.run_async(task, rerun=self.rerun)
else:
task_futures.add(self.worker.run(task, rerun=self.rerun))
task_futures = await self.worker.fetch_finished(task_futures)
Expand Down
Loading