10000 Implement view filters on the populate* request options by graysonarts · Pull Request #260 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

Implement view filters on the populate* request options #260

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
Jan 31, 2018
Merged

Implement view filters on the populate* request options #260

merged 6 commits into from
Jan 31, 2018

Conversation

graysonarts
Copy link
Contributor

This is fallout from a bug I was fixing elsewhere, but we should have them.

@graysonarts graysonarts requested review from t8y8 and LGraber January 30, 2018 22:32
@@ -105,7 +105,7 @@ def csv_fetcher():
def _get_view_csv(self, view_item, req_options):
url = "{0}/{1}/data".format(self.baseurl, view_item.id)

with closing(self.get_request(url, parameters={"stream": True})) as server_response:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is right, the 'stream=true' is an option for the requests library, not something that gets included in the url string, which is what apply_query_parameters does.

t8y8
t8y8 previously approved these changes Jan 31, 2018
Copy link
Collaborator
@t8y8 t8y8 left a comment

Choose a reason for hiding this comment

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

Fit-It-Then-:rocket:

All minor

@@ -105,7 +105,7 @@ def csv_fetcher():
def _get_view_csv(self, view_item, req_options):
url = "{0}/{1}/data".format(self.baseurl, view_item.id)

with closing(self.get_request(url, parameters={"stream": True})) as server_response:
with closing(self.get_request(url, req_options, {"stream": True})) as server_response:
Copy link
Collaborator
@t8y8 t8y8 Jan 31, 2018

Choose a reason for hiding this comment

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

Thanks!

This might already by correct, but since I'm not 100% sure the order of function parameters as they get passed to the underlying requests.get, can you make the {"stream":True} a named parameter ( parameters=...)

Ugh, naming a parameter parameters is confusing. Thanks Requests....

@@ -62,24 +62,49 @@ def apply_query_params(self, url):
return "{0}?{1}".format(url, '&'.join(params))


class ImageRequestOptions(RequestOptionsBase):
class _FilterOptionsBase(RequestOptionsBase):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like a reasonable refactor.

Can you give this class a docstring just so at a glance we can tell what it's used for vs other optionsbases?

class ImageRequestOptions(RequestOptionsBase):
class _FilterOptionsBase(RequestOptionsBase):
def __init__(self):
self.view_filters = []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Calling it view filters and then using it in CSV options is a little confusing to me -- can you tell me your thinking on this vs just 'filters'?

I'm not opposed just want to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We already have filters which is for filtering responses to the "get" calls. View Filters are different because they are filtering the view. A CSV is still a view of the data...

Copy link
Collaborator

Choose a reason for hiding this comment

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

These are filtering literal Views (Vizzes?) Ok that makes sense.

return "{0}?{1}".format(url, '&'.join(params))


class ImageRequestOptions(_FilterOptionsBase):
# if 'high' isn't specified, the REST API endpoint returns an image with standard resolution
class Resolution:
High = 'high'

def __init__(self, imageresolution=None):
Copy link
Collaborator
@t8y8 t8y8 Jan 31, 2018

Choose a reason for hiding this comment

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

Side note: I thought I made this so it was image_resolution... maybe I never checked that fix in?

I might make a PR after this merges

def apply_query_params(self, url):
raise NotImplementedError()

def vf(self, name, value):
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's no code testing this or sampling this yet, but I'm guessing this makes it:

opts = ImageRequestOptions()
opts.vf('a', 1).vf('b', 2) etc?

Baby-builder pattern!
Did you still want to refactor this all to eventually just be builder-y and call str on those? (referenced in #212)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, eventually, we will refactor to a builder pattern!

Copy link
Collaborator
@t8y8 t8y8 left a comment

Choose a reason for hiding this comment

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

🚀

@graysonarts graysonarts changed the base branch from master to development January 31, 2018 22:24
@graysonarts graysonarts merged commit 7816d2e into tableau:development Jan 31, 2018
@graysonarts graysonarts deleted the add-view-filters-to-exports branch January 31, 2018 22:24
@lpm-lpm
Copy link
lpm-lpm commented Jun 12, 2018

Hi @RussTheAerialist

Any ETA of this getting merged to master branch?

@ecmonsen
Copy link

Thank you for adding view filters - I needed it for requesting view images. Looking forward to seeing it merged into the master branch.

@mcoles
Copy link
mcoles commented Jul 13, 2018

Ditto, this is important for me as well!

@graysonarts
Copy link
Contributor Author

We released v0.7 on Wednesday which contains these changes.

@xevo-emonsen
Copy link

You rock, @RussTheAerialist! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0