diff --git a/src/blosc2/c2array.py b/src/blosc2/c2array.py index f6cde039..e87e31b0 100644 --- a/src/blosc2/c2array.py +++ b/src/blosc2/c2array.py @@ -144,11 +144,6 @@ def info(path, urlbase, params=None, headers=None, model=None, auth_token=None): return json if model is None else model(**json) -def subscribe(root, urlbase, auth_token): - url = _sub_url(urlbase, f"api/subscribe/{root}") - return _xpost(url, auth_token=auth_token) - - def fetch_data(path, urlbase, params, auth_token=None, as_blosc2=False): url = _sub_url(urlbase, f"api/fetch/{path}") response = _xget(url, params=params, auth_token=auth_token) @@ -237,15 +232,8 @@ def __init__(self, path: str, /, urlbase: str | None = None, auth_token: str | N # Try to 'open' the remote path try: self.meta = info(self.path, self.urlbase, auth_token=self.auth_token) - except requests.HTTPError: - # Subscribe to root and try again. It is less latency to subscribe directly - # than to check for the subscription. - root, _ = self.path.split("/", 1) - subscribe(root, self.urlbase, self.auth_token) - try: - self.meta = info(self.path, self.urlbase, auth_token=self.auth_token) - except requests.HTTPError as err: - raise FileNotFoundError(f"Remote path not found: {path}.\nError was: {err}") from err + except requests.HTTPError as err: + raise FileNotFoundError(f"Remote path not found: {path}.\nError was: {err}") from err cparams = self.meta["schunk"]["cparams"] # Remove "filters, meta" from cparams; this is an artifact from the server cparams.pop("filters, meta", None) diff --git a/tests/conftest.py b/tests/conftest.py index 7b2a6a03..8389f8c8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,10 +17,10 @@ def pytest_configure(config): @pytest.fixture(scope="session") -def c2sub_context(): +def cat2_context(): # You may use the URL and credentials for an already existing user # in a different Caterva2 subscriber. - urlbase = os.environ.get("BLOSC_C2URLBASE", "https://demo.caterva2.net/") + urlbase = os.environ.get("BLOSC_C2URLBASE", "https://cat2.cloud/testing/") c2params = {"urlbase": urlbase, "username": None, "password": None} with blosc2.c2context(**c2params): yield c2params diff --git a/tests/ndarray/test_c2array_expr.py b/tests/ndarray/test_c2array_expr.py index d5c89fc5..c613f1e1 100644 --- a/tests/ndarray/test_c2array_expr.py +++ b/tests/ndarray/test_c2array_expr.py @@ -16,7 +16,7 @@ pytestmark = pytest.mark.network NITEMS_SMALL = 1_000 -ROOT = "b2tests" +ROOT = "@public" DIR = "expr/" @@ -51,7 +51,7 @@ def get_arrays(shape, chunks_blocks): (False, False), ], ) -def test_simple(chunks_blocks, c2sub_context): +def test_simple(chunks_blocks, cat2_context): shape = (60, 60) a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks) @@ -67,7 +67,7 @@ def test_simple(chunks_blocks, c2sub_context): np.testing.assert_allclose(res[:], nres) -def test_simple_getitem(c2sub_context): +def test_simple_getitem(cat2_context): shape = (NITEMS_SMALL,) chunks_blocks = "default" a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks) @@ -91,7 +91,7 @@ def test_simple_getitem(c2sub_context): (False, False), ], ) -def test_ixxx(chunks_blocks, c2sub_context): +def test_ixxx(chunks_blocks, cat2_context): shape = (60, 60) a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks) expr = a1**3 + a2**2 + a3**3 - a4 + 3 @@ -103,7 +103,7 @@ def test_ixxx(chunks_blocks, c2sub_context): np.testing.assert_allclose(res[:], nres) -def test_complex(c2sub_context): +def test_complex(cat2_context): shape = (NITEMS_SMALL,) chunks_blocks = "default" a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks) @@ -132,7 +132,7 @@ def test_complex(c2sub_context): (False, False), ], ) -def test_mix_operands(chunks_blocks, c2sub_context): +def test_mix_operands(chunks_blocks, cat2_context): shape = (60, 60) a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks) b1 = blosc2.asarray(na1, chunks=a1.chunks, blocks=a1.blocks) @@ -168,7 +168,7 @@ def test_mix_operands(chunks_blocks, c2sub_context): # Tests related with save method -def test_save(c2sub_context): +def test_save(cat2_context): shape = (60, 60) tol = 1e-17 a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, (False, True)) @@ -212,7 +212,7 @@ def broadcast_shape(request): @pytest.fixture -def broadcast_fixture(broadcast_shape, c2sub_context): +def broadcast_fixture(broadcast_shape, cat2_context): shape1, shape2 = broadcast_shape dtype = np.float64 na1 = np.linspace(0, 1, np.prod(shape1), dtype=dtype).reshape(shape1) diff --git a/tests/ndarray/test_c2array_reductions.py b/tests/ndarray/test_c2array_reductions.py index ebfc104e..ec1826e0 100644 --- a/tests/ndarray/test_c2array_reductions.py +++ b/tests/ndarray/test_c2array_reductions.py @@ -16,7 +16,7 @@ pytestmark = pytest.mark.network NITEMS_SMALL = 1_000 -ROOT = "b2tests" +ROOT = "@public" DIR = "expr/" @@ -45,7 +45,7 @@ def get_arrays(shape, chunks_blocks): @pytest.mark.parametrize("reduce_op", ["sum", pytest.param("all", marks=pytest.mark.heavy)]) -def test_reduce_bool(reduce_op, c2sub_context): +def test_reduce_bool(reduce_op, cat2_context): shape = (NITEMS_SMALL,) chunks_blocks = "default" a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks) @@ -73,7 +73,7 @@ def test_reduce_bool(reduce_op, c2sub_context): @pytest.mark.parametrize("axis", [1]) @pytest.mark.parametrize("keepdims", [True, False]) @pytest.mark.parametrize("dtype_out", [np.int16]) -def test_reduce_params(chunks_blocks, axis, keepdims, dtype_out, reduce_op, c2sub_context): +def test_reduce_params(chunks_blocks, axis, keepdims, dtype_out, reduce_op, cat2_context): shape = (60, 60) a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks) if axis is not None and np.isscalar(axis) and len(a1.shape) >= axis: @@ -125,7 +125,7 @@ def test_reduce_params(chunks_blocks, axis, keepdims, dtype_out, reduce_op, c2su ], ) @pytest.mark.parametrize("axis", [0]) -def test_reduce_expr_arr(chunks_blocks, axis, reduce_op, c2sub_context): +def test_reduce_expr_arr(chunks_blocks, axis, reduce_op, cat2_context): shape = (60, 60) a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks) if axis is not None and len(a1.shape) >= axis: diff --git a/tests/ndarray/test_c2array_udf.py b/tests/ndarray/test_c2array_udf.py index 7d4a1438..223c95b3 100644 --- a/tests/ndarray/test_c2array_udf.py +++ b/tests/ndarray/test_c2array_udf.py @@ -12,7 +12,7 @@ import blosc2 -ROOT = "b2tests" +ROOT = "@public" DIR = "expr/" pytestmark = pytest.mark.network @@ -34,7 +34,7 @@ def udf1p(inputs_tuple, output, offset): ), ], ) -def test_1p(chunks, blocks, chunked_eval, c2sub_context): +def test_1p(chunks, blocks, chunked_eval, cat2_context): dtype = np.float64 shape = (60, 60) urlpath = f"ds-0-10-linspace-{dtype.__name__}-(True, False)-a1-{shape}d.b2nd" @@ -71,7 +71,7 @@ def udf2p(inputs_tuple, output, offset): pytest.param((53, 20), (10, 13), (slice(3, 8), slice(9, 12)), None, False), ], ) -def test_getitem(chunks, blocks, slices, urlpath, contiguous, chunked_eval, c2sub_context): +def test_getitem(chunks, blocks, slices, urlpath, contiguous, chunked_eval, cat2_context): dtype = np.float64 shape = (60, 60) blosc2.remove_urlpath(urlpath) diff --git a/tests/ndarray/test_proxy_c2array.py b/tests/ndarray/test_proxy_c2array.py index 602d373e..f02ed797 100644 --- a/tests/ndarray/test_proxy_c2array.py +++ b/tests/ndarray/test_proxy_c2array.py @@ -15,7 +15,7 @@ pytestmark = pytest.mark.network NITEMS_SMALL = 1_000 -ROOT = "b2tests" +ROOT = "@public" DIR = "expr/" @@ -44,7 +44,7 @@ def get_array(shape, chunks_blocks): ("proxy", (slice(37, 53), slice(19, 233))), ], ) -def test_simple(chunks_blocks, c2sub_context, urlpath, slices): +def test_simple(chunks_blocks, cat2_context, urlpath, slices): shape = (60, 60) a = get_array(shape, chunks_blocks) b = blosc2.Proxy(a, urlpath=urlpath, mode="w") @@ -62,7 +62,7 @@ def test_simple(chunks_blocks, c2sub_context, urlpath, slices): blosc2.remove_urlpath(urlpath) -def test_small(c2sub_context): +def test_small(cat2_context): shape = (NITEMS_SMALL,) chunks_blocks = "default" a = get_array(shape, chunks_blocks) @@ -77,7 +77,7 @@ def test_small(c2sub_context): np.testing.assert_allclose(cache[...], a[...]) -def test_open(c2sub_context): +def test_open(cat2_context): urlpath = "proxy.b2nd" shape = (NITEMS_SMALL,) chunks_blocks = "default" diff --git a/tests/ndarray/test_proxy_expr.py b/tests/ndarray/test_proxy_expr.py index c92cca21..718da234 100644 --- a/tests/ndarray/test_proxy_expr.py +++ b/tests/ndarray/test_proxy_expr.py @@ -15,7 +15,7 @@ pytestmark = pytest.mark.network -ROOT = "b2tests" +ROOT = "@public" DIR = "expr/" @@ -60,7 +60,7 @@ def get_arrays(shape, chunks_blocks): (False, False), ], ) -def test_expr_proxy_operands(chunks_blocks, c2sub_context): +def test_expr_proxy_operands(chunks_blocks, cat2_context): shape = (60, 60) a1, a2, a3, a4, na1, na2, na3, na4, cleanup_paths = get_arrays(shape, chunks_blocks) diff --git a/tests/test_open_c2array.py b/tests/test_open_c2array.py index 13096545..b52bf8d2 100644 --- a/tests/test_open_c2array.py +++ b/tests/test_open_c2array.py @@ -18,11 +18,11 @@ pytestmark = pytest.mark.network NITEMS_SMALL = 1_000 -ROOT = "b2tests" +ROOT = "@public" DIR = "expr/" -def test_open_c2array(c2sub_context): +def test_open_c2array(cat2_context): dtype = np.float64 shape = (NITEMS_SMALL,) chunks_blocks = "default" @@ -50,7 +50,7 @@ def test_open_c2array(c2sub_context): _ = blosc2.open(urlpath, mode="r", offset=0, cparams={}) -def test_open_c2array_args(c2sub_context): # instance args prevail +def test_open_c2array_args(cat2_context): # instance args prevail dtype = np.float64 shape = (NITEMS_SMALL,) chunks_blocks = "default" @@ -58,8 +58,8 @@ def test_open_c2array_args(c2sub_context): # instance args prevail path = pathlib.Path(f"{ROOT}/{DIR + path}").as_posix() with blosc2.c2context(urlbase="https://wrong.example.com/", auth_token="wrong-token"): - urlbase = c2sub_context["urlbase"] - auth_token = blosc2.c2array.login(**c2sub_context) if c2sub_context["username"] else None + urlbase = cat2_context["urlbase"] + auth_token = blosc2.c2array.login(**cat2_context) if cat2_context["username"] else None a1 = blosc2.C2Array(path, urlbase=urlbase, auth_token=auth_token) urlpath = blosc2.URLPath(path, urlbase=urlbase, auth_token=auth_token) a_open = blosc2.open(urlpath, mode="r", offset=0) @@ -71,7 +71,7 @@ def c2sub_user(): def rand32(): return random.randint(0, 0x7FFFFFFF) - urlbase = "https://demo-auth.caterva2.net/" + urlbase = "https://cat2.cloud/testing/" username = f"user+{rand32():x}@example.com" password = hex(rand32())