treeseg_lib

class treesegmentation.treeseg_lib.Pipeline(verbose=False)

Controls the order and handling of multiple stages of a process.

Build a pipeline by constructing a Pipeline and using the .then method to add stages.

Note

Use the .execute method to pass an initial input and begin running the first stage. Each stage is executed sequentially, passing output from the previous stage as input to the next stage.

Either every stage completes successfully, or somewhere along the line an error occurs. The .execute method returns either a successful result or an error.

execute(initial)

Run each handler in order passing the context object to each handler.

The required parameters for each handler are determined from the function definition, and the appropriate parameters are passed from the context object to the handler upon execution.

Handler functions can update the context by returning a dict of key/value pairs for which to update the context object with. Although this is not required.

Parameters

initial – The initial context dictionary to be updated after each stage in the pipeline.

Returns

The resulting context dictionary (string names to values).

intersperse(wrapper)

Call the wrapper function on each stage of the pipeline.

Parameters

wrapper – Decorator like function to be applied to each handler function before execution.

Returns

Returns this pipeline. Allows .intersperse calls to be chained.

then(handler)

Adds the next sequential stage in this pipeline.

Parameters

handler – Handler function to be executed. See Pipeline.execute for specification of handler functions.

Returns

Returns this pipeline. Allows .then calls to be chained.

treesegmentation.treeseg_lib.transform_print_runtime(f)

Wrapper/decorator which prints the runtime of the funtion when called.

Parameters

f – Function to print the execution time of.

Returns

Decorator applied to the given function.