"...composable_kernel_rocm.git" did not exist on "f6edda6119ebbb237dfa6270797b34f960d7b190"
Unverified Commit 7b6f7fd1 authored by Jakob Görgen's avatar Jakob Görgen
Browse files

client + cli : added functions to delete namespaces

parent f8c67ccc
...@@ -89,3 +89,13 @@ async def create(name: str): ...@@ -89,3 +89,13 @@ async def create(name: str):
ns_id = namespace["id"] ns_id = namespace["id"]
print(f"Creating namespace {name} in {state.namespace}. New namespace: {ns_id}") print(f"Creating namespace {name} in {state.namespace}. New namespace: {ns_id}")
@app.command()
@async_cli()
async def delete(ident: int):
"""Delete a namespace."""
client = state.ns_client()
await client.delete(ident)
print(f"Deleted namespace with id {ident}.")
...@@ -91,6 +91,17 @@ class BaseClient: ...@@ -91,6 +91,17 @@ class BaseClient:
resp.raise_for_status() # TODO: handel gracefully resp.raise_for_status() # TODO: handel gracefully
yield resp yield resp
@contextlib.asynccontextmanager
async def delete(self, url: str, **kwargs: typing.Any) -> typing.AsyncIterator[aiohttp.ClientResponse]:
url = f"{self._base_url}{url}"
async with self.session() as session:
async with session.delete(url=url, **kwargs) as resp: # TODO: handel connection error
print(await resp.text())
resp.raise_for_status() # TODO: handel gracefully
yield resp
async def info(self): async def info(self):
async with self.get(url="/info") as resp: async with self.get(url="/info") as resp:
return await resp.json() return await resp.json()
...@@ -136,6 +147,10 @@ class NSClient: ...@@ -136,6 +147,10 @@ class NSClient:
async with self.post(url="/", json=namespace_json) as resp: async with self.post(url="/", json=namespace_json) as resp:
return await resp.json() return await resp.json()
async def delete(self, ns_id: int):
async with self._base_client.delete(url=self._build_ns_prefix(f"/{ns_id}")) as _:
return
# retrieve namespace ns_id, useful for retrieving a child the current namespace # retrieve namespace ns_id, useful for retrieving a child the current namespace
async def get_ns(self, ns_id: int): async def get_ns(self, ns_id: int):
async with self.get(url=f"/one/{ns_id}") as resp: async with self.get(url=f"/one/{ns_id}") as resp:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment