Update API configuration in values.yaml and connectors_config.py; integrate PIWebAPIScouter into worker setup
139 lines
4.0 KiB
Plaintext
139 lines
4.0 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9d16b24a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from datetime import timedelta\n",
|
|
"from typing import Any\n",
|
|
"from temporalio import client\n",
|
|
"from temporalio.client import WorkflowHandle\n",
|
|
"\n",
|
|
"\n",
|
|
"async def start_workflow_advanced(\n",
|
|
" temporal_client: client.Client,\n",
|
|
" workflow_name: str,\n",
|
|
" workflow_input: dict[str, Any],\n",
|
|
" workflow_id: str | None = None,\n",
|
|
" task_queue: str = \"scouter-queue\",\n",
|
|
" execution_timeout: timedelta | None = None,\n",
|
|
" run_timeout: timedelta | None = None,\n",
|
|
" task_timeout: timedelta | None = None,\n",
|
|
") -> WorkflowHandle:\n",
|
|
" handle = await temporal_client.start_workflow(\n",
|
|
" workflow=workflow_name,\n",
|
|
" arg=workflow_input,\n",
|
|
" id=workflow_id or f\"{workflow_name}-{id(workflow_input)}\",\n",
|
|
" task_queue=task_queue,\n",
|
|
" execution_timeout=execution_timeout,\n",
|
|
" run_timeout=run_timeout,\n",
|
|
" task_timeout=task_timeout,\n",
|
|
" )\n",
|
|
" \n",
|
|
" return handle"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "5e344fb0",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"input_data = {\n",
|
|
" \"debug_data_package\": False,\n",
|
|
" \"execution_timeout_seconds\": 300,\n",
|
|
" \"fill_missing_tags\": False,\n",
|
|
" \"filters\": {\n",
|
|
" \"NULL_VALUES_FILTER\": {\n",
|
|
" \"policy\": \"DISCARD\"\n",
|
|
" },\n",
|
|
" \"OUT_OF_BOUNDS_FILTER\": {\n",
|
|
" \"policy\": \"DISCARD\"\n",
|
|
" }\n",
|
|
" },\n",
|
|
" \"frequency\": \"30s\",\n",
|
|
" \"max_retry_policy\": 1,\n",
|
|
" \"model_config\": {\n",
|
|
" \"predict_flavor\": \"sklearn\",\n",
|
|
" \"retention_minutes\": 0,\n",
|
|
" \"target\": \"CI-W3A05F1\",\n",
|
|
" \"transform_flavor\": \"sklearn\"\n",
|
|
" },\n",
|
|
" \"model_id\": \"10\",\n",
|
|
" \"model_name\": \"Pi Web API Test Model\",\n",
|
|
" \"model_tags\": {\n",
|
|
" \"CI-W3W03S1\": {\n",
|
|
" \"aggr_func\": \"avg\",\n",
|
|
" \"data_range\": [\n",
|
|
" -100,\n",
|
|
" 100\n",
|
|
" ],\n",
|
|
" \"webid\": \"F1DP-7fYgsRTtUOa7V9NIwSujATFUAAAUElIQVZDXENJLVczVzAzUzE\"\n",
|
|
" },\n",
|
|
" \"CI-W3A05F1\": {\n",
|
|
" \"aggr_func\": \"lts\",\n",
|
|
" \"data_range\": [\n",
|
|
" -100,\n",
|
|
" 100\n",
|
|
" ],\n",
|
|
" \"webid\": \"F1DP-7fYgsRTtUOa7V9NIwSujAkVMAAAUElIQVZDXENJLVczQTA1RjE\"\n",
|
|
" }\n",
|
|
" },\n",
|
|
" \"offset\": \"0m\",\n",
|
|
" \"retention_time\": 3600,\n",
|
|
" \"schedule_name\": \"pi-web-api-scouter-test\",\n",
|
|
" \"schema\": \"sientia_data\",\n",
|
|
" \"table_name\": \"laborious_data\",\n",
|
|
" \"task_timeout_seconds\": 300,\n",
|
|
" \"trigger_laborious\": False,\n",
|
|
" \"updated_at\": \"2025-08-13 18:35:01.600000+0000\",\n",
|
|
" \"workflow_type\": \"pi_web_api_scouter\"\n",
|
|
"}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9350bff3",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from temporalio import client\n",
|
|
"import datetime\n",
|
|
"\n",
|
|
"temporal_client = await client.Client.connect(\n",
|
|
" target_host=\"localhost:7233\",\n",
|
|
" namespace=\"scouter\"\n",
|
|
")\n",
|
|
"\n",
|
|
"now = datetime.datetime.now()\n",
|
|
"\n",
|
|
"handle = await start_workflow_advanced(\n",
|
|
" temporal_client=temporal_client,\n",
|
|
" workflow_name='pi_web_api_scouter',\n",
|
|
" workflow_input=input_data,\n",
|
|
" workflow_id='test_workflow_id_' + now.strftime('%Y%m%d%H%M%S')\n",
|
|
")\n",
|
|
"\n"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "venv",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"name": "python",
|
|
"version": "3.11.14"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|