From 3e21e544da17ebf7b2773921a793762017efdaea Mon Sep 17 00:00:00 2001 From: Simon Perkins Date: Tue, 15 Oct 2024 09:21:34 +0200 Subject: [PATCH] Remove incomplete testing feature --- pyproject.toml | 5 +--- tests/test_corpus.py | 47 ------------------------------------- xarray_ms/testing/corpus.py | 14 ----------- 3 files changed, 1 insertion(+), 65 deletions(-) delete mode 100644 tests/test_corpus.py delete mode 100644 xarray_ms/testing/corpus.py diff --git a/pyproject.toml b/pyproject.toml index 41c2114..b8f33b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,12 +15,9 @@ cacheout = "^0.16.0" arcae = "^0.2.5" typing-extensions = { version = "^4.12.2", python = "<3.11" } zarr = {version = "^2.18.3", optional = true, extras = ["testing"]} -requests = {version = "^2.32.3", optional = true, extras = ["testing"]} -diskcache = {version = "^5.6.3", optional = true, extras = ["testing"]} -appdirs = {version = "^1.4.4", optional = true, extras = ["testing"]} [tool.poetry.extras] -testing = ["appdirs", "dask", "diskcache", "distributed", "pytest", "requests", "zarr"] +testing = ["dask", "distributed", "pytest", "zarr"] [tool.poetry.plugins."xarray.backends"] "xarray-ms:msv2" = "xarray_ms.backend.msv2.entrypoint:MSv2PartitionEntryPoint" diff --git a/tests/test_corpus.py b/tests/test_corpus.py deleted file mode 100644 index 0766a11..0000000 --- a/tests/test_corpus.py +++ /dev/null @@ -1,47 +0,0 @@ -import concurrent.futures as cf -import json -import multiprocessing -import os - -import appdirs -import requests - -from xarray_ms.testing.corpus import METADATA_URL, dropbox_url - -HEADERS = {"User-Agent": "Wget/1.20.3"} - - -def test_corpus(): - response = requests.get(METADATA_URL, headers=HEADERS) - payload = json.loads(response.text) - - _ = payload["version"] - ncpus = multiprocessing.cpu_count() - user_cache_dir = appdirs.user_cache_dir("xarray-ms") - os.makedirs(user_cache_dir, exist_ok=True) - - def download_and_save(url: str, name: str): - path = os.path.sep.join((user_cache_dir, name)) - with open(path, "wb") as f: - response = requests.get(url, headers=HEADERS, stream=True) - for chunk in response.iter_content(chunk_size=1024 * 1024): - f.write(chunk) - - with cf.ThreadPoolExecutor(max_workers=ncpus) as pool: - futures = [] - names = [] - meta = [] - - for name, metadata in payload["metadata"].items(): - if metadata["dtype"] != "CASA MS v2": - continue - - print(metadata["dtype"]) - - url = dropbox_url(metadata["file"], metadata["id"], metadata["rlkey"]) - futures.append(pool.submit(download_and_save, url, metadata["file"])) - names.append(name) - meta.append(metadata) - - done, _ = cf.wait(futures, return_when="ALL_COMPLETED") - [f.result() for f in done] diff --git a/xarray_ms/testing/corpus.py b/xarray_ms/testing/corpus.py deleted file mode 100644 index d06c658..0000000 --- a/xarray_ms/testing/corpus.py +++ /dev/null @@ -1,14 +0,0 @@ -# Constants defining the location of the metadata file -# describing the test corpus -METADATA_FILENAME = "file.download.json" -METADATA_ID = "1m53led1mchpdc4m3pv37" -METADATA_RLKEY = "enkp8m1hv437nu6p020owflrt&st=11psoc6n" - - -def dropbox_url(filename: str, file_id: str, rlkey: str) -> str: - """Returns the URL for a dropbox file""" - return f"https://www.dropbox.com/scl/fi/{file_id}/{filename}?rlkey={rlkey}" - - -# The URL for the metadata file describing the test corpus -METADATA_URL = dropbox_url(METADATA_FILENAME, METADATA_ID, METADATA_RLKEY)