Skip to content

Commit 8787fc7

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 b2a22a9 commit 8787fc7

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
@@ -246,9 +246,9 @@ def extract_business_context(user_input: str) -> dict | None:
246246

247247

248248
def deploy_and_generate_yaml(recommendation: dict) -> dict | None:
249-
"""Deploy a recommendation and fetch generated YAML files.
249+
"""Deploy a recommendation and return generated YAML contents.
250250
251-
Returns dict with deployment_id, files, and success status, or None on error.
251+
Returns dict with deployment_id, files (YAML contents), and success status, or None on error.
252252
"""
253253
try:
254254
response = requests.post(
@@ -259,17 +259,10 @@ def deploy_and_generate_yaml(recommendation: dict) -> dict | None:
259259
response.raise_for_status()
260260
result = response.json()
261261
if result.get("success"):
262-
deployment_id = result.get("deployment_id")
263-
yaml_response = requests.get(
264-
f"{API_BASE_URL}/api/v1/deployments/{deployment_id}/yaml",
265-
timeout=DEFAULT_TIMEOUT,
266-
)
267-
yaml_response.raise_for_status()
268-
yaml_data = yaml_response.json()
269262
return {
270263
"success": True,
271-
"deployment_id": deployment_id,
272-
"files": yaml_data.get("files", {}),
264+
"deployment_id": result.get("deployment_id"),
265+
"files": result.get("files", {}),
273266
}
274267
else:
275268
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)