diff --git a/src/tiledb/cloud/_common/testonly.py b/src/tiledb/cloud/_common/testonly.py index dff153389..8f31adcee 100644 --- a/src/tiledb/cloud/_common/testonly.py +++ b/src/tiledb/cloud/_common/testonly.py @@ -32,7 +32,7 @@ def register_udf(func: Callable, func_name: Optional[str] = None) -> Iterator[st try: yield f"{ns}/{func_name}" finally: - udf.delete(func_name, ns) + udf.delete(uri=f"tiledb://{ns}/{func_name}") def random_name(name: str) -> str: diff --git a/src/tiledb/cloud/udf.py b/src/tiledb/cloud/udf.py index e9d7f778c..f41ec5612 100644 --- a/src/tiledb/cloud/udf.py +++ b/src/tiledb/cloud/udf.py @@ -1,6 +1,7 @@ import base64 import uuid import warnings +from logging import warning from typing import Any, Callable, Iterable, Optional, Union import cloudpickle @@ -550,14 +551,32 @@ def unshare(name=None, namespace=None, async_req=False): """ -def delete(name, namespace, async_req=False): +def delete( + uri: str, namespace: Optional[str] = None, *, async_req: bool = False +) -> None: """ Deletes a registered udf - :param name: name of udf - :param namespace: namespace the udf belongs to - :param async_req: return future instead of results for async support + + :param uri: TileDB URI of the udf, defaults to None. + :param namespace: namespace the udf belongs to, defaults to None. + DEPRECATION WARNING: Will be deprecate from version 0.12.17 + :param async_req: Return future instead of results for async support :return: deleted udf details """ + try: + namespace, name = utils.split_uri(uri) + except Exception as exc: + if str(exc).startswith("Incorrect"): + warning( + DeprecationWarning( + "From version 0.12.17 the method will accept" + "only `tiledb:///` URIs" + ), + ) + name = uri + else: + raise exc + try: api_instance = client.build(rest_api.UdfApi) @@ -570,6 +589,20 @@ def delete(name, namespace, async_req=False): raise tiledb_cloud_error.check_exc(exc) from None +def deregister(uri: str, *, async_req: bool = False): + """ + De-registers a registered udf, by de-registering the array that it + is registered on. + This does not physically delete the array, it will remain in your bucket. + All access to the array and cloud metadata will be removed. + + :param uri: TileDB URI of the array. + :param async_req: Return future instead of results for async support + :return success or error + """ + return array.deregister_array(uri=uri, async_req=async_req) + + class _StoredParamJSONer(tiledb_json.Encoder): """Turns parameters passed to the existing UDF APIs into TileDB JSON.