Spaces:
Running
Running
Remove old pre-crdt workspace endpoints.
Browse files
lynxkite-app/src/lynxkite_app/main.py
CHANGED
@@ -46,29 +46,9 @@ def get_catalog(workspace: str):
|
|
46 |
return {env: _get_ops(env) for env in ops.CATALOGS}
|
47 |
|
48 |
|
49 |
-
class SaveRequest(workspace.BaseConfig):
|
50 |
-
path: str
|
51 |
-
ws: workspace.Workspace
|
52 |
-
|
53 |
-
|
54 |
data_path = pathlib.Path()
|
55 |
|
56 |
|
57 |
-
def save(req: SaveRequest):
|
58 |
-
path = data_path / req.path
|
59 |
-
assert path.is_relative_to(data_path), f"Path '{path}' is invalid"
|
60 |
-
req.ws.save(path)
|
61 |
-
|
62 |
-
|
63 |
-
@app.post("/api/save")
|
64 |
-
async def save_and_execute(req: SaveRequest):
|
65 |
-
save(req)
|
66 |
-
if req.ws.has_executor():
|
67 |
-
await req.ws.execute()
|
68 |
-
save(req)
|
69 |
-
return req.ws
|
70 |
-
|
71 |
-
|
72 |
@app.post("/api/delete")
|
73 |
async def delete_workspace(req: dict):
|
74 |
json_path: pathlib.Path = data_path / req["path"]
|
@@ -79,15 +59,6 @@ async def delete_workspace(req: dict):
|
|
79 |
crdt.delete_room(req["path"])
|
80 |
|
81 |
|
82 |
-
@app.get("/api/load")
|
83 |
-
def load(path: str):
|
84 |
-
path = data_path / path
|
85 |
-
assert path.is_relative_to(data_path), f"Path '{path}' is invalid"
|
86 |
-
if not path.exists():
|
87 |
-
return workspace.Workspace()
|
88 |
-
return workspace.Workspace.load(path)
|
89 |
-
|
90 |
-
|
91 |
class DirectoryEntry(pydantic.BaseModel):
|
92 |
name: str
|
93 |
type: str
|
|
|
46 |
return {env: _get_ops(env) for env in ops.CATALOGS}
|
47 |
|
48 |
|
|
|
|
|
|
|
|
|
|
|
49 |
data_path = pathlib.Path()
|
50 |
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
@app.post("/api/delete")
|
53 |
async def delete_workspace(req: dict):
|
54 |
json_path: pathlib.Path = data_path / req["path"]
|
|
|
59 |
crdt.delete_room(req["path"])
|
60 |
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
class DirectoryEntry(pydantic.BaseModel):
|
63 |
name: str
|
64 |
type: str
|