Skip to content

Commit 9ca0288

Browse files
Merge pull request #511 from Blosc/network-to-cat2cloud
Network tests have been migrated to new cat2.cloud/testing site
2 parents ecbcb75 + 44fef20 commit 9ca0288

8 files changed

Lines changed: 31 additions & 43 deletions

File tree

src/blosc2/c2array.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,6 @@ def info(path, urlbase, params=None, headers=None, model=None, auth_token=None):
144144
return json if model is None else model(**json)
145145

146146

147-
def subscribe(root, urlbase, auth_token):
148-
url = _sub_url(urlbase, f"api/subscribe/{root}")
149-
return _xpost(url, auth_token=auth_token)
150-
151-
152147
def fetch_data(path, urlbase, params, auth_token=None, as_blosc2=False):
153148
url = _sub_url(urlbase, f"api/fetch/{path}")
154149
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
237232
# Try to 'open' the remote path
238233
try:
239234
self.meta = info(self.path, self.urlbase, auth_token=self.auth_token)
240-
except requests.HTTPError:
241-
# Subscribe to root and try again. It is less latency to subscribe directly
242-
# than to check for the subscription.
243-
root, _ = self.path.split("/", 1)
244-
subscribe(root, self.urlbase, self.auth_token)
245-
try:
246-
self.meta = info(self.path, self.urlbase, auth_token=self.auth_token)
247-
except requests.HTTPError as err:
248-
raise FileNotFoundError(f"Remote path not found: {path}.\nError was: {err}") from err
235+
except requests.HTTPError as err:
236+
raise FileNotFoundError(f"Remote path not found: {path}.\nError was: {err}") from err
249237
cparams = self.meta["schunk"]["cparams"]
250238
# Remove "filters, meta" from cparams; this is an artifact from the server
251239
cparams.pop("filters, meta", None)

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def pytest_configure(config):
1717

1818

1919
@pytest.fixture(scope="session")
20-
def c2sub_context():
20+
def cat2_context():
2121
# You may use the URL and credentials for an already existing user
2222
# in a different Caterva2 subscriber.
23-
urlbase = os.environ.get("BLOSC_C2URLBASE", "https://demo.caterva2.net/")
23+
urlbase = os.environ.get("BLOSC_C2URLBASE", "https://cat2.cloud/testing/")
2424
c2params = {"urlbase": urlbase, "username": None, "password": None}
2525
with blosc2.c2context(**c2params):
2626
yield c2params

tests/ndarray/test_c2array_expr.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
pytestmark = pytest.mark.network
1717

1818
NITEMS_SMALL = 1_000
19-
ROOT = "b2tests"
19+
ROOT = "@public"
2020
DIR = "expr/"
2121

2222

@@ -51,7 +51,7 @@ def get_arrays(shape, chunks_blocks):
5151
(False, False),
5252
],
5353
)
54-
def test_simple(chunks_blocks, c2sub_context):
54+
def test_simple(chunks_blocks, cat2_context):
5555
shape = (60, 60)
5656
a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks)
5757

@@ -67,7 +67,7 @@ def test_simple(chunks_blocks, c2sub_context):
6767
np.testing.assert_allclose(res[:], nres)
6868

6969

70-
def test_simple_getitem(c2sub_context):
70+
def test_simple_getitem(cat2_context):
7171
shape = (NITEMS_SMALL,)
7272
chunks_blocks = "default"
7373
a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks)
@@ -91,7 +91,7 @@ def test_simple_getitem(c2sub_context):
9191
(False, False),
9292
],
9393
)
94-
def test_ixxx(chunks_blocks, c2sub_context):
94+
def test_ixxx(chunks_blocks, cat2_context):
9595
shape = (60, 60)
9696
a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks)
9797
expr = a1**3 + a2**2 + a3**3 - a4 + 3
@@ -103,7 +103,7 @@ def test_ixxx(chunks_blocks, c2sub_context):
103103
np.testing.assert_allclose(res[:], nres)
104104

105105

