Uplink Module¶
This module contains functionality for linking with external systems and services.
uplink
¶
Module for communicating with the Nextmv platform.
This module provides functionality to communicate pipeline execution status with the Nextmv platform. It includes data classes for modeling the pipeline graph state and a client for updating this state in the platform.
CLASS | DESCRIPTION |
---|---|
UplinkConfig |
Configuration for the uplink client. |
StepDTO |
Data Transfer Object representing a pipeline step. |
NodeDTO |
Data Transfer Object representing a node in the pipeline graph. |
FlowDTO |
Data Transfer Object representing a flow graph. |
FlowUpdateDTO |
Data Transfer Object for updating a flow in the platform. |
UplinkClient |
Client for posting graph and node updates to the platform. |
FUNCTION | DESCRIPTION |
---|---|
ExcludeIfNone |
Helper function for dataclasses_json to exclude None fields. |
ENV_APP_ID
module-attribute
¶
Environment variable name for the application ID.
ENV_RUN_ID
module-attribute
¶
Environment variable name for the run ID.
ExcludeIfNone
¶
ExcludeIfNone(value)
Determine if a value should be excluded from serialization.
This function is used as a helper for dataclasses_json to exclude None values during serialization.
PARAMETER | DESCRIPTION |
---|---|
|
The value to check.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the value is None and should be excluded, False otherwise. |
Examples:
Source code in nextpipe/uplink.py
FAILED_UPDATES_THRESHOLD
module-attribute
¶
Maximum number of consecutive failed updates before termination.
FlowDTO
dataclass
¶
FlowUpdateDTO
dataclass
¶
FlowUpdateDTO(
pipeline_graph: FlowDTO, updated_at: str = None
)
Data Transfer Object for updating a flow in the platform.
A FlowUpdateDTO represents a flow in the platform, containing the pipeline graph and the timestamp of the update.
PARAMETER | DESCRIPTION |
---|---|
|
The graph of the pipeline.
TYPE:
|
|
Time of the update as an RFC3339 string. Will be set automatically.
TYPE:
|
MAX_DOCS_LENGTH
module-attribute
¶
Maximum length for documentation strings sent to the platform.
NodeDTO
dataclass
¶
NodeDTO(
id: str,
parent_id: str,
predecessor_ids: list[str],
status: str,
run_id: str = None,
)
Data Transfer Object representing a node in the pipeline graph.
A NodeDTO represents a node in the pipeline execution graph, tracking its status, dependencies, and relationships.
PARAMETER | DESCRIPTION |
---|---|
|
The ID of the node.
TYPE:
|
|
Parent step ID.
TYPE:
|
|
Predecessor nodes via their IDs.
TYPE:
|
|
Status of the node.
TYPE:
|
|
ID of the associated run, if any.
TYPE:
|
run_id
class-attribute
instance-attribute
¶
run_id: str = field(
default=None, metadata=config(exclude=ExcludeIfNone)
)
ID of the associated run, if any.
StepDTO
dataclass
¶
StepDTO(
id: str,
predecessors: list[str],
docs: str = None,
app_id: str = None,
)
Data Transfer Object representing a pipeline step.
A StepDTO represents a step in a pipeline, with its unique identifier, dependencies, documentation, and optional associated application.
PARAMETER | DESCRIPTION |
---|---|
|
The ID of the step.
TYPE:
|
|
The IDs of the nodes that depend on this node.
TYPE:
|
|
The documentation string of the step.
TYPE:
|
|
The ID of the app this step represents (if any).
TYPE:
|
app_id
class-attribute
instance-attribute
¶
app_id: str = field(
default=None, metadata=config(exclude=ExcludeIfNone)
)
The ID of the app this step represents (if any).
docs
class-attribute
instance-attribute
¶
docs: str = field(
default=None, metadata=config(exclude=ExcludeIfNone)
)
The doc string of the step.
predecessors
instance-attribute
¶
The IDs of the nodes that depend on this node.
UplinkClient
¶
UplinkClient(client: Client, config: UplinkConfig)
Client for posting graph and node updates to the platform.
This class provides an interface to communicate with the Nextmv platform, posting updates about the pipeline execution status and graph structure.
PARAMETER | DESCRIPTION |
---|---|
|
The Nextmv Cloud client.
TYPE:
|
|
The configuration for the uplink client.
TYPE:
|
ATTRIBUTE | DESCRIPTION |
---|---|
config |
The configuration for the uplink client.
TYPE:
|
inactive |
Whether the client is inactive.
TYPE:
|
client |
The Nextmv Cloud client.
TYPE:
|
flow |
The current flow.
TYPE:
|
changed |
Whether the flow has changed and needs to be updated.
TYPE:
|
Initialize the UplinkClient.
PARAMETER | DESCRIPTION |
---|---|
|
The Nextmv Cloud client.
TYPE:
|
|
The configuration for the uplink client. If None, configuration is loaded from environment variables.
TYPE:
|
Notes
If no application ID or run ID is provided, the client will be marked as inactive and will not send any updates to the platform.
Source code in nextpipe/uplink.py
run_async
¶
Start the uplink client in a separate thread.
This method starts the uplink client in a separate thread, which will post node updates to the platform until terminated. Updates are sent at regular intervals defined by UPDATE_INTERVAL.
If the client is inactive or already terminated, this method returns without starting a new thread.
Source code in nextpipe/uplink.py
submit_update
¶
submit_update(flow: FlowUpdateDTO)
Post the full flow and its state to the platform.
This method submits the flow state to be updated in the Nextmv platform. It truncates documentation strings if they exceed the maximum length.
PARAMETER | DESCRIPTION |
---|---|
|
The flow to update.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the flow is not a FlowUpdateDTO instance. |
Source code in nextpipe/uplink.py
terminate
¶
Terminate the uplink client gracefully.
This method stops the uplink client's update thread and sends a final update to the platform if there are pending changes. It waits for the thread to terminate before returning.
If the client is inactive, this method returns without taking any action.
Source code in nextpipe/uplink.py
UplinkConfig
dataclass
¶
UplinkConfig(application_id: str, run_id: str)