Communication with an external application

The communication with an external application is based on JSON-RPC messages.

Pipeline Manager supports two ways of defining external application:

Communication protocol

The application layer protocol specifies two blocks:

  • size - four first bytes form an unsigned integer and tell the size of the content of the message in bytes.

  • content - the rest of the message holding additional data in JSON-RPC format described in API Specification.

The size and content are stored in big-endian.

External Backend Application

This is a core concept of server-app Pipeline Manager mode.

Pipeline Manager implements a TCP server that is listening on a specified port and waiting for the client to connect. Pipeline Manager frontend sends JSON-RPC requests to this server through SocketIO, which redirects messages to connected client for specific actions described in this chapter. External application can also request actions from Pipeline Manager in similar manner.

Frontend / Backend / External application

By default, Pipeline Manager will wait for an external application to connect and then request the specification. If the connection is established successfully, Pipeline Manager frontend will check if external application is still connected every 0.5 second. Apart from that, both Pipeline Manager frontend and external application can send requests which pass through Pipeline Manager backend.

sequenceDiagram
    Note over Frontend,Backend: Pipeline Manager (SocketIO)
    Note over External App: Pipeline Manager Backend Communication
    Frontend->>Backend: status_get
    Backend->>Frontend: status
    Frontend->>+Backend: external_app_connect
    Note over Backend,External App: BSD socket
    External App->>Backend: connect_socket
    Backend->>-Frontend: MessageType.OK
    Frontend->>+Backend: specification_get
    Backend->>External App: specification_get
    External App->>Backend: specification
    Backend->>-Frontend: MessageType.OK + specification
    loop Every 0.5s
        Frontend->>Backend: status_get
        Backend->>Frontend: status
    end
    par External App API
        Frontend->>+Backend: request
        Backend->>+External App: redirected request
        External App->>-Backend: response
        Backend->>-Frontend: redirected response
    and Frontend API
        External App->>+Backend: request
        Backend->>+Frontend: redirected request
        Frontend->>-Backend: response
        Backend->>-External App: redirected response
    end

As Pipeline Manager part of communication is done with SocketIO, it is based on events, which are precisely defined for both sides and can trigger different actions.

Frontend listens to:

  • api – received messages are JSON-RPC requests, they are validated with specification, executed and generated responds are resend,

  • api-response – received messages are JSON-RPC responses, they are also validated and returned as result of previous request.

Backend implements the following events:

  • backend-api – receives all JSON-RPC requests, runs methods and responds,

  • external-api – redirects messages to external application through BSD socket.

On the other hand, communication between backend and external application is done through BSD socket. To manage this, both sides run socket listener as separate coroutine task, which waits for messages and responds or redirects them.

External Frontend / Pipeline Manager

If the Pipeline Manager is wrapped with another frontend (see Frontend Features for details), the communication can be established with POST requests.

sequenceDiagram
    Note over External Frontend,Frontend: postMessage
    par Frontend API
        External Frontend->>Frontend: request
        Frontend->>External Frontend: response
    and Backend/External API
        External Frontend->>+Frontend: request
        Note over Frontend,Backend & External App: Pipeline Manager (SocketIO)
        Frontend->>+Backend & External App: redirected request
        Backend & External App->>-Frontend: response
        Frontend->>-External Frontend: redirected response
    end

Request structure

Following communication structure diagram below, we have:

