Skip to content

Ensure sorted data on upload of data from python #126

Merged
hanne-opseth-rygg-4ss merged 4 commits intomasterfrom
ESS-2644-fetching-data-via-get-in-python-implicitly-expects-sorted-data-uploading-doesnt-validate-that-it-is
Jun 4, 2024
Merged

Ensure sorted data on upload of data from python #126
hanne-opseth-rygg-4ss merged 4 commits intomasterfrom
ESS-2644-fetching-data-via-get-in-python-implicitly-expects-sorted-data-uploading-doesnt-validate-that-it-is

Conversation

@hanne-opseth-rygg-4ss
Copy link
Copy Markdown
Contributor

@hanne-opseth-rygg-4ss hanne-opseth-rygg-4ss commented May 31, 2024

This PR is related to user story ESS-2644

Description

Not allowed to create and append to timeseries of the index is not sorted. If a KeyError is raised when trying to get data, the data is sorted before once more trying to access the specific date range.

Comment thread datareservoirio/client.py
series.index.name = None

if series.empty and raise_empty: # may become empty after slicing
raise ValueError("can't find data in the given interval")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you might get the warning that you've gotten a keyError and that we try to sort the data and then you will get another valueError saying that the program can't find data. Should i maybe copy the following code into each part of the try/except?

series.index.name = None
if series.empty and raise_empty: # may become empty after slicing
raise ValueError("can't find data in the given interval")

Comment thread tests/test_client.py
Copy link
Copy Markdown
Contributor

@branislav-jenco-4ss branislav-jenco-4ss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple nitpicks!

Comment thread datareservoirio/client.py Outdated
Comment thread docs/user_guide/index.rst Outdated
Comment thread docs/user_guide/manage_series.rst Outdated
Comment thread tests/test_client.py Outdated
Comment thread tests/test_client.py
Copy link
Copy Markdown
Contributor

@branislav-jenco-4ss branislav-jenco-4ss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hanne-opseth-rygg-4ss hanne-opseth-rygg-4ss merged commit 4101ba5 into master Jun 4, 2024
@hanne-opseth-rygg-4ss hanne-opseth-rygg-4ss deleted the ESS-2644-fetching-data-via-get-in-python-implicitly-expects-sorted-data-uploading-doesnt-validate-that-it-is branch June 4, 2024 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Changes to the code

Development

Successfully merging this pull request may close these issues.

2 participants