fix: ruff formatting and allow-direct-references for handler-base dep
This commit is contained in:
@@ -8,6 +8,7 @@ Bridges NATS events to workflow engines using handler-base:
|
||||
3. Monitor execution and publish status updates
|
||||
4. Publish completion to "ai.pipeline.status.{request_id}"
|
||||
"""
|
||||
|
||||
import logging
|
||||
from typing import Any, Optional
|
||||
from datetime import datetime
|
||||
@@ -137,9 +138,7 @@ class PipelineBridge(Handler):
|
||||
|
||||
try:
|
||||
if engine == "argo":
|
||||
run_id = await self._submit_argo(
|
||||
pipeline["template"], parameters, request_id
|
||||
)
|
||||
run_id = await self._submit_argo(pipeline["template"], parameters, request_id)
|
||||
else:
|
||||
run_id = await self._submit_kubeflow(
|
||||
pipeline["pipeline_id"], parameters, request_id
|
||||
@@ -155,9 +154,7 @@ class PipelineBridge(Handler):
|
||||
}
|
||||
|
||||
# Publish status update
|
||||
await self.nats.publish(
|
||||
f"ai.pipeline.status.{request_id}", result
|
||||
)
|
||||
await self.nats.publish(f"ai.pipeline.status.{request_id}", result)
|
||||
|
||||
logger.info(f"Pipeline {pipeline_name} submitted: {run_id}")
|
||||
return result
|
||||
@@ -170,9 +167,7 @@ class PipelineBridge(Handler):
|
||||
"error": str(e),
|
||||
}
|
||||
|
||||
async def _submit_argo(
|
||||
self, template: str, parameters: dict, request_id: str
|
||||
) -> str:
|
||||
async def _submit_argo(self, template: str, parameters: dict, request_id: str) -> str:
|
||||
"""Submit workflow to Argo Workflows."""
|
||||
with create_span("pipeline.submit.argo") as span:
|
||||
if span:
|
||||
@@ -191,10 +186,7 @@ class PipelineBridge(Handler):
|
||||
"spec": {
|
||||
"workflowTemplateRef": {"name": template},
|
||||
"arguments": {
|
||||
"parameters": [
|
||||
{"name": k, "value": str(v)}
|
||||
for k, v in parameters.items()
|
||||
]
|
||||
"parameters": [{"name": k, "value": str(v)} for k, v in parameters.items()]
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -208,9 +200,7 @@ class PipelineBridge(Handler):
|
||||
result = response.json()
|
||||
return result["metadata"]["name"]
|
||||
|
||||
async def _submit_kubeflow(
|
||||
self, pipeline_id: str, parameters: dict, request_id: str
|
||||
) -> str:
|
||||
async def _submit_kubeflow(self, pipeline_id: str, parameters: dict, request_id: str) -> str:
|
||||
"""Submit run to Kubeflow Pipelines."""
|
||||
with create_span("pipeline.submit.kubeflow") as span:
|
||||
if span:
|
||||
@@ -220,10 +210,7 @@ class PipelineBridge(Handler):
|
||||
"name": f"{pipeline_id}-{request_id[:8]}",
|
||||
"pipeline_spec": {
|
||||
"pipeline_id": pipeline_id,
|
||||
"parameters": [
|
||||
{"name": k, "value": str(v)}
|
||||
for k, v in parameters.items()
|
||||
],
|
||||
"parameters": [{"name": k, "value": str(v)} for k, v in parameters.items()],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ dev = [
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.metadata]
|
||||
allow-direct-references = true
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["."]
|
||||
only-include = ["pipeline_bridge.py"]
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"""
|
||||
Pytest configuration and fixtures for pipeline-bridge tests.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
Unit tests for PipelineBridge handler.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
|
||||
Reference in New Issue
Block a user