C4Deployment
    Deployment_Node(cf, "External Frontend", "") {
        Container(external-post-message, "postMessage")
    }
    Deployment_Node(pm, "Pipeline Manager", "") {
        Deployment_Node(front, "Frontend", "") {
            Container(front-post-message, "postMessage")
            Deployment_Node(socketio, "SocketIO", "") {
                Container(front-socket, "SocketIO")
                Deployment_Node(front-event, "Events", "") {
                    Container(front-api, "api")
                    Container(front-response-api, "api-response")
                }
            }
        }
        Deployment_Node(back, "Backend", "") {
            Deployment_Node(flask, "Python-SocketIO events", "") {
                Container(flask-backend-api, "backend-api")
                Container(flask-external-api, "external-api")
            }
            Deployment_Node(flask-task, "Coroutine task", "") {
                Container(back-socket, "BSD socket listener")
            }
        }
    }
    Deployment_Node(pmbc, "Pipeline Manager Backend Communication", "") {
        Deployment_Node(pmbc-socket, "Socket", "") {
            Container(pmbc-socket, "BSD socket")
            Deployment_Node(pmbc-task, "Coroutine task", "") {
                Container(pmbc-listener, "BSD socket listener")
            }
        }
    }
    %% frontend to frontend
    BiRel(external-post-message, front-post-message, "JSON-RPC requests and frontend responses")
    Rel(front-post-message, front-socket, "Redirected requests")
    Rel(front-response-api, external-post-message, "Redirected responses")
    UpdateRelStyle(external-post-message, front-post-message, $offsetX="-55", $offsetY="-30")
    UpdateRelStyle(front-post-message, front-socket, front-post-message, $offsetX="-55", $offsetY="-30")
    %% frontend to backend request
    Rel(front-socket, flask-backend-api, "JSON-RPC request")
    Rel(flask-backend-api, front-response-api, "JSON-RPC response")
    UpdateRelStyle(front-socket, flask-backend-api, $lineColor="var(--md-code-hl-keyword-color)", $textColor="var(--md-code-hl-keyword-color)", $offsetY="-15")
    UpdateRelStyle(flask-backend-api, front-response-api, $lineColor="var(--md-code-hl-keyword-color)", $textColor="var(--md-code-hl-keyword-color)", $offsetX="-50", $offsetY="55")
    %% frontend to external app request
    Rel(front-socket, flask-external-api, "JSON-RPC request")
    Rel(flask-external-api, pmbc-listener, "Redirected requests and responses")
    Rel(pmbc-listener, back-socket, "JSON-RPC response")
    Rel(back-socket, front-response-api, "Redirected response")
    UpdateRelStyle(front-socket, flask-external-api, $lineColor="var(--md-code-hl-number-color)", $textColor="var(--md-code-hl-number-color)")
    UpdateRelStyle(flask-external-api, pmbc-listener, $lineColor="var(--md-code-hl-name-color)", $textColor="var(--md-code-hl-name-color)", $offsetX="-10", $offsetY="-10")
    UpdateRelStyle(pmbc-listener, back-socket, $lineColor="var(--md-code-hl-number-color)", $textColor="var(--md-code-hl-number-color)", $offsetX="25", $offsetY="-25")
    UpdateRelStyle(back-socket, front-response-api, $lineColor="var(--md-code-hl-number-color)", $textColor="var(--md-code-hl-number-color)", $offsetX="-10", $offsetY="20")
    %% external app to frontend request
    Rel(pmbc-socket, back-socket, "JSON-RPC request")
    Rel(back-socket, front-api, "Redirected request")
    Rel(front-api, flask-external-api, "JSON-RPC response")
    Rel(pmbc-listener, pmbc-socket, "Received response")
    UpdateRelStyle(pmbc-socket, back-socket, $textColor="var(--md-code-hl-function-color)", $lineColor="var(--md-code-hl-function-color)", $offsetX="-10", $offsetY="15")
    UpdateRelStyle(back-socket, front-api, $textColor="var(--md-code-hl-function-color)", $lineColor="var(--md-code-hl-function-color)", $offsetX="45")
    UpdateRelStyle(front-api, flask-external-api, $textColor="var(--md-code-hl-function-color)", $lineColor="var(--md-code-hl-function-color)", $offsetX="-65", $offsetY="-30")
    UpdateRelStyle(pmbc-listener, pmbc-socket, $textColor="var(--md-code-hl-function-color)", $lineColor="var(--md-code-hl-function-color)", $offsetX="5", $offsetY="-30")

    UpdateLayoutConfig($c4ShapeInRow="1", $c4BoundaryInRow="3")

External Frontend Application

If the Pipeline Manager is used as an iframe, a website that wraps it can implement an External Application.

Similartly to External Frontend Communication, data transfer relies on POST requests: both requests and responses use MessageEvent (see Frontend Features for details).

This application type can be enabled dynamically via dedicated register_external_frontend Frontend API request. This is possible for both static-html and server-app modes. Currently, in the latter case, external backend application will be overridden with the frontend one.

Request structure

sequenceDiagram
    Note over External Frontend,Pipeline Manager Frontend: postMessage
    par Frontend API
        External Frontend->>Pipeline Manager Frontend: request
        Pipeline Manager Frontend->>External Frontend: response
    and External API
        Pipeline Manager Frontend->>External Frontend: request
        External Frontend->>Pipeline Manager Frontend: response
    end

Response messages types - sent by the external application

OK

Message of type OK (0) is used to indicate a success and optionally includes an answer to a previous request. Its content may vary depending on the request type.

ERROR

Message of type ERROR (1) is used to indicate a failure and optionally includes an answer to a previous request. Its content may vary depending on the answered request.

PROGRESS

Message of optional type PROGRESS (2) is used to inform Pipeline Manager about the status of a running dataflow. The PROGRESS message type can only be used once a message of type RUN is received and can be sent multiple times before sending a final response message of type either ERROR or OK that indicates the end of the run. The progress information is conveyed in content using a number ranging 0 - 100 encoded in UTF-8 that signals the percentage of completion of the run. See RUN for more information.

WARNING

Message of type WARNING (3) is used to indicate a success but also alerts of a condition that might cause a problem in the future. It optionally includes an answer to a previous request. Its content may vary depending on the answered request.

API Specification

Frontend API

frontend_status_get

Returns status of the frontend

  • params: Refer to null_or_empty.

  • result (object): Description of frontend status. Cannot contain additional properties.

    • status (string, required): Status.

frontend_specification_get

Returns specification used by frontend

  • params (object): Parameters for specification request. Cannot contain additional properties.

    • graph (boolean): Specifies whether graph should be returned along with the specification. Default: false.

    • minify (boolean): Specifies whether the returned specification should be minified. Default: false.

  • result: Refer to specification_object.

