Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions virtualizarr/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
requires_zarr_python,
slow_test,
)
from virtualizarr.tests.utils import PYTEST_TMP_DIRECTORY_URL_PREFIX

icechunk = pytest.importorskip("icechunk")

Expand Down Expand Up @@ -143,19 +144,16 @@ def roundtrip_as_in_memory_icechunk(

config = icechunk.RepositoryConfig.default()

url_prefixes = ["file:///private/var/folders/70", "file:///tmp/"]

for url_prefix in url_prefixes:
container = icechunk.VirtualChunkContainer(
url_prefix=url_prefix,
store=icechunk.local_filesystem_store(url_prefix),
)
config.set_virtual_chunk_container(container)
container = icechunk.VirtualChunkContainer(
url_prefix=PYTEST_TMP_DIRECTORY_URL_PREFIX,
store=icechunk.local_filesystem_store(PYTEST_TMP_DIRECTORY_URL_PREFIX),
)
config.set_virtual_chunk_container(container)

repo = icechunk.Repository.create(
storage=storage,
config=config,
authorize_virtual_chunk_access={prefix: None for prefix in url_prefixes},
authorize_virtual_chunk_access={PYTEST_TMP_DIRECTORY_URL_PREFIX: None},
)
session = repo.writable_session("main")

Expand Down
8 changes: 1 addition & 7 deletions virtualizarr/tests/test_writers/test_icechunk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os
import tempfile
import time
from datetime import datetime, timedelta, timezone
from pathlib import Path
Expand All @@ -15,6 +13,7 @@
from zarr.core.metadata import ArrayV3Metadata

from virtualizarr.manifests import ChunkManifest, ManifestArray
from virtualizarr.tests.utils import PYTEST_TMP_DIRECTORY_URL_PREFIX
from virtualizarr.writers.icechunk import generate_chunk_key
from virtualizarr.xarray import separate_coords

Expand All @@ -28,11 +27,6 @@
)


# Find location of pytest temporary data in what should be a cross-platform way. This should be the same as what pytest actually does - see https://docs.pytest.org/en/stable/how-to/tmp_path.html#temporary-directory-location-and-retention
# The realpath call is there to resolve any symbolic links, such as from /var/ to /private/var/ on MacOS, as Icechunk needs the entire URL prefix without symlinks.
PYTEST_TMP_DIRECTORY_URL_PREFIX = f"file://{os.path.realpath(tempfile.gettempdir())}"


@pytest.fixture(scope="function")
def icechunk_storage(tmp_path: Path) -> "Storage":
from icechunk import Storage
Expand Down
5 changes: 5 additions & 0 deletions virtualizarr/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import os
import tempfile
from pathlib import Path
from urllib.parse import urlparse

Expand All @@ -9,6 +10,10 @@
from virtualizarr.parsers import HDFParser
from virtualizarr.registry import ObjectStoreRegistry

# Find location of pytest temporary data in what should be a cross-platform way. This should be the same as what pytest actually does - see https://docs.pytest.org/en/stable/how-to/tmp_path.html#temporary-directory-location-and-retention
# The realpath call is there to resolve any symbolic links, such as from /var/ to /private/var/ on MacOS, as Icechunk needs the entire URL prefix without symlinks.
PYTEST_TMP_DIRECTORY_URL_PREFIX = f"file://{os.path.realpath(tempfile.gettempdir())}"


def obstore_local(url: str) -> ObjectStore:
parsed = urlparse(url)
Expand Down