processor

module of dascore.workflow source

A patch operation, as a task.

Any function decorated with dascore.patch_function is one operation, and PatchOp is that operation said as an object: the function’s name and the arguments it was given, which can be compared, fingerprinted, written to a file and joined into a pipe.

One class stands for every patch function, rather than one class each. What identifies an operation is its name and its arguments, and a name is a string; manufacturing ninety classes to hold ninety strings buys nothing and costs a registry tag, an import and a lookup for each.

PatchProcessor is the base for the few operations which are eventually written out by hand, because they want a kernel seam. When one exists, fn.op(...) returns it instead: one name, one implementation.

An operation is named by a registry tag rather than by where a patch keeps it, so a function bound to nothing – one a user has only just written – is nameable too, and a plugin’s normalize can never be read as DASCore’s.

Examples

import dascore as dc

patch = dc.get_example_patch()
op = dc.proc.normalize.op(dim="time")
assert op(patch).equals(patch.normalize(dim="time"))

Functions

Name Description
fingerprint_call Return the digest which identifies one call to a patch function.
op_name Return the tag which names a patch function, else raise.
patch_function_tag Return the tag which names a patch function in a document.
register_implementation Say that a hand-written class is what a patch function’s name means.
register_patch_function Add a patch function to the registry under its derived tag.
resolve_patch_function Return the patch function a tag names, else say what is missing.

Classes

Name Description
PatchOp Any patch function, as a task.
PatchProcessor A task which runs on a patch, written out by hand.