Skip to content

Commit

Permalink
Merge pull request #662 from tclose/type-coercion
Browse files Browse the repository at this point in the history
Merging now ahead of alpha release 🥳 

(NB: I left out the relaxation to allow Parent (out) -> Child (in) to pass type-checking as it is a bit involved, and can wait until before we make a full release)
  • Loading branch information
tclose authored Aug 4, 2023
2 parents 9de0560 + 292fd3f commit 6062274
Show file tree
Hide file tree
Showing 34 changed files with 4,791 additions and 2,733 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/testslurm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
docker pull $DOCKER_IMAGE
# Have image running in background
docker run `bash <(curl -s https://codecov.io/env)` -itd -h ernie --name slurm -v `pwd`:/pydra -e NO_ET=$NO_ET $DOCKER_IMAGE
- name: Update python
run: docker exec slurm bash -c "conda install python==3.8.15"
- name: Display previous jobs with sacct
run: |
echo "Allowing ports/daemons time to start" && sleep 10
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ cov.xml
.*.swp
*~
.idea
*.venv

.DS_Store

Expand Down
14 changes: 8 additions & 6 deletions docs/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,17 @@ the Task execution, the user can set splitter and combiner attributes of the Sta
.. code-block:: python
task_with_state =
add2(x=[1, 5]).split("x").combine("x")
add2().split(x=[1, 5]).combine("x")
In this example, the ``State`` class is responsible for creating a list of two
separate inputs, *[{x: 1}, {x:5}]*, each run of the *Task* should get one
element from the list.
The results are grouped back when returning the result from the *Task*.
While this example
illustrates mapping and grouping of results over a single parameter, *Pydra*
extends this to arbitrary combinations of input fields and downstream grouping
element from the list. Note that in this case the value for `x` is set in the `split()`
method, not at the task's initialisation.
The `combine()` method, specifies that the results are grouped back when returning the
result from the *Task*.

While this example illustrates mapping and grouping of results over a single parameter,
*Pydra* extends this to arbitrary combinations of input fields and downstream grouping
over nested dataflows. Details of how splitters and combiners power *Pydra*'s
scalable dataflows are described in the next section.

Expand Down
8 changes: 0 additions & 8 deletions pydra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,3 @@ def check_latest_version():

if TaskBase._etelemetry_version_data is None:
TaskBase._etelemetry_version_data = check_latest_version()


# attr run_validators is set to False, but could be changed using use_validator
attr.set_run_validators(False)


def set_input_validator(flag=False):
attr.set_run_validators(flag)
15 changes: 9 additions & 6 deletions pydra/engine/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import json
import attr
from ..utils.messenger import send_message, make_message, gen_uuid, now, AuditFlag
from .helpers import ensure_list, gather_runtime_info, hash_file
from .specs import attr_fields, File, Directory
from ..utils.hash import hash_function
from .helpers import ensure_list, gather_runtime_info
from .specs import attr_fields
from fileformats.core import FileSet

try:
import importlib_resources
Expand Down Expand Up @@ -181,10 +183,11 @@ def audit_task(self, task):
command = task.cmdline if hasattr(task.inputs, "executable") else None
attr_list = attr_fields(task.inputs)
for attrs in attr_list:
if attrs.type in [File, Directory]:
input_name = attrs.name
input_path = os.path.abspath(getattr(task.inputs, input_name))
file_hash = hash_file(input_path)
input_name = attrs.name
value = getattr(task.inputs, input_name)
if isinstance(value, FileSet):
input_path = os.path.abspath(value)
file_hash = hash_function(value)
entity_id = f"uid:{gen_uuid()}"
entity_message = {
"@id": entity_id,
Expand Down
Loading

0 comments on commit 6062274

Please sign in to comment.