Overview
At a high level:- The child process server (
optexity/inference/child_process.py) exposes a small HTTP API. - It accepts an
InferenceRequest, asks the Optexity control plane for aTask, and then executes that task via browser automation. - Configuration is provided through environment variables loaded from a file referenced by
ENV_PATH.
Configuration
Configuration is defined inoptexity/utils/settings.py via a Settings model:
HEALTH_ENDPOINT(default:api/v1/health)INFERENCE_ENDPOINT(default:api/v1/inference)START_TASK_ENDPOINT(default:api/v1/start_task)COMPLETE_TASK_ENDPOINT(default:api/v1/complete_task)SAVE_OUTPUT_DATA_ENDPOINT(default:api/v1/save_output_data)SAVE_DOWNLOADS_ENDPOINT(default:api/v1/save_downloads)SAVE_TRAJECTORY_ENDPOINT(default:api/v1/save_trajectory)API_KEY: API key for authenticated server-to-server calls (required).CHILD_PORT_OFFSET(default:9000): Port offset used when discovering child processes in AWS/ECS environments.DEPLOYMENT:"dev"or"prod".
ENV_PATH:
Models
InferenceRequest
Defined in optexity/schema/inference.py:
-
endpoint_name: str- Name of the target automation endpoint.
- Must match a recording/automation configured in the control plane.
-
input_parameters: dict[str, list[str]]- All input parameters for the automation, modeled as lists of strings.
- Example:
{ "email": ["alice@example.com"], "full_name": ["Alice Doe"] }.
-
unique_parameter_names: list[str]- Subset of keys from
input_parametersused to identify a unique task. - Validation ensures every name in
unique_parameter_namesexists as a key ininput_parameters. - If no
unique_parameter_namesare provided, the task will be allocated immediately.
- Subset of keys from
Task
Defined in optexity/schema/task.py:
-
Identity & routing
task_id: struser_id: strrecording_id: strautomation: Automation
-
Inputs & deduplication
input_parameters: dict[str, list[str]]unique_parameter_names: list[str]unique_parameters: dict[str, list[str]] | Nonededup_key: str– stable JSON-encoded key derived fromunique_parameters(when provided).
-
Lifecycle & status
created_at,allocated_at,started_at,completed_at: datetime | Nonestatus: "queued" | "allocated" | "running" | "success" | "failed" | "cancelled"error: str | Noneretry_count: int(default0)max_retries: int(default1)
-
Storage paths
save_directory: Path(default/tmp/optexity)task_directory,logs_directory,downloads_directory,log_file_path: Path | None- Directories are created on validation.
-
Accounting
api_key: str
TaskCreateRequestTaskStartedRequestTaskCompleteRequestTaskOutputDataRequest
HTTP endpoints (child process server)
The child process server is created inget_app_with_endpoints (optexity/inference/child_process.py).
When is_aws=False (local mode, recommended for development):
-
POST /inference- Body:
InferenceRequestJSON. - Behavior:
- Sends the request to
api.optexity.com+INFERENCE_ENDPOINTwith headerx-api-key: API_KEY. - Expects a response containing a serialized
Task. - Enqueues that
Taskonto a localasyncio.Queue. - Returns
202 Acceptedwith:{"success": true, "message": "Task has been allocated"}on success.
- Sends the request to
- Body:
-
GET /health- Returns HTTP 200 with:
status: "healthy"task_running: boolqueued_tasks: int
- If a task has been running more than 15 minutes, returns HTTP 503 with:
status: "unhealthy"- A descriptive
message.
- Returns HTTP 200 with:
-
GET /is_task_running- Returns a boolean indicating whether a task is currently executing.
is_aws=True (managed/remote worker mode):
-
POST /allocate_task- Accepts a serialized
Taskdirectly in the request body and enqueues it for execution.
- Accepts a serialized
-
POST /set_child_process_id- Sets the
child_process_idfor this worker.
- Sets the
-
On startup, the process:
- Introspects ECS metadata from
http://169.254.170.2/v3/task. - Registers itself with the master at
SERVER_URLvia aregister_childendpoint.
- Introspects ECS metadata from