mapteksdk.workflows.connector_type module

The ConnectorType interface.

Classes which implement this interface can be passed to WorkflowArgumentParser as connector types.

class Dimensionality(value)

Bases: Enum

Represents the dimensionality of an input.

SINGLE = 0

This connector type accepts a single value.

LIST = 1

This connector accepts a list of uniformly typed values.

class DataType(name, dimensionality)

Bases: object

A data type supported by workflows.

Parameters:
property name: str

The name of this data type.

property dimensionality: Dimensionality

The dimensionality of this data type.

base_type()

The base type of this data type.

This will be this data type.

Return type:

DataType

is_subtype_of(data_type)

True if this DataType is a subtype of data_type.

Parameters:

data_type (DataType)

class PortType(*args, **kwargs)

Bases: Protocol

Interface for classes representing port types.

Classes which implement this protocol can be used as data types for WorkflowArgumentParser.declare_input_connector() and WorkflowArgumentParser.declare_output_connector() when running in WorkflowMAE.

data_type()

The type of data supported by this port.

Return type:

DataType

type_string()

The data type when generating ports.

Return type:

str

from_workflow_native(json_value)

Convert from the Workflow native representation to the Python one.

Raises:
  • TypeError – If json_value is not a supported type.

  • ValueError – If json_value is the correct type but an invalid value.

Parameters:

json_value (JsonValues)

Return type:

Any

to_workflow_native(value)

Convert value to the Workflow native format.

Parameters:

value (Any)

Return type:

JsonValues

class DynamicConnectorType(*args, **kwargs)

Bases: Protocol

Interface for classes representing connector types.

Classes which implement this protocol can be used as data types for WorkflowArgumentParser.declare_input_connector() and WorkflowArgumentParser.declare_output_connector() when running in Workflows.

Remarks

This differs from ConnectorType by being a non-static class, allowing for a class to implement both PortType and DynamicConnectorType so that it supports both Workflows and WorkflowMAE.

data_type()

The type of data supported by this port.

Return type:

DataType

type_string()

The data type when generating ports.

Return type:

str

from_string(string_value)

Convert a string value to the corresponding python type.

Raises:
  • TypeError – If string_value is not a supported type.

  • ValueError – If string_value is the correct type but an invalid value.

Parameters:

string_value (str)

Return type:

Any

to_json(value)

Converts the value to a json-serializable value.

This is used to convert python values to json values to be passed to the workflow for output connectors.

Returns:

Json serializable representation of value.

Return type:

json-serializable

Raises:
  • TypeError – If value is not a supported type.

  • ValueError – If value is the correct type but an invalid value.

Parameters:

value (Any)

to_default_json(value)

Converts the value to a json serializable default.

This allows for specifying a different representation for default values. The output of this function should not include lists.

Overwrite this function to raise an error to indicate that default values are not supported.

By default this calls to_json.

Returns:

String representation of value. None if there is no default value.

Return type:

str

Raises:
  • TypeError – If value is not a supported type.

  • ValueError – If value is the correct type but an invalid value.

Parameters:

value (Any)

class ConnectorType

Bases: object

Interface for classes representing connector types.

Classes which implement this interface can be passed as types for WorkflowArgumentParser.declare_input_connector() and WorkflowArgumentParser.declare_output_connector().

classmethod data_type()

The type of data supported by this port.

Return type:

DataType

classmethod type_string()

The data type when generating ports.

Returns:

String representation of the type to report to the workflow.

Return type:

str

classmethod json_type_string()

The type string expected to be in JSON inputs.

This is the same as the type string by default, but for certain cases this differs.

Return type:

str

classmethod json_dimensionality()

The dimensionality of the input in JSON.

This must either be ‘Single’ or ‘List’. It is ‘Single’ by default.

Return type:

str

classmethod from_string(string_value)

Convert a string value from an input connector to the corresponding python type and returns it.

Returns:

The python representation of the string value.

Return type:

any

Raises:
  • TypeError – If string_value is not a supported type.

  • ValueError – If string_value is the correct type but an invalid value.

Parameters:

string_value (str)

classmethod to_json(value)

Converts the value to a json-serializable value.

This is used to convert python values to json values to be passed to the workflow for output connectors.

Returns:

Json serializable representation of value.

Return type:

json-serializable

Raises:
  • TypeError – If value is not a supported type.

  • ValueError – If value is the correct type but an invalid value.

Parameters:

value (Any)

classmethod to_default_json(value)

Converts the value to a json serializable default.

This allows for specifying a different representation for default values. The output of this function should not include lists.

Overwrite this function to raise an error to indicate that default values are not supported.

By default this calls to_json.

Returns:

String representation of value. None if there is no default value.

Return type:

str

Raises:
  • TypeError – If value is not a supported type.

  • ValueError – If value is the correct type but an invalid value.

Parameters:

value (Any)

classmethod to_workflow_native(value)

Convert value to JSON using the modern format.

Parameters:

value (Any)

Return type:

JsonValues