Skip to content

pdyap version dependent client.open_url call #6656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 16, 2022
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
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Bug fixes
allowing the ``encoding`` and ``unlimited_dims`` options with ``save_mfdataset``.
(:issue:`6684`)
By `Travis A. O'Brien <https://github.com/taobrienlbl>`_.
- Fix backend support of pydap versions <3.3.0 (:issue:`6648`, :pull:`6656`).
By `Hauke Schulz <https://github.com/observingClouds>`_.
- :py:meth:`Dataset.where` with ``drop=True`` now behaves correctly with mixed dimensions.
(:issue:`6227`, :pull:`6690`)
By `Michael Niklas <https://github.com/headtr1ck>`_.
Expand Down
34 changes: 16 additions & 18 deletions xarray/backends/pydap_.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import numpy as np
from packaging.version import Version

from ..core import indexing
from ..core.pycompat import integer_types
Expand All @@ -17,7 +18,9 @@

try:
import pydap.client
import pydap.lib

pydap_version = pydap.lib.__version__
has_pydap = True
except ModuleNotFoundError:
has_pydap = False
Expand Down Expand Up @@ -99,29 +102,24 @@ def open(
user_charset=None,
):

if output_grid is None:
output_grid = True

if verify is None:
verify = True

if timeout is None:
from pydap.lib import DEFAULT_TIMEOUT

timeout = DEFAULT_TIMEOUT

if user_charset is None:
user_charset = "ascii"

ds = pydap.client.open_url(
url=url,
application=application,
session=session,
output_grid=output_grid,
timeout=timeout,
verify=verify,
user_charset=user_charset,
)
kwargs = {
"url": url,
"application": application,
"session": session,
"output_grid": output_grid or True,
"timeout": timeout,
}
if Version(pydap_version) >= Version("3.3.0"):
if verify is not None:
kwargs.update({"verify": verify})
if user_charset is not None:
kwargs.update({"user_charset": user_charset})
ds = pydap.client.open_url(**kwargs)
return cls(ds)

def open_store_variable(self, var):
Expand Down