dialog_template_add

Request to register user dialog box or override existing one.

  • params (object)

    • name (string): Name of the dialog box.

    • box

  • result (object)

    • added (array): List of added dialog boxes.

      • Items (string): Name of the dialog box.

    • removed (array): List of removed dialog boxes.

      • Items (string): Name of the dialog box.

    • overridden (array): List of overridden dialog boxes.

      • Items (string): Name of the dialog box.

dialog_open

Request opening dialog box by frontend.

  • params (object): Cannot contain additional properties.

    • name (string, required): Name of the dialog box.

  • result: Refer to dialog_box_output.

graph_get

Returns dataflow used by frontend

  • params ([object, null]): Serialization options. Cannot contain additional properties.

    • readonly (boolean): Specifies whether the returned dataflow should be marked as read only. Default: false.

    • hideHud (boolean): Specifies whether the returned dataflow should have the HUD disabled. Default: false.

    • position (boolean): Specifies whether the current view location should be included. Default: false.

    • hideLayers (boolean): Specifies whether information about hidden layers should be included. Default: false.

  • result: Refer to dataflow_object.

node_get

Procedure to read node state

  • params

  • result (object): Cannot contain additional properties.

    • node (object, required): State of the node.

properties_get

Procedure to alter values of a node

  • params (object): Cannot contain unevaluated properties.

    • All of

    • properties ([array, null]): Properties which values are going to be read specified by either a name of id. If undefined then all properties are returned.

      • Items (object)

        • One of

          • object: Cannot contain additional properties.

            • id (string, required): Id of the property to read.

          • object: Cannot contain additional properties.

            • name (string, required): Name of the property to read.

  • result (array)

    • Items (object): Values of the searched properties. Cannot contain additional properties.

      • id (string, required): Id of the property.

      • name (string, required): Name of the property.

      • value: Value of the property. Its type depends on the property.

properties_change

Procedure to alter properties of a node

interfaces_change

Procedure to alter interfaces of a node

name_change

Procedure to alter the name of the node.

position_change

Procedure to alter position of a node

nodes_change

Procedure to add and delete nodes

connections_change

Procedure to add and delete connections

graph_change

Procedure to add and delete nodes

progress_change

Notification with progress of job ran by external application

  • params (object): Parameters for notification. Cannot contain additional properties.

    • method (string, required): Name of the method used to run the job.

    • progress (number, required): Progress of job ran be external application. If between 0 and 100 progress will be set and if -1, animation will ran.

metadata_change

Updates the editor’s metadata

viewport_center

Center the editor

terminal_add

Create new terminal instance

  • params (object): Parameters for request.

    • name (string, required): Unique name for the new terminal instance. This name is used for any communication.

    • readonly (boolean): Specifies whether the terminal should be read-only, or editable by user. Default: true.

  • result: Refer to null_or_empty.

terminal_remove

Create new terminal instance

  • params (object): Parameters for request.

    • name (string, required): Name of the terminal to remove.

  • result: Refer to null_or_empty.

terminal_write

Writes a message line to a terminal instance. Allows to send both text and hterm’s control sequences. For more details on available control sequences check hterm Control Sequences.

Warning

