Skip to content
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

docs: Update APIDataset docs and refactor #217

Merged
merged 8 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions kedro-datasets/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Many thanks to the following Kedroids for contributing PRs to this release:

* [BrianCechmanek](https://github.com/BrianCechmanek)
* [McDonnellJoseph](https://github.com/McDonnellJoseph)

# Release 1.2.1:
astrojuanlu marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
21 changes: 9 additions & 12 deletions kedro-datasets/kedro_datasets/api/api_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
from requests import Session, sessions
from requests.auth import AuthBase

# NOTE: kedro.extras.datasets will be removed in Kedro 0.19.0.
# Any contribution to datasets should be made in kedro-datasets
# in kedro-plugins (https://github.com/kedro-org/kedro-plugins)


class APIDataSet(AbstractDataSet[None, requests.Response]):
"""``APIDataSet`` loads/saves data from/to HTTP(S) APIs.
Expand All @@ -38,7 +34,7 @@ class APIDataSet(AbstractDataSet[None, requests.Response]):
Example usage for the `Python API <https://kedro.readthedocs.io/en/stable/data/\
data_catalog.html#use-the-data-catalog-with-the-code-api>`_: ::

>>> from kedro.extras.datasets.api import APIDataSet
>>> from kedro_datasets.api import APIDataSet
>>>
>>>
>>> data_set = APIDataSet(
Expand All @@ -63,7 +59,7 @@ class APIDataSet(AbstractDataSet[None, requests.Response]):
>>> example_table = '{"col1":["val1", "val2"], "col2":["val3", "val4"]}'

>>> data_set = APIDataSet(
method = "POST"
method = "POST",
url = "url_of_remote_server",
save_args = {"chunk_size":1}
)
Expand Down Expand Up @@ -108,23 +104,24 @@ def __init__(
methods
load_args: Additional parameters to be fed to requests.request.
https://requests.readthedocs.io/en/latest/api/#requests.request
credentials: Allows specifying secrets in credentials.yml.
Expected format is ``('login', 'password')`` if given as a tuple or
list. An ``AuthBase`` instance can be provided for more complex cases.
save_args: Options for saving data on server. Includes all parameters used
during load method. Adds an optional parameter, ``chunk_size`` which
determines the size of the package sent at each request.
credentials: Allows specifying secrets in credentials.yml.
Expected format is ``('login', 'password')`` if given as a tuple or
list. An ``AuthBase`` instance can be provided for more complex cases.

Raises:
ValueError: if both ``auth`` in ``load_args`` and ``credentials`` are
specified.
ValueError: if both ``auth`` and ``credentials`` are specified or used
unsupported RESTful API method.
"""
super().__init__()

# GET method means load
if method == "GET":
self._params = load_args or {}

# PUT, POST, DELETE means save
# PUT, POST means save
elif method in ["PUT", "POST"]:
self._params = deepcopy(self.DEFAULT_SAVE_ARGS)
if save_args is not None:
Expand Down