flowserv.model.template.schema module

Definition of schema components for benchmark results. The schema definition is part of the extended workflow template specification that is used to define benchmarks.

class flowserv.model.template.schema.ResultColumn(column_id, name, dtype, path=None, required=None)

Bases: object

Column in the result schema of a benchmark. Each column has a unique identifier and unique name. The identifier is used as column name in the database schema. The name is for display purposes in a user interface. The optional path element is used to extract the column value from nested result files.

cast(value)

Cast the given value to the data type of the column. Will raise ValueError if type cast is not successful.

Parameters

value (scalar) – Expects a scalar value that can be converted to the respective column type.

Return type

int, float, or string

classmethod from_dict(doc, validate=True)

Get an instance of the column from the dictionary serialization. Raises an error if the given dictionary does not contain the expected elements as generated by the to_dict() method of the class.

Parameters
  • doc (dict) – Dictionary serialization of a column object

  • validate (bool, default=True) – Validate the serialization if True.

Return type

flowserv.model.template.schema.ResultColumn

Raises

flowserv.error.InvalidTemplateError

jpath()

The Json path for a result column is a list of element keys that reference the column value in a nested document. If the internal path variable is not set the column identifier is returned as the only element in the path.

Return type

list(string)

to_dict()

Get dictionary serialization for the column object.

Return type

dict

class flowserv.model.template.schema.ResultSchema(result_file, columns, order_by=None)

Bases: object

The result schema of a benchmark run is a collection of columns. The result schema is used to generate leader boards for benchmarks.

The schema also contains the identifier of the output file that contains the result object. The result object that is generated by each benchmark run is expected to contain a value for each required columns in the schema.

classmethod from_dict(doc, validate=True)

Get an instance of the schema from a dictionary serialization. Raises an error if the given dictionary does not contain the expected elements as generated by the to_dict() method of the class or if the names or identifier of columns are not unique.

Returns None if the given document is None.

Parameters
  • doc (dict) – Dictionary serialization of a benchmark result schema object

  • validate (bool, default=True) – Validate the serialization if True.

Return type

flowserv.model.template.schema.ResultSchema

Raises

flowserv.error.InvalidTemplateError

get_default_order()

By default the first column in the schema is used as the sort column. Values in the column are sorted in descending order.

Return type

list(flowserv.model.template.schema.SortColumn)

to_dict()

Get dictionary serialization for the result schema object.

Return type

dict

class flowserv.model.template.schema.SortColumn(column_id, sort_desc=None)

Bases: object

The sort column defines part of an ORDER BY statement that is used to sort benchmark results when creating the benchmark leader board. Each object contains a reference to a result column and a flag indicating the sort order for values in the column.

classmethod from_dict(doc, validate=True)

Get an instance of the sort column from the dictionary serialization. Raises an error if the given dictionary does not contain the expected elements as generated by the to_dict() method of the class.

Parameters
  • doc (dict) – Dictionary serialization of a column object

  • validate (bool, default=True) – Validate the serialization if True.

Return type

flowserv.model.template.schema.SortColumn

Raises

flowserv.error.InvalidTemplateError

to_dict()

Get dictionary serialization for the sort column object.

Return type

dict