smttask.base.TaskOutput#
- class smttask.base.TaskOutput(*args, _task, outcome='')#
Output definition logic:
If a TaskOutput type defines only one output, it expects the result to be that output:
class Outputs: x: float
Expects the task to return a single float, which will be saved with the name ‘x’. Similarly:
class Outputs: x: Tuple[float, float]
expects a single tuple, which will be saved with the name ‘x’.
If instead a TaskOutput type defines multiple values, it expects them to be wrapped with a tuple (as would multiple return values from a function). So:
class Outputs: x: float y: float
expects the task to return a tuple of length two, the components of which will be saved with the names ‘x’ and ‘y’. Similarly:
class Outputs: x: Tuple[float, float] y: float
expects the task to return a tuple of length two, the elements of which would be a tuple and a float.
Warning
In the interest of brevity, the snippets above are incomplete. In a real definition, each type is a union including Task.
Note
In contrast to most other situations, we try here to avoid raising exceptions. This is because once we’ve reached the point of constructing a TaskOutput object, we have already computed the result. This may have taken a long time, and we want to do our best to save the data in some form. If we can’t parse the result, we store the original value to allow write to save it as-is. It will not be useable in downstream tasks, but at least this gives the user a chance to inspect it.
- __init__(*args, _task, outcome='', **kwargs)#
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Methods
__init__(*args, _task[, outcome])Create a new model by parsing and validating input data from keyword arguments.
construct([_fields_set])Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
copy(*args, **kwargs)Duplicate a model, optionally choose which fields to include, exclude and change.
describe()dict(*args, **kwargs)Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
display_block()emergency_dump(filename, obj)A function called when the normal saving function fails.
from_orm(obj)json(*[, include, exclude, by_alias, ...])Generate a JSON representation of the model, include and exclude arguments as per dict().
outputdir(_task)outputpaths(_task)parse_file(path, *[, content_type, ...])parse_obj(obj)parse_raw(b, *[, content_type, encoding, ...])parse_result(result, _task)schema([by_alias, ref_template])schema_json(*[, by_alias, ref_template])update_forward_refs(**localns)Try to update ForwardRefs on fields based on this Model, globalns and localns.
validate(value)write(**dumps_kwargs)Save outputs; file locations are determined automatically.
Attributes
digesthashed_digestoutcomeresultReturn the value, as it would have been returned by the Task.
unhashed_digests