106-
def test_complex(c2sub_context):
106+
def test_complex(cat2_context):
107107
shape = (NITEMS_SMALL,)
108108
chunks_blocks = "default"
109109
a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks)
@@ -132,7 +132,7 @@ def test_complex(c2sub_context):
132132
(False, False),
133133
],
134134
)
135-
def test_mix_operands(chunks_blocks, c2sub_context):
135+
def test_mix_operands(chunks_blocks, cat2_context):
136136
shape = (60, 60)
137137
a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks)
138138
b1 = blosc2.asarray(na1, chunks=a1.chunks, blocks=a1.blocks)
@@ -168,7 +168,7 @@ def test_mix_operands(chunks_blocks, c2sub_context):
168168

169169

170170
# Tests related with save method
171-
def test_save(c2sub_context):
171+
def test_save(cat2_context):
172172
shape = (60, 60)
173173
tol = 1e-17
174174
a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, (False, True))
@@ -212,7 +212,7 @@ def broadcast_shape(request):
212212

213213

214214
@pytest.fixture
215-
def broadcast_fixture(broadcast_shape, c2sub_context):
215+
def broadcast_fixture(broadcast_shape, cat2_context):
216216
shape1, shape2 = broadcast_shape
217217
dtype = np.float64
218218
na1 = np.linspace(0, 1, np.prod(shape1), dtype=dtype).reshape(shape1)

tests/ndarray/test_c2array_reductions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
pytestmark = pytest.mark.network
1717

1818
NITEMS_SMALL = 1_000
19-
ROOT = "b2tests"
19+
ROOT = "@public"
2020
DIR = "expr/"
2121

2222

@@ -45,7 +45,7 @@ def get_arrays(shape, chunks_blocks):
4545

4646

4747
@pytest.mark.parametrize("reduce_op", ["sum", pytest.param("all", marks=pytest.mark.heavy)])
48-
def test_reduce_bool(reduce_op, c2sub_context):
48+
def test_reduce_bool(reduce_op, cat2_context):
4949
shape = (NITEMS_SMALL,)
5050
chunks_blocks = "default"
5151
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):
7373
@pytest.mark.parametrize("axis", [1])
7474
@pytest.mark.parametrize("keepdims", [True, False])
7575
@pytest.mark.parametrize("dtype_out", [np.int16])
76-
def test_reduce_params(chunks_blocks, axis, keepdims, dtype_out, reduce_op, c2sub_context):
76+
def test_reduce_params(chunks_blocks, axis, keepdims, dtype_out, reduce_op, cat2_context):
7777
shape = (60, 60)
7878
a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks)
7979
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
125125
],
126126
)
127127
@pytest.mark.parametrize("axis", [0])
128-
def test_reduce_expr_arr(chunks_blocks, axis, reduce_op, c2sub_context):
128+
def test_reduce_expr_arr(chunks_blocks, axis, reduce_op, cat2_context):
129129
shape = (60, 60)
130130
a1, a2, a3, a4, na1, na2, na3, na4 = get_arrays(shape, chunks_blocks)
131131
if axis is not None and len(a1.shape) >= axis:

tests/ndarray/test_c2array_udf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import blosc2
1414

15-
ROOT = "b2tests"
15+
ROOT = "@public"
1616
DIR = "expr/"
1717

1818
pytestmark = pytest.mark.network
@@ -34,7 +34,7 @@ def udf1p(inputs_tuple, output, offset):
3434
),
3535
],
3636
)
37-
def test_1p(chunks, blocks, chunked_eval, c2sub_context):
37+
def test_1p(chunks, blocks, chunked_eval, cat2_context):
3838
dtype = np.float64
3939
shape = (60, 60)
4040
urlpath = f"ds-0-10-linspace-{dtype.__name__}-(True, False)-a1-{shape}d.b2nd"
@@ -71,7 +71,7 @@ def udf2p(inputs_tuple, output, offset):
7171
pytest.param((53, 20), (10, 13), (slice(3, 8), slice(9, 12)), None, False),
7272
],
7373
)
74-
def test_getitem(chunks, blocks, slices, urlpath, contiguous, chunked_eval, c2sub_context):
74+
def test_getitem(chunks, blocks, slices, urlpath, contiguous, chunked_eval, cat2_context):
7575
dtype = np.float64
7676
shape = (60, 60)
7777
blosc2.remove_urlpath(urlpath)

tests/ndarray/test_proxy_c2array.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
pytestmark = pytest.mark.network
1616

1717
NITEMS_SMALL = 1_000
18-
ROOT = "b2tests"
18+
ROOT = "@public"
1919
DIR = "expr/"
2020