Since data is sent in JSON format, the hexadecimal values need to be escaped with \u, not \x, e.g. \u001b[38:2:238:178:17mexample.

  • params (object): Parameters for request.

    • name (string, required): Name of the terminal to which the message is written.

    • message (string, required): Message to be written to the terminal.

  • result: Refer to null_or_empty.

terminal_clear

Clears a terminal with a given name

  • params (object)

    • name (string): Name of the terminal to clear. If the name is not provided, the main terminal is cleared.

  • result: Refer to null_or_empty.

terminal_hide

Hides a terminal panel

terminal_show

  • params (object): Parameters for request.

    • name (string): Name of the terminal to show. If the name is not provided, the main terminal is chosen.

  • result: Refer to null_or_empty.

terminal_view

Configures the layout of the terminal panel

  • params (object): Parameters for request.

    • names (array): Names of the terminal to show. If the parameter is empty, then the terminal view is unmodified.

      • Items (string): Name of the terminal.

    • clearButton (boolean): Specifies whether to ‘Clear terminal’ button should be displayed. If not specified, the state of the clear button is not modified.

  • result: Refer to null_or_empty.

terminal_get_instances

Configures the layout of the terminal panel

  • params: Refer to null_or_empty.

  • result (array): Existing terminals.

    • Items (string): Name of the terminal.

notification_send

Sends a notification to the frontend. It will display the message both in the notifications and in the default terminal

  • params (object): Parameters for notification.

    • type: Type of the notification. Must be one of: ["error", "warning", "info"].

    • title (string, required): Title of the notification, appearing both in the terminal and notification.

    • details (string, required): Details of the notification, displayed only in the terminal.

    • timestamp (string): Notification timestamp, if not provided, timestamp will be automatically generated (pass non-null falsy value to disable).

  • result: Refer to null_or_empty.

specification_change

Procedure to update specification

specification_graph_change

Procedure to update specification and dataflow

specification_preprocess

Handles preprocessor specification directives

specification_expand

nodes_highlight

Procedure to highlight specified nodes in the editor

register_external_frontend

Register external frontend in the Pipeline Manager frontend, available only through ‘postMessage’ interface

return_from_subgraph

Returns from subgraph if currently in one

  • params: Refer to null_or_empty.

  • result (object): Specifies whether the editor was in subgraph and returned. Cannot contain additional properties.

    • has_returned (boolean, required): Has returned from subgraph.

notifications_get_verbosity

Obtains current notifications verbosity level or all possible values

  • params (object)

    • all (boolean): Set all to true to obtain all possible values.

  • result ([object, array]): Current notification verbosity level or a list of all possible values.

    • Items (string)

    • verbosity ([string])

notifications_set_verbosity

Sets notifications verbosity level

  • params (object): The new verbosity level, pass null to obtain possible values.

    • verbosity ([string])

  • result (null)

connections_get_style

Obtains current connections style, or a list of all possible values

  • params (object)

    • all (boolean): Set all to true to obtain all possible values.

  • result ([object, array]): Current connections style or a list of all possible values.

    • Items (string)

    • style (string)

connections_set_style

Sets connections style

  • params (object): The new connection style.

    • style (string)

  • result (null)

background_get_grid_size

Obtains current background grid size

  • params: Refer to null_or_empty.

  • result (object): Current background grid size.

    • size (integer)

background_set_grid_size

Sets background grid size

  • params (object): The new background grid size.

    • size (integer)

  • result (null)

autolayout_apply

Apply autolayout algorithm

interfaces_swap

Swap interfaces

interfaces_hide_unconnected

Hides unconnected interfaces

interfaces_show_hidden

Shows previously hidden interfaces

editor_clear

Clears editor

layers_get_list

Obtains list of available layers

  • params: Refer to null_or_empty.

  • result (array): List of available layers.

    • Items (string)

layer_get_hidden

Obtains layer state

  • params (object)

    • name (string): Layer name.

  • result (object): Current layer state.

    • hidden (boolean)

layer_set_hidden

Sets layer state

  • params (object)

    • name (string): Layer name.

    • hidden (boolean): Hide or unhide layer.

  • result (null)

panel_toggle

Toggle navbar panels

  • params (object)

    • name ([string, null]): Panel name, pass null to obtain a list of possible values.

  • result ([array, null]): Either a null or a list of possible name values.

    • Items (string)

fullscreen_toggle

Toggle editor fullscreen mode

search_get_query

Obtains the current search query

  • params: Refer to null_or_empty.

  • result (object)

    • query ([string, null]): Current search query.

search_set_query

Sets the current search query

  • params (object)

    • query ([string, null]): New search query, pass null to clear search.

  • result: Refer to null_or_empty.

graph_add

Adds a new empty graph to the editor

  • params ([object, null]): Parameters for request. Cannot contain additional properties.

    • name (string): Name of the new graph. Default: "New Graph".

  • result (object): Information about the created graph. Cannot contain additional properties.

    • graph_id (string, required): ID of the created graph.

graph_set_name

Renames a graph

  • params (object): Parameters for request. Cannot contain additional properties.

    • name (string, required): New name of the graph.

    • graph_id (string): ID of the graph to rename, defaults to the currently displayed graph.

  • result: Refer to null_or_empty.

graph_export_image

Renders the currently displayed graph to an image

  • params (object): Parameters for request. Cannot contain additional properties.

    • format: Format of the image. Must be one of: ["png", "svg"].

    • width (integer): Width of the PNG image in pixels, ignored for SVG. Minimum: 1. Maximum: 16384. Default: 1920.

    • height (integer): Height of the PNG image in pixels, ignored for SVG. Minimum: 1. Maximum: 16384. Default: 1080.

  • result (object): Rendered image. Cannot contain additional properties.

    • format: Format of the image. Must be one of: ["png", "svg"].

    • data (string, required): Image encoded as a data URL.

layout_get

Returns the layout of a graph.

  • params ([object, null]): Parameters for request. Cannot contain additional properties.

    • graph_id (string): ID of the graph, defaults to the currently displayed graph.

  • result: Refer to graph_layout.

layout_set

Applies a layout to a graph.

  • params: Refer to graph_layout.

  • result (object): Result of applying the layout. Cannot contain additional properties.

    • errors (array, required): Errors that occurred while applying the layout.

      • Items (string)

Backend API

status_get

Returns status of connection with external application

  • params: Refer to null_or_empty.

  • result (object): Description of backend status. Cannot contain additional properties.

    • status (object, required): Status. Cannot contain additional properties.

      • connected (boolean, required): Connection with external application.

external_app_connect

Request to wait till connection with external application is established

connected_frontends_get

Request the number of connected fronteds

  • params: Refer to null_or_empty.

  • result (object): Cannot contain additional properties.

    • connections (number, required): Number of connections.

External App API

specification_get

Request specification used by external application

app_capabilities_get

Request external application capabilities

dialog_boxes_get

Request external application dialog boxes

dataflow_import

Request to convert dataflow in external app to Pipeline Manager format and import it

  • params (object): Parameters for request. Cannot contain additional properties.

    • external_application_dataflow (string, required): Dataflow in external application format. If loaded file cannot be represented as text, it will be sent as base64 string. To make sure received data are in readable format convert_message_to_string from pipeline_manager_backend_communication.utils can be used. Optionally, for conversion to bytes convert_message_to_bytes function is available.

    • mime (string, required): MIME type.

    • base64 (boolean, required): Specifies whether external_application_dataflow is in byte64 format.

  • result: Refer to external_endpoint_return_type.

dataflow_validate

Request external application to validate dataflow

dataflow_run

Request external application to run dataflow

dataflow_stop

Request external application to run dataflow

  • params (object): Parameters for stopping dataflow. Cannot contain additional properties.

    • method (string, required): Name of the method used to start run.

  • result: Refer to external_endpoint_return_type.

dataflow_export

Request external application to export dataflow

  • params: Refer to dataflow_object.

  • result (object): Common type returned by external app. Cannot contain additional properties.

    • type (number, required): MessageType specifying success or error.

    • content ([object, string]): Exported dataflow, which is then saved by the frontend user. Should be either a json object, or a base64 encoded string. If any error occurred then it should contain a proper message.

    • filename (string): Suggested filename used to save the file.

frontend_on_connect

Request sent when Pipeline Manager frontend connects to backend and notifyWhenChanged option is enabled in the metadata section of specification.

properties_on_change

Request sent when properties of any node change and notifyWhenChanged option is enabled in the metadata section of specification.

interfaces_on_change

Request sent when interface of any node changes and notifyWhenChanged option is enabled in the metadata section of specification.

name_on_change

Request sent when node name was changed and notifyWhenChanged option is enabled in the metadata section of specification.

position_on_change

Request sent when position of any node changes and notifyWhenChanged option is enabled in the metadata section of specification.

nodes_on_change

Request sent when node was added or deleted and notifyWhenChanged option is enabled in the metadata section of specification.

connections_on_change

Request sent when connection was added or deleted and notifyWhenChanged option is enabled in the metadata section of specification.

graph_on_change

Request sent when whole dataflow changed, e.g. when dataflow is loaded, and notifyWhenChanged option is enabled in the metadata section of specification.

specification_on_change

Request sent when whole specification changed, e.g. when node type is modified, and notifyWhenChanged option is enabled in the metadata section of specification.

metadata_on_change

Request sent when metadata was changed, and notifyWhenChanged option is enabled in the metadata section of specification.

viewport_on_center

Request sent when editor was centered and notifyWhenChanged option is enabled in the metadata section of specification.

dialog_on_submit

Request sent by the frontend when custom user dialog is closed

terminal_read

Request sent by the frontend when terminal received an input

  • params (object): Parameters for request.

    • name (string, required): Name of the terminal to which the message was written. Terminal has to be not read-only.

    • message (string, required): Terminal input.

  • result: Refer to null_or_empty.

nodes_on_highlight

Request sent when node was either selected or unselected and notifyWhenChanged option is enabled in the metadata section of specification.

button_click

Request send when button node property was pressed

  • params (object): Parameters for request.

    • id (string, required): ID of the property.

    • value ([object, null], required): Value of the property.

  • result: Refer to null_or_empty.

Common Types

empty

  • object: Empty object definition. Cannot contain additional properties.

null_or_empty

  • [object, null]: Empty or missing object definition. Cannot contain additional properties.

unnested_dialog_box_template

  • object: A template that defines unnested dialog box inputs.

    • name (string, required): A title of the input visible to a user.

    • type: A type of the input. Must be one of: ["text", "number", "int", "bool", "select", "dynamic", "nested"].

    • default ([string, number, boolean, array, object]): A default value of the input.

    • min (number): A minimal value for numerical types.

    • max (number): A maximum value for numerical types.

dialog_box_template

  • : A template that defines dialog box inputs.

dialog_box

  • object: Schema that defines dialog box template.

    • title (string): Title of the dialog box.

    • confirmText (string): Name of confirmation button.

    • template (object): A template of the dialog box. Can contain additional properties.

dialog_boxes

  • object: Schema that defines dialog boxes template. Can contain additional properties.

dialog_box_output

  • object: Parameters for request.

    • name (string): A name of used user dialog.

    • data (object, required): Data read by user dialog.

node_object

  • object: Schema that identifies a node in a graph.

    • graph_id (string, required): Id of the graph.

    • node_id (string, required): Id of the node.

urloverrides

  • object: Override metadata URLs in provided specification.

    • ^.*$ (string)

loadingScreen

  • boolean: Show loading screen. Default: false.

tryMinify

  • boolean: Try to minify specification if a dataflow or entry graph is provided. Default: false.

dataflow_or_url

  • [object, string]: JSON or link to the remote JSON with graph definition.

dataflow_object

  • object: Definition containing dataflow object. Cannot contain additional properties.

    • dataflow (object): JSON with graph definition in PM format.

specification

  • object: JSON with specification definition in PM format.

specification_or_url

  • [object, string]: JSON or link to the remote JSON with specification.

specification_object

  • object: Definition containing specification object. Cannot contain additional properties.

properties_diff

  • object: Schema that represents differences in properties of the node. Cannot contain unevaluated properties.

    • All of

    • properties (array, required): Properties to change specified by either a name or id.

      • Items (object)

        • One of

          • object: Cannot contain additional properties.

            • id (string, required): Id of the property to alter.

            • new_value: New value of the property.

          • object: Cannot contain additional properties.

            • name (string, required): Name of the property to alter.

            • new_value: New value of the property.

interfaces_diff

  • object: Schema that represents differences in interfaces of the node. Cannot contain unevaluated properties.

    • All of

    • interfaces (array, required): Interfaces to change specified by either a name or id.

      • Items (object)

        • One of

          • object: Cannot contain additional properties.

            • id (string, required): Id of the interface to alter.

            • externalName (string): New external name of the interface.

          • object: Cannot contain additional properties.

            • name (string, required): Name of the interface to alter.

            • externalName (string): New external name of the interface.

name_diff

  • object: Schema that represent differences in title change. Cannot contain unevaluated properties.

    • All of

    • name (string, required): Name of the node to change.

position_diff

  • object: Schema that represent differences in position of the node. Cannot contain unevaluated properties.

    • All of

    • position (object, required): Position to change specified by either a name or id.

      • x (number): X coordinate.

      • y (number): Y coordinate.

nodes_diff

  • object: Schema that represents nodes’ differences in a graph.

    • graph_id (string, required): Id of the graph.

    • nodes (object, required): .

      • added (array): List with created nodes.

        • Items (object): JSON with node definition.

      • deleted (array): List with removed nodes.

        • Items (string): ID of node to delete.

    • remove_with_connections (boolean): Should node be removed with connections.

connections_diff

  • object: Schema that represents connections’ differences in a graph.

    • graph_id (string, required): Id of the graph.

    • connections (object, required): .

      • added (array): List with created connections.

        • Items (object): JSON with connection definition.

      • deleted (array): List with removed connections.

        • Items (object): Connection defined with its beginning and end.

          • from (string): ID of output interface.

          • to (string): ID of input interface.

highlight_diff

  • object: Schema that represents the difference in node selection in the editor.

    • graph_id (string, required): Id of the graph.

    • nodes (object, required): .

      • selected (array): List with selected nodes.

        • Items (string): ID of selected node.

      • unselected (array): List with unselected nodes.

        • Items (string): ID of unselected node.

metadata

  • object: Type with PM metadata. Cannot contain additional properties.

    • metadata (object, required): JSON with metadata description in PM format.

external_endpoint_return_type

  • object: Common type returned by external app. Cannot contain additional properties.

    • type (number, required): MessageType specifying success, error or progress.

    • content ([object, string]): Additional information, either message or dataflow.

navbar_items

  • array: List of buttons displayed in the application navbar. Default: [].

    • Items (object): Description of a single button. Cannot contain additional properties.

      • Any of

          • procedureName (string, required): Name of the procedure used when button is pressed. The currently displayed graph is used as an argument.

          • openUrl (string, required): URL opened in a new tab when the button starts its procedure, e.g. a page following its progress. Opened on the click itself, so that browsers do not block it as a popup.

      • name (string, required): Name displayed in the tooltip.

      • stopName (string): Name displayed in the tooltip when the corresponding procedure is running and is stoppable. If not specified simply Stop is added as a prefix to the name.

      • iconName (string, required): Name of the icon displayed in the navbar. Name should correspond to a file in the asset directory or to an icon in frontend/src/icons.

      • procedureName (string): Name of the procedure used when button is pressed. The currently displayed graph is used as an argument.

      • allowToRunInParallelWith (array): List of procedures which can be run when this navbarItem is still running. Default: [].

        • Items (string): procedureName of navbarItem.

      • requireResponse (boolean): Flag determining whether response from external application should be awaited when running the procedure. Default: true.

      • openUrl (string): URL opened in a new tab when the button starts its procedure, e.g. a page following its progress. Opened on the click itself, so that browsers do not block it as a popup.

graph_layout

  • object: Layout of a graph. Cannot contain additional properties.

    • graph_id (string): ID of the graph the layout belongs to, defaults to the currently displayed graph.

    • layout (object, required): Mapping from node IDs to their layout. Can contain additional properties.

      • Additional properties (object)

        • position (object, required): Position of the node.

          • x (number, required): X coordinate.

          • y (number, required): Y coordinate.

        • style ([string, array]): A style defined by ‘styles’ in metadata.

        • interfaces (object, required): Mapping from interface names to their placement. Can contain additional properties.

          • Additional properties (object)

            • side: Side of the node on which the interface is rendered. Must be one of: ["left", "right", "top", "bottom"].

            • sidePosition (number): Position of the interface on its side.

Custom procedures

External application can define new remote procedures, which will be called by custom Navbar button. To use it, procedure’s name has to start with custom_ prefix, e.g. custom_simulate_design.

Such remote procedures can be called from the frontend using custom Navbar buttons defined in the metadata’s navbarItems field, e.g.:

{
    "name": "Simulate design",
    "stopName": "Stop simulation",
    "iconName": "Run",
    "procedureName": "custom_simulate_design"
}

Custom procedure has the same parameters and return type as dataflow_run method.

Context menus

An external application can also define custom remote procedures to be called in the context menu of node. There are three scopes for such an action: all nodes, subgraph nodes and a given node type. They are specified by including a Context menu item in, respectively, customMenuActions or subgraphCustomMenuActions fields of metadata or in the contextMenuActions field of a given node.

Context menu procedures have only one parameter: node_id, which is the id of the clicked node. The expected return type is dataflow_export for procedures with the custom_download prefix in their name, and dataflow_run for all other procedures.

Custom dialog box

Custom dialog box definition

An external application can also define custom dialog boxes for various use cases. When connection with Pipeline Manager server is established it sends dialog_boxes_get request to get user credentials with all custom dialog boxes used by the application. Example dictionary defining simple form:

 {
    "optimizationTask": {
        "title": "Optimization task",
        "confirmText": "Ok",
        "template": {
            "taskName": {
                "name": "task",
                "type": "text",
                "default": "Foo"
            },
            "numberOfIterations": {
                "name": "iterations",
                "type": "int",
                "default": 10
            },
            "earlyStopping": {
                "name": "early stopping",
                "type": "bool",
                "default": false
            },
            "algorithmsSelect": {
                "name": "algorithms",
                "type": "select",
                "items": {
                    "CG": "cg",
                    "BFGS": "bfgs",
                    "Newton-CG": "newton"
                },
                "default": "newton"
            },
            "portDynamic": {
                "name": "dynamo",
                "type": "dynamic",
                "template": {
                    "intPort": {"name": "port", "type": "int"}
                }
            },
            "attrNested": {
                "name": "Additional attributes",
                "type": "nested",
                "template": {
                    "attrName": {"name": "name", "type": "text"},
                    "attrId": {"name": "id", "type": "int"}
                }
            }
        }
    }
}

Every entry in the dictionary defines an object with the name later used to open a dialog box, in this case it is the dialog box with name optimizationTask. Each dialog definition consists of:

  • title - a name of the dialog box’s window

  • confirmText - a title of the dialog box’s confirm button

  • template - a definition for every input in the dialog box.

The user dialog box template allows for defining input’s name and its type. Object name represents internal name of the input in which it will be returned, see Read data from custom dialog box. Nested name property represents a name of the input it will be shown in a dialog box’s form and type represents type of the input, supported types:

  • text - a standard text input

  • number - a numerical input

  • int - an integer input

  • bool - a checkbox with two states true or false

  • select - a dropdown selection input

  • nested - a nested form

  • dynamic - a dynamic form

default properties in the template allows for setting an initial value in user data form.

The resulting specification gives us the dialog box that looks like that:

Example custom dialog box

In case of an error with the provided template, an error message will be sent through requestTerminalRead on dialogErrors terminal, it can be handy for debugging purposes.

Custom dialog input types description

  • text - Represents a standard input that accepts text data.

  • number - Represents a numerical input that supports float numbers and allows for settings maximum and minimum value through optional max and min parameters.

  • int - Represents a numerical input that supports integer based data and allows for settings maximum and minimum value through optional max and min parameters.

  • bool - Represents an input that accepts only two states true and false and is displayed as a checkbox in the dialog box.

  • select - Represents an input as a dropdown selection list with options defined in items option. Defined as a simple dictionary in which the key represents a name of the entry, visible by user, and item’s value is an internal value used by the application.

  • nested - Represents a nested form input, which allows defining form inside other form, using template property which accepts the same generic template format like normal custom dialog’s form. default parameter allows setting default values for each form in the nested form.

  • dynamic - Represents a dynamic form, which allows defining virtually infinite number of forms defined in template property, which accepts standard generic template format for custom dialog’s form. The number of forms is defined with additional integer input in the form. For dynamic form, default parameter have two functions:

    • when an integer value higher than 0 is set as default value, it is used to define initial amount of dynamic inputs.

    • when the default value is an array, it creates dynamic inputs based on values defined in the array. It allows for setting default value for each element in form.

Example usage of a default value in the dynamic input, based on a dialog box template presented below:

{
    "optimizationTask": {
        "title": "Power simulation",
        "confirmText": "OK",
        "template": {
            "parameters": {
                "name": "Parameters",
                "type": "dynamic",
                "default": [
                    {
                        "paramName": "Voltage",
                        "paramVal": "1800mV"
                    },
                    {
                        "paramName": "Current",
                        "paramVal": "500mA"
                    }
                ],
                "template": {
                        "paramName": {
                            "name": "Name",
                            "type": "text"
                        },
                        "paramVal": {
                            "name": "Value",
                            "type": "text"
                        }
                }
            }
        }
    }
}

This template will create the dialog box with two dynamic inputs with default values:

Example custom dialog box with default values

It is also possible to add, overwrite or remove the dialog box during application execution, using dialog_template_add requests. Example input data used with request:

{
    "name": "optimizationTask",
    "box": {
        "title": "Task form",
        "confirmText": "Send",
        "template": {
            "taskName": {
                "name": "task",
                "type": "text",
                "default": "Foo"
            }
        }
    }
}
  • name - a name of dialog box we wish to add or modify

  • box - a template used to define custom dialog box

In this case it will create a dialog box with a single text input. If optimizationTask is already registered, its template will be overridden with a new one. When optimizationTask is registered but the provided template or a box parameter is empty, optimizationTask will be removed. As a response dialog_template_add returns arrays with showing added, removed or overridden dialog boxes:

{
    "added": [ "optimizationTask" ],
    "removed": [],
    "overridden": []
}

Open custom dialog box

To open this dialog box, external application sends dialog_open request with a payload:

{
    "name": "optimizationTask"
}

In which name parameter is a name of the dialog box to open.

Read data from custom dialog box

When confirm button, OK button in this case, is pressed, Pipeline Manager sends dialog_on_submit request with data read from the dialog box in a form of simple json-like format:

{
    "taskName": "Foo"
}

In which taskName corresponds to input_name defined in template section of the dialog box.

Example usage of the custom dialog box is defined in a script tester_client.

You can also test the custom dialog box using Custom dialog box demo which uses Pipeline Manager embedded into HTML page.

Implementing a Python-based client for Pipeline Manager

The communication described above is necessary to integrate an application with Pipeline Manager. The client needs to be able to read requests coming from Pipeline Manager and send proper responses.

For applications written in Python, you can use the pipeline-manager-backend-communication library. It implements an easy-to-use interface that is able to communicate with Pipeline Manager along with helper structures and enumerations.

The main structures provided by the pipeline-manager-backend-communication library are:

  • CommunicationBackend - class that implements the functionality for receiving and sending messages.

  • MessageType - enum used to easily distinguish message types.

  • Status - enum that describes the current state of the client.

The following code is an example of how to receive requests and send responses to Pipeline Manager: As Pipeline Manager communication is based on JSON-RPC, application should implement method that can be requested. They are described in Backend API.

# Class containing all implemented methods
class RPCMethods:
    def specification_get(self) -> Dict:
        # ...
        return {'type': MessageType.OK.value, 'content': specification}

    # ...

Defined methods have to have appropriate (matching with specification) name, input and output.

    # Function name matches with the dataflow_import endpoint from External App API
    def dataflow_import(self, external_application_dataflow: str, mime: str, base64: bool) -> Dict:
        # Function will receive one parameter, it's name has to be the same
        # as the one from API specification `params`.
        # Optional, but you can convert the received file to string format
        # with `convert_message_to_string`
        # from pipeline_manager_backend_communication.utils import (
        #     convert_message_to_string
        # )
        data_as_string = convert_message_to_string(
            external_application_dataflow,
            base64,
            mime
        )
        # ...
        # pipeline_manager_dataflow here is the converted input file to the
        # Pipeline Manager's graph representation
        return {
            'type': MessageType.OK.value,
            'content': pipeline_manager_dataflow
        }

    def dataflow_validate(self, dataflow: Dict) -> Dict:
        # ...
        # Returned object has to match API specification `returns`
        return {'type': MessageType.OK.value}

    def dataflow_run(self, **kwargs: Dict) -> Dict:
        # All params can also be retrieved as one dictionary
        print(kwargs['dataflow'])
        # ...
        return {'type': MessageType.OK.value}

    # Custom procedure example
    def custom_build(self, dataflow: Dict) -> Dict:
        # ...
        return {'type': MessageType.OK.value}

Moreover, every uncaught exception will be classified as error.

    def dataflow_export(self, dataflow: Dict) -> Dict:
        # ...
        raise Exception('Something went very, very bad...')

RPC methods can also be asynchronous. It is automatically detected by server and awaited.

    async def dataflow_stop(self) -> Dict:
        # ...
        return {'type': MessageType.OK.value}

Therefore, the following JSON-RPC error message will be returned to frontend application.

{
    "id": 1,
    "jsonrpc": "2.0",
    "error": {
        "code": -3,
        "message": "Something went very, very bad...",
        "data": {}
    }
}

TCP client, that connects to Pipeline Manager using host and port parameters provided has to be created. It has to be initialized with object containing JSON-RPC methods.

host = '127.0.0.1'
port = 5000

# Creating a client instance with host and port specified
client = CommunicationBackend(host, port)
# Registering implemented methods and
# connecting to Pipeline Manager
await client.initialize_client(RPCMethods())

Once the connection is established, the application can start listening for the incoming requests.

await client.start_json_rpc_client()

These methods can be wrapped into the async function and run with asyncio.run function.

Sending JSON-RPC requests to Pipeline Manager

Sending requests is defined as coroutine which has to be awaited.

response = await client.request('graph_get')

This method sends graph-get request to frontend application and receive following response:

{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "dataflow": {
            // ...
        }
    }
}

Last update: 2026-12-02