Skip to content

Utilities and Typing

Path Utilities

pytask.path.import_path(path, root)

Import and return a module from the given path.

The functions are taken from pytest when the import mode is set to importlib. It was assumed to be the new default import mode but insurmountable tradeoffs caused the default to be set to prepend. More discussion and information can be found in #373.

pytask.get_state_of_path(path)

Get state of a path.

A simple function to handle local and remote files.

pytask.path.hash_path(path, modification_time, digest='sha256')

Compute the hash of a file.

The function is connected to a cache that is warmed up with previous hashes during the configuration phase.

Tree Utilities

pytask.tree_util.tree_flatten_with_path = functools.partial(_optree_tree_flatten_with_path, none_is_leaf=True, namespace='pytask') module-attribute

pytask.tree_util.tree_leaves = functools.partial(_optree_tree_leaves, none_is_leaf=True, namespace='pytask') module-attribute

pytask.tree_util.tree_map = functools.partial(_optree_tree_map, none_is_leaf=True, namespace='pytask') module-attribute

pytask.tree_util.tree_map_with_path = functools.partial(_optree_tree_map_with_path, none_is_leaf=True, namespace='pytask') module-attribute

pytask.tree_util.tree_structure = functools.partial(_optree_tree_structure, none_is_leaf=True, namespace='pytask') module-attribute

Typing Helpers

pytask.Product = ProductType() module-attribute

ProductType: A singleton to mark products in annotations.

pytask.is_task_function(obj)

Check if an object could be decorated as a task function.