Skip to content

Commit cc570eb

Browse files
committed
refactor: use inline YAML from deploy response in UI
Remove second GET /deployments/{id}/yaml round-trip from both api_client.deploy_and_generate_yaml() and the deployment component. YAML contents are now read directly from the deploy response. Zip download entries use proper filenames ({deployment_id}-{type}.yaml). Assisted-by: Claude <noreply@anthropic.com> Signed-off-by: Amit Oren <amoren@redhat.com>
1 parent 78983cf commit cc570eb

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

ui/api_client.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ def extract_business_context(user_input: str) -> dict | None:
247247

248248

249249
def deploy_and_generate_yaml(recommendation: dict) -> dict | None:
250-
"""Deploy a recommendation and fetch generated YAML files.
250+
"""Deploy a recommendation and return generated YAML contents.
251251
252-
Returns dict with deployment_id, files, and success status, or None on error.
252+
Returns dict with deployment_id, files (YAML contents), and success status, or None on error.
253253
"""
254254
try:
255255
response = requests.post(
@@ -260,17 +260,10 @@ def deploy_and_generate_yaml(recommendation: dict) -> dict | None:
260260
response.raise_for_status()
261261
result = response.json()
262262
if result.get("success"):
263-
deployment_id = result.get("deployment_id")
264-
yaml_response = requests.get(
265-
f"{API_BASE_URL}/api/v1/deployments/{deployment_id}/yaml",
266-
timeout=DEFAULT_TIMEOUT,
267-
)
268-
yaml_response.raise_for_status()
269-
yaml_data = yaml_response.json()
270263
return {
271264
"success": True,
272-
"deployment_id": deployment_id,
273-
"files": yaml_data.get("files", {}),
265+
"deployment_id": result.get("deployment_id"),
266+
"files": result.get("files", {}),
274267
}
275268
else:
276269
return {"success": False, "message": result.get("message", "Unknown error")}

ui/components/deployment.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,8 @@ def render_deployment_tab():
8383
result = response.json()
8484

8585
if result.get("success"):
86-
deployment_id = result.get("deployment_id")
87-
st.session_state.deployment_id = deployment_id
88-
89-
yaml_response = requests.get(
90-
f"{API_BASE_URL}/api/v1/deployments/{deployment_id}/yaml",
91-
timeout=10,
92-
)
93-
yaml_response.raise_for_status()
94-
yaml_data = yaml_response.json()
95-
96-
st.session_state.deployment_yaml_files = yaml_data.get("files", {})
86+
st.session_state.deployment_id = result.get("deployment_id")
87+
st.session_state.deployment_yaml_files = result.get("files", {})
9788
st.session_state.deployment_yaml_generated = True
9889
st.rerun()
9990
else:
@@ -117,7 +108,8 @@ def render_deployment_tab():
117108
if yaml_files:
118109
zip_buffer = io.BytesIO()
119110
with zipfile.ZipFile(zip_buffer, "w", zipfile.ZIP_DEFLATED) as zf:
120-
for filename, content in yaml_files.items():
111+
for config_type, content in yaml_files.items():
112+
filename = f"{deployment_id}-{config_type}.yaml"
121113
zf.writestr(filename, content)
122114
zip_buffer.seek(0)
123115

0 commit comments

Comments
 (0)