Skip to content

Commit

Permalink
Attempt at nested optional depedency usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkinsspatial committed Nov 18, 2024
1 parent 5de9d2c commit a8cc82f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,17 @@ dependencies = [
[project.optional-dependencies]
hdf_reader = [
"fsspec",
"h5py",
"hdf5plugin",
"imagecodecs",
"imagecodecs-numcodecs==2024.6.1",
"numcodecs"
]
test = [
"codecov",
"fastparquet",
"fsspec",
"h5py",
"hdf5plugin",
"imagecodecs",
"imagecodecs-numcodecs==2024.6.1",
"kerchunk>=0.2.5",
"mypy",
"netcdf4",
Expand All @@ -57,6 +56,7 @@ test = [
"ruff",
"s3fs",
"scipy",
"virtualizarr[hdf_reader]"
]


Expand Down
10 changes: 10 additions & 0 deletions virtualizarr/readers/hdf/hdf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math
from dataclasses import dataclass
from typing import TYPE_CHECKING, Dict, Iterable, List, Mapping, Optional, Union

import numpy as np
Expand All @@ -21,6 +22,15 @@

h5py = soft_import("h5py", "For reading hdf files", strict=False)

if not h5py:

@dataclass
class h5py_stub:
Group: str
Dataset: str

h5py = h5py_stub(Group="", Dataset="")


class HDFVirtualBackend(VirtualBackend):
@staticmethod
Expand Down

0 comments on commit a8cc82f

Please sign in to comment.