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

[TMP, do not merge] adding example for task with FuctionImage #432

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 16 additions & 1 deletion pydra/engine/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,19 @@ def hash_value(value, tp=None, metadata=None, precalculated=None):
return hash_dir(value, precalculated=precalculated)
elif type(value).__module__ == "numpy": # numpy objects
return sha256(value.tostring()).hexdigest()
else:
elif (
isinstance(
value, (int, float, complex, bool, str, bytes, LazyField, os.PathLike)
)
or value is None
):
return value
else:
warnings.warn(
f"pydra doesn't fully support hashing for {type(value)}, "
f"cp.dumps is used in hash functions, so it could depend on the system"
)
return sha256(cp.dumps(value)).hexdigest()


def output_from_inputfields(output_spec, input_spec):
Expand Down Expand Up @@ -812,6 +823,10 @@ def load_task(task_pkl, ind=None):
if isinstance(task_pkl, str):
task_pkl = Path(task_pkl)
task = cp.loads(task_pkl.read_bytes())
if task.name == "img_extract_pdt":
img0 = task.inputs.img[0]
sha0 = sha256(cp.dumps(img0)).hexdigest()
print("\n\n !!!!! hash value in load task", sha0)
if ind is not None:
_, inputs_dict = task.get_input_el(ind)
task.inputs = attr.evolve(task.inputs, **inputs_dict)
Expand Down
Loading