Skip to content

Commit

Permalink
no need to run griddap_initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
ocefpaf committed Aug 29, 2024
1 parent c3ee123 commit 60de53b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions erddapy/erddapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,24 @@ def __init__(
self.response = response

# Initialized only via properties.
self.constraints: dict | None = None
self.server_functions: dict | None = None
self.dataset_id: OptionalStr = None
self.requests_kwargs: dict = {}
self.auth: tuple | None = None

self.constraints: dict | None = None
self.variables: OptionalList | None = None
self.dim_names: OptionalList | None = None

@property
def dataset_id(self) -> str:
"""dataset_id property."""
return self._dataset_id

@dataset_id.setter
def dataset_id(self, value: str) -> None:
self._dataset_id = value
self.griddap_initialize(dataset_id=value)

self._get_variables = functools.lru_cache(maxsize=128)(
self._get_variables_uncached,
)
Expand All @@ -171,15 +181,11 @@ def griddap_initialize(
"""
dataset_id = dataset_id if dataset_id else self.dataset_id
msg = f"Method only valid using griddap protocol, got {self.protocol}"
if self.protocol != "griddap":
raise ValueError(msg)
return
msg = f"Must set a valid dataset_id, got {self.dataset_id}"
if dataset_id is None:
raise ValueError(msg)
# Return the opendap URL without any slicing.
if self.response == "opendap":
return

metadata_url = f"{self.server}/griddap/{self.dataset_id}"
(
Expand Down

0 comments on commit 60de53b

Please sign in to comment.