worker_node.worker_node_task_instance

The Task Instance Object once it has been submitted to run on a worker node.

Attributes

logger

Classes

WorkerNodeTaskInstance

The Task Instance object once it has been submitted to run on a worker node.

Module Contents

worker_node.worker_node_task_instance.logger
class worker_node.worker_node_task_instance.WorkerNodeTaskInstance(cluster_interface: jobmon.core.cluster_protocol.ClusterWorkerNode, task_instance_id: int, task_instance_heartbeat_interval: int | None = None, heartbeat_report_by_buffer: float | None = None, command_interrupt_timeout: int | None = None, requester: jobmon.core.requester.Requester | None = None)

The Task Instance object once it has been submitted to run on a worker node.

A mechanism whereby a running task_instance can communicate back to the JSM.

Logs its status, errors, usage details, etc.

Parameters:
  • cluster_interface – interface that gathers executor info in the execution_wrapper.

  • task_instance_id – the id of the TaskInstance that is reporting back.

  • task_instance_heartbeat_interval – how ofter to log a report by with the db

  • heartbeat_report_by_buffer – multiplier for report by date in case we miss a few.

  • command_interrupt_timeout – the amount of time to wait for the child process to terminate.

  • requester – communicate with the flask services.

requester = None
cluster_interface
property task_instance_id: int

Returns a task instance ID if it’s been bound.

property distributor_id: str | None

Executor id given from the executor it is being run on.

property nodename: str | None

Node it is being run on.

property process_group_id: int | None

Process group to track parent and child processes.

property status: str

Returns the last known status of the task instance.

property stdout: str
property stderr: str
property command: str

Returns the command this task instance will run.

property command_add_env: Dict[str, str]

Returns the command this task instance will run.

property command_returncode: int

Returns the exit code of the command that was run.

property command_stdout: str

Returns the last 10k characters of the commands stdout.

property command_stderr: str

Returns the last 10k characters of the commands stderr.

log_done() None

Tell the JobStateManager that this task_instance is done.

log_error(error_state: str, description: str) None

Tell the JobStateManager that this task_instance has errored.

log_running() None

Tell the JobStateManager that this task_instance is running.

Update the report_by_date to be further in the future in case it gets reconciled immediately.

async log_report_by(session: aiohttp.ClientSession) None

Log the heartbeat to show that the task instance is still alive.

Uses the async requester with an aiohttp ClientSession so heartbeats can run concurrently with other asyncio work (subprocess pipe drain, lazy log-directory creation in _communicate). Running on the event loop instead of the default thread-pool avoids the executor pressure that asyncio.to_thread would add when multiple slow I/O paths are in flight at the same time.

run() None

This script executes on the target node and wraps the target application.

Could be in any language, anything that can execute on linux. Similar to a stub or a container set ENV variables in case tasks need to access them.

set_command_output(returncode: int, stdout: str, stderr: str) None