2121

@@ -44,7 +44,7 @@ def get_array(shape, chunks_blocks):
4444
("proxy", (slice(37, 53), slice(19, 233))),
4545
],
4646
)
47-
def test_simple(chunks_blocks, c2sub_context, urlpath, slices):
47+
def test_simple(chunks_blocks, cat2_context, urlpath, slices):
4848
shape = (60, 60)
4949
a = get_array(shape, chunks_blocks)
5050
b = blosc2.Proxy(a, urlpath=urlpath, mode="w")
@@ -62,7 +62,7 @@ def test_simple(chunks_blocks, c2sub_context, urlpath, slices):
6262
blosc2.remove_urlpath(urlpath)
6363

6464

65-
def test_small(c2sub_context):
65+
def test_small(cat2_context):
6666
shape = (NITEMS_SMALL,)
6767
chunks_blocks = "default"
6868
a = get_array(shape, chunks_blocks)
@@ -77,7 +77,7 @@ def test_small(c2sub_context):
7777
np.testing.assert_allclose(cache[...], a[...])
7878

7979

80-
def test_open(c2sub_context):
80+
def test_open(cat2_context):
8181
urlpath = "proxy.b2nd"
8282
shape = (NITEMS_SMALL,)
8383
chunks_blocks = "default"

tests/ndarray/test_proxy_expr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
pytestmark = pytest.mark.network
1717

18-
ROOT = "b2tests"
18+
ROOT = "@public"
1919
DIR = "expr/"
2020

2121

@@ -60,7 +60,7 @@ def get_arrays(shape, chunks_blocks):
6060
(False, False),
6161
],
6262
)
63-
def test_expr_proxy_operands(chunks_blocks, c2sub_context):
63+
def test_expr_proxy_operands(chunks_blocks, cat2_context):
6464
shape = (60, 60)
6565
a1, a2, a3, a4, na1, na2, na3, na4, cleanup_paths = get_arrays(shape, chunks_blocks)
6666

tests/test_open_c2array.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
pytestmark = pytest.mark.network
1919

2020
NITEMS_SMALL = 1_000
21-
ROOT = "b2tests"
21+
ROOT = "@public"
2222
DIR = "expr/"
2323

2424

25-
def test_open_c2array(c2sub_context):
25+
def test_open_c2array(cat2_context):
2626
dtype = np.float64
2727
shape = (NITEMS_SMALL,)
2828
chunks_blocks = "default"
@@ -50,16 +50,16 @@ def test_open_c2array(c2sub_context):
5050
_ = blosc2.open(urlpath, mode="r", offset=0, cparams={})
5151

5252

53-
def test_open_c2array_args(c2sub_context): # instance args prevail
53+
def test_open_c2array_args(cat2_context): # instance args prevail
5454
dtype = np.float64
5555
shape = (NITEMS_SMALL,)
5656
chunks_blocks = "default"
5757
path = f"ds-0-10-linspace-{dtype.__name__}-{chunks_blocks}-a1-{shape}d.b2nd"
5858
path = pathlib.Path(f"{ROOT}/{DIR + path}").as_posix()
5959

6060
with blosc2.c2context(urlbase="https://wrong.example.com/", auth_token="wrong-token"):
61-
urlbase = c2sub_context["urlbase"]
62-
auth_token = blosc2.c2array.login(**c2sub_context) if c2sub_context["username"] else None
61+
urlbase = cat2_context["urlbase"]
62+
auth_token = blosc2.c2array.login(**cat2_context) if cat2_context["username"] else None
6363
a1 = blosc2.C2Array(path, urlbase=urlbase, auth_token=auth_token)
6464
urlpath = blosc2.URLPath(path, urlbase=urlbase, auth_token=auth_token)
6565
a_open = blosc2.open(urlpath, mode="r", offset=0)
@@ -71,7 +71,7 @@ def c2sub_user():
7171
def rand32():
7272
return random.randint(0, 0x7FFFFFFF)
7373

74-
urlbase = "https://demo-auth.caterva2.net/"
74+
urlbase = "https://cat2.cloud/testing/"
7575
username = f"user+{rand32():x}@example.com"
7676
password = hex(rand32())
7777

0 commit comments

Comments
 (0)