Skip to content

Commit c3d3d31

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 468927f commit c3d3d31

2 files changed

Lines changed: 8 additions & 23 deletions

File tree

ui/api_client.py

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

432432

433433
def deploy_and_generate_yaml(recommendation: dict) -> dict | None:
434-
"""Deploy a recommendation and fetch generated YAML files.
434+
"""Deploy a recommendation and return generated YAML contents.
435435
436-
Returns dict with deployment_id, files, and success status, or None on error.
436+
Returns dict with deployment_id, files (YAML contents), and success status, or None on error.
437437
"""
438438
try:
439439
response = requests.post(
@@ -444,17 +444,10 @@ def deploy_and_generate_yaml(recommendation: dict) -> dict | None:
444444
response.raise_for_status()
445445
result = response.json()
446446
if result.get("success"):
447-
deployment_id = result.get("deployment_id")
448-
yaml_response = requests.get(
449-
f"{API_BASE_URL}/api/v1/deployments/{deployment_id}/yaml",
450-
timeout=DEFAULT_TIMEOUT,
451-
)
452-
yaml_response.raise_for_status()
453-
yaml_data = yaml_response.json()
454447
return {
455448
"success": True,
456-
"deployment_id": deployment_id,
457-
"files": yaml_data.get("files", {}),
449+
"deployment_id": result.get("deployment_id"),
450+
"files": result.get("files", {}),
458451
}
459452
else:
460453
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)