Orchest SDK reference#

Note

πŸ’‘ The Orchest SDK comes pre-installed when using Orchest.

To see how to use the SDK in different progamming languages, refer to the dedicated section on data passing.

orchest.transfer#

Transfer mechanisms to output data and get data.

class orchest.transfer.Serialization(value)#

Possible types of serialization.

Types are:

  • ARROW_TABLE

  • ARROW_BATCH

  • PICKLE

orchest.transfer.get_inputs(ignore_failure: bool = False, verbose: bool = False) Dict[str, Any]#

Gets all data sent from incoming steps.

Warning

Only call get_inputs() once! When auto eviction is configured data might no longer be available. Either cache the data or maintain a copy yourself.

Parameters:
  • ignore_failure – If True then the returned result can have None values if the data of a step could not be retrieved. If False, then this function will fail if any of the incoming steps’s data could not be retrieved. Example: [None, "Hello World!"] vs OutputNotFoundError

  • verbose – If True print all the steps from which the current step has retrieved data.

Returns:

Dictionary with input data for this step. We differentiate between two cases:

  • Named data, which is data that was outputted with a name by any parent step. Named data can be retrieved through the dictionary by its name, e.g. data = get_inputs()["my_name"]. Name collisions will raise an InputNameCollisionError.

  • Unnamed data, which is an ordered list containing all the data that was outputted without a name by the parent steps. Unnamed data can be retrieved by accessing the reserved "unnamed" key. The order of this list depends on the order of the parent steps of the node, which is visible through the GUI, refer to the this section for more details.

Example:

# It does not matter how the data was outputted by parent
# steps. It is resolved automatically by the `get_inputs`
# method.
{
    "unnamed" : ["Hello World!", (3, 4)],
    "named_1" : "mystring",
    "named_2" : [1, 2, 3]
}

Raises:
  • InputNameCollisionError – Multiple steps have outputted data with the same name.

  • OutputNotFoundError – If no output can be found of the given step_uuid. Either no output was generated or the in-memory object store died (and therefore lost all its data).

  • StepUUIDResolveError – The step’s UUID cannot be resolved and thus it cannot determine what inputs to get.

orchest.transfer.output(data: Any, name: Optional[str]) None#

Outputs data so that it can be retrieved by the next step.

Note

Calling output() multiple times within the same step will overwrite the output, even when using a different output name. You therefore want to be only calling the function once.

Parameters:
  • data – Data to output.

  • name – Name of the output data. As a string, it becomes the name of the data, when None, the data is considered nameless. This affects the way the data can be later retrieved using get_inputs().

Raises:
  • DataInvalidNameError – The name of the output data is invalid, e.g because it is a reserved name ("unnamed") or because it contains a reserved substring.

  • OrchestNetworkError – Could not connect to the Config.STORE_SOCKET_NAME, because it does not exist. Which might be because the specified value was wrong or the store died.

  • StepUUIDResolveError – The step’s UUID cannot be resolved and thus data cannot be outputted.

Example

>>> data = "Data I would like to use in my next step"
>>> output(data, name="my_data")
orchest.transfer.output_to_disk(data: Any, name: Optional[str], serialization: Optional[Serialization] = None) None#

Outputs data to disk.

Note

Calling output_to_disk() multiple times within the same script will overwrite the output, even when using a different output name. You therefore want to be only calling the function once.

To manage outputing the data to disk, this function has a side effect:

  • Writes to a HEAD file alongside the actual data file. This file serves as a protocol that returns the timestamp of the latest write to disk via this function alongside the used serialization.

Parameters:
  • data – Data to output to disk.

  • name – Name of the output data. As a string, it becomes the name of the data, when None, the data is considered nameless. This affects the way the data can be later retrieved using get_inputs().

  • serialization – Serialization of the data in case it is already serialized. For possible values see Serialization.

Raises:
  • DataInvalidNameError – The name of the output data is invalid, e.g because it is a reserved name ("unnamed") or because it contains a reserved substring.

  • PipelineDefinitionNotFoundError – If the pipeline definition file could not be found.

  • StepUUIDResolveError – The step’s UUID cannot be resolved and thus it cannot determine where to output data to.

Example

>>> data = "Data I would like to use in my next step"
>>> output_to_disk(data, name="my_data")

orchest.parameters#

Module to interact with the parameter values of pipeline steps.

Handle to parameters that are stored in the corresponding pipeline definition file, e.g. pipeline.orchest.

orchest.parameters.get_params() Tuple[dict, dict]#

Gets the parameters of the current step and the pipeline.

Returns:

A tuple of two elements, where the first is the parameters of the current step, the second is the parameters of the pipeline.

orchest.parameters.get_pipeline_param(name: str, default: Optional[Any] = None) Any#

Gets a pipeline parameter by name.

Parameters:

name – The pipeline parameter to get.

Returns:

The value that was mapped to the pipeline parameter name.

orchest.parameters.get_step_param(name: str, default: Optional[Any] = None) Any#

Gets a parameter of the current step by name.

Parameters:

name – The step parameter to get.

Returns:

The value that was mapped to the step parameter name.

orchest.services#

Module to retrieve information about services.

Service specifications are stored in the corresponding pipeline definition file e.g. pipeline.orchest.

orchest.services.get_service(name) Dict[str, Any]#

Gets the service of the pipeline by name.

Returns:

A dictionary describing a service.

Example:

{
    "internal_url": service-<service-name>-<identifier>,
    "external_urls": {
        80: "http://{host_name}:{port}/service"
        "-<service-name>-<identifier>_80"
    }
    "base_paths": {
        80: "/service-<service-name>-<identifier>_80"
    }
    ... # user specified service fields
}

where each port specified in the service specification constitutes to one element in the external_urls and base_paths mappings, that map port to external urls and ports to base paths respectively.

Raises:

ServiceNotFoundError – The service given by name name could not be found.

orchest.services.get_services() Dict[str, Dict[str, Any]]#

Gets the services of the pipeline.

Returns:

A dictionary of services, mapping service name to service description. For an example of a service dictionary, see get_service().