Skip to content

Commit

Permalink
Pass polytope from_source kwargs to polytope client (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandorkertesz authored Apr 17, 2024
1 parent 6b2d41b commit 0212f7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/release_notes/version_0.7_updates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ New features
- added support for Lambert Conformal projection when using :meth:`Field.projection() <data.core.fieldlist.Field.projection>`
- changed the default of the ``bits_per_value`` option to None in :meth:`NumpyFieldList.save() <data.sources.numpy_list.NumpyFieldList.save>`. None means the original ``bits_per_value`` in the GRIB header is kept when the data is written to disk.
- added the ``model`` option to the :ref:`data-sources-eod` source
- added the ``prompt`` optional argument to certain retrievals to control whether the prompt is to use. When enabled (default), the prompt asks the user to provide credentials when none seems to be specified. See the :ref:`data-sources-cds`, :ref:`data-sources-mars`, :ref:`data-sources-wekeo`, :ref:`data-sources-wekeocds` sources for more information on how the prompt works.
- added the ``prompt`` optional argument to certain retrievals to control whether the prompt is to be used. When enabled (default), the prompt asks the user to provide credentials when none seems to be specified. See the :ref:`data-sources-cds`, :ref:`data-sources-mars`, :ref:`data-sources-wekeo`, :ref:`data-sources-wekeocds` sources for more information on how the prompt works.
- added the ``user_email`` and ``user_key`` options to the :ref:`data-sources-polytope` source. This source does not use the prompt any longer.
- allowed using :func:`save` without specifying a file name. In this case an attempt is made to generate the filename automatically, when it fails an exception is thrown.
- :func:`from_source` now fails when trying to load an empty file
Expand Down
26 changes: 3 additions & 23 deletions earthkit/data/sources/polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,10 @@ def __init__(

self.stream = stream

# Polytope client configuration options
client_kwargs = {}
for k in [
"config_path",
"address",
"port",
"username",
"key_path",
"quiet",
"verbose",
"log_file",
"log_level",
"user_key",
"user_email",
"password",
"insecure",
"skip_tls",
"cli",
]:
if k in kwargs:
client_kwargs[k] = kwargs.pop(k, None)

self.request = dict(dataset=dataset, request=request)
self.client = polytope.api.Client(**client_kwargs)

# all the kwargs are passed to the client!
self.client = polytope.api.Client(**kwargs)

def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.request['dataset']}, {self.request['request']})"
Expand Down

0 comments on commit 0212f7f

Please sign in to comment.