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

Error on big Asset data query while partial response is correctly sent #29

Open
TimotheeGerber opened this issue Mar 29, 2018 · 0 comments
Assignees
Labels

Comments

@TimotheeGerber
Copy link
Contributor

Context

I have an Asset service containing a collection of 101 elements. I am using the get_collection method to get my elements.

def get_collection(self, collection, filter=None, fields=None,
page_size=None):

Result

I get an error message containing the first 100 elements of my query. No exception is raised. No data is returned.

Expected result

There should be no error message. I should get the first 100 elements of my query. Ideally, I should also get the link to fetch the next batch of elements.

What happened?

Asset get_collection is using the _get method in service.py. This method supposes that a working query returns a 200 status code.

if response.status_code == 200:

Unfortunately, Asset service limits the number of returned element to 100 by default. If the collection contains more elements, the status code returned is 206. Therefore, an error is logged and an exception is raised. But requests raises no exception for a 206 status code.

How to fix?

The condition in _get method could by changed for something like:

    if response:
    # or 
    if response.ok:

It would then accept both 200 and 206 code. As a side effect, it would accept many more status code. Could this be annoying?

Nevertheless, this modification is not enough to address another problem: the link to the next data batch is lost. This link is present in the header of the response.

Work around

As a temporary work around, I just increased the number of elements that an Asset query can return. I added page_size=1000 as an argument of the Asset get_collection method.

Version

I use the 1.0.0rc1 version of PredixPy.

@j12y j12y self-assigned this Apr 5, 2018
@j12y j12y added the bug label Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants