Spaces:
Building
Building
Update spark_controller.py
Browse files- spark_controller.py +13 -0
spark_controller.py
CHANGED
@@ -76,3 +76,16 @@ async def delete_project(request: Request, config: ServiceConfig = Depends(get_c
|
|
76 |
json.dump(config, f, indent=2)
|
77 |
|
78 |
return {"message": f"Project {project_name} deleted"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
json.dump(config, f, indent=2)
|
77 |
|
78 |
return {"message": f"Project {project_name} deleted"}
|
79 |
+
|
80 |
+
@router.get("/spark/projects")
|
81 |
+
def get_spark_projects(config: ServiceConfig = Depends(get_config)):
|
82 |
+
try:
|
83 |
+
spark_url = config.spark_endpoint + "/projects"
|
84 |
+
response = requests.get(spark_url, timeout=5)
|
85 |
+
response.raise_for_status()
|
86 |
+
projects = response.json()
|
87 |
+
return { "projects": projects }
|
88 |
+
|
89 |
+
except Exception as e:
|
90 |
+
log(f"⚠️ Spark service unreachable: {str(e)}")
|
91 |
+
return { "error": True }
|