Skip to content

Commit dd54a2e

Browse files
committed
Remove network calls and only export ACTIVITY_SPECS list for consumption
1 parent 67ba0b1 commit dd54a2e

File tree

4 files changed

+8
-91
lines changed

4 files changed

+8
-91
lines changed

application_sdk/application/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from application_sdk.clients.base import BaseClient
66
from application_sdk.clients.utils import get_workflow_client
77
from application_sdk.constants import ENABLE_MCP
8-
from application_sdk.decorators.automation_activity import flush_activity_registrations
98
from application_sdk.events.models import EventRegistration
109
from application_sdk.handlers.base import BaseHandler
1110
from application_sdk.observability.logger_adaptor import get_logger
@@ -153,9 +152,6 @@ async def setup_workflow(
153152
workflow_and_activities_classes=workflow_and_activities_classes
154153
)
155154

156-
# Register activities via HTTP API for automation engine
157-
flush_activity_registrations(app_name=self.application_name)
158-
159155
async def start_workflow(self, workflow_args, workflow_class) -> Any:
160156
"""
161157
Start a new workflow execution.

application_sdk/constants.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@
4949
SQL_SERVER_MIN_VERSION = os.getenv("ATLAN_SQL_SERVER_MIN_VERSION")
5050
#: Path to the SQL queries directory
5151
SQL_QUERIES_PATH = os.getenv("ATLAN_SQL_QUERIES_PATH", "app/sql")
52-
#: Host address for the automation engine API server
53-
AUTOMATION_ENGINE_API_HOST = os.getenv("AUTOMATION_ENGINE_API_HOST", "localhost")
54-
#: Port number for the automation engine API server
55-
AUTOMATION_ENGINE_API_PORT = os.getenv("AUTOMATION_ENGINE_API_PORT", "8080")
56-
#: Base URL for automation engine API server (constructed from host and port)
57-
AUTOMATION_ENGINE_API_URL = (
58-
f"http://{AUTOMATION_ENGINE_API_HOST}:{AUTOMATION_ENGINE_API_PORT}"
59-
)
6052

6153
# Output Path Constants
6254
#: Output path format for workflows.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""Decorators module for application SDK."""
2+
3+
from application_sdk.decorators.automation_activity import ACTIVITY_SPECS
4+
5+
__all__: list[str] = ["ACTIVITY_SPECS"]
6+

application_sdk/decorators/automation_activity.py

Lines changed: 2 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@
77
from typing import Any, Callable, Dict, List, Union, get_args, get_origin
88

99
from pydantic import BaseModel
10-
import requests
1110

12-
from application_sdk.constants import AUTOMATION_ENGINE_API_URL
1311
from application_sdk.observability.logger_adaptor import get_logger
1412

1513
logger = get_logger(__name__)
1614

1715

1816
# Global registry to collect decorated activities
19-
ACTIVITY_REGISTRY: List[dict[str, Any]] = []
17+
ACTIVITY_SPECS: List[dict[str, Any]] = []
2018

2119

2220
def _type_to_json_schema(annotation: Any) -> Dict[str, Any]:
@@ -117,7 +115,7 @@ def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
117115
output_schema: dict[str, Any] = _generate_output_schema(func)
118116

119117
logger.info(f"Collected automation activity: {name}")
120-
ACTIVITY_REGISTRY.append(
118+
ACTIVITY_SPECS.append(
121119
{
122120
"name": name,
123121
"description": description,
@@ -129,78 +127,3 @@ def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
129127
return func
130128

131129
return decorator
132-
133-
134-
def flush_activity_registrations(
135-
app_name: str,
136-
) -> None:
137-
"""Flush all collected registrations by calling the activities create API via HTTP."""
138-
if not ACTIVITY_REGISTRY:
139-
logger.info("No activities to register")
140-
return
141-
142-
if not AUTOMATION_ENGINE_API_URL:
143-
logger.warning(
144-
"Automation engine API URL not configured. Skipping activity registration."
145-
)
146-
return
147-
148-
# Perform health check first
149-
try:
150-
health_check_url: str = f"{AUTOMATION_ENGINE_API_URL}/api/health"
151-
health_response: requests.Response = requests.get(health_check_url, timeout=5.0)
152-
health_response.raise_for_status()
153-
logger.info("Automation engine health check passed")
154-
except Exception as e:
155-
logger.warning(
156-
f"Automation engine health check failed: {e}. "
157-
"Skipping activity registration. "
158-
"Check if the automation engine is deployed and accessible."
159-
)
160-
return
161-
162-
logger.info(
163-
f"Registering {len(ACTIVITY_REGISTRY)} activities with automation engine"
164-
)
165-
166-
# Generate app qualified name
167-
app_qualified_name: str = f"default/apps/{app_name}"
168-
169-
# Build tools payload without function objects (not JSON serializable)
170-
tools = [
171-
{
172-
"name": item["name"],
173-
"description": item["description"],
174-
"input_schema": item["input_schema"],
175-
"output_schema": item["output_schema"],
176-
}
177-
for item in ACTIVITY_REGISTRY
178-
]
179-
180-
payload = {
181-
"app_qualified_name": app_qualified_name,
182-
"app_name": app_name,
183-
"tools": tools,
184-
}
185-
186-
try:
187-
response: requests.Response = requests.post(
188-
f"{AUTOMATION_ENGINE_API_URL}/api/tools",
189-
json=payload,
190-
timeout=30.0,
191-
)
192-
response.raise_for_status()
193-
result = response.json()
194-
195-
if result.get("status") == "success":
196-
logger.info(
197-
f"Successfully registered {len(tools)} activities with automation engine"
198-
)
199-
else:
200-
logger.warning(
201-
f"Failed to register activities with automation engine: {result.get('message')}"
202-
)
203-
except Exception as e:
204-
raise Exception(
205-
f"Failed to register activities with automation engine: {e}"
206-
) from e

0 commit comments

Comments
 (0)