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
.thenmethod to add stages.Note
Use the
.executemethod 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
.executemethod 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
wrapperfunction 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
.interspersecalls to be chained.
- then(handler)¶
Adds the next sequential stage in this pipeline.
- Parameters
handler – Handler function to be executed. See
Pipeline.executefor specification of handler functions.- Returns
Returns this pipeline. Allows
.thencalls 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.