-
Notifications
You must be signed in to change notification settings - Fork 178
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
Initial attempt at enabling reading the columns from the datasource #45
Initial attempt at enabling reading the columns from the datasource #45
Conversation
Nice. Some questions:
|
@benlower the version number was changed to appease setuptools. That's the preferred format for in-development versions. I'd honestly, leave it at 0 unless we need to push a development version to pypi for some reason (let's try to not do that). We'll increment the minor for the next release of features, but that'll be done right before we merge into master. This does not address writing columns at all. We'll need more logic, but I wanted to unblock @t8y8 for reading columns as quickly as possible, so focused on reading first, and then I'll add writing. |
Will this work for TWBs? The XPath queries look like they shouldn't care, but workbooks might handle local/remote fields slightly differently? |
@@ -0,0 +1,62 @@ | |||
import functools | |||
|
|||
_ATTRIBUTES = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you comment how each of these fields relates to the UI, it's not intuitive that caption is what most people would call the 'name' in the UI, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can do that.
@t8y8 For a workbook, you'd need to iterate through all of the datasources and get the columns from the datasource. Since workbook creates a Datasource object for each Do you want a method on workbook that gives you everything by combining datasource name and column name in the standard way: |
That makes sense, iterating through the datasources to get the fields works for me! A convenience method "get_all_fields_with_datasource" or something is a nice addition for the "get a list of things to audit" use case. |
whew. I had to rebase that with the feature @t8y8 just merged in, and I was scared force pushing to github on my feature branch was going to do messy things, but yay! Must just be perforce withdrawals |
Running this through some real work workbooks and I noticed a few things:
|
@t8y8 Suggested change to the API of this change
My understanding of how we display names in the UI is:
|
I like the API proposal, in the common case folks are trying to get a list of fields and matching Desktop is an intuitive default. For folks who need remote name they can go for 'id'. It remvoes the need for this function in my script too:
The ordereddict is probably only with it if it matches document order though, if it doesn't I wouldn't continue the trouble of the overhead (though py35 gets a c-based ordereddict) -- is it verified that it matches doc order? |
I haven't verified that it matches the order in the UI, but I'll do that before implementing the more complex look up. |
Okay playing around in the UI, it looks like fields are not related to document order. We display them in alphabetic order in the measures and dimensions panes. I think I'm going to ignore order for this PR and if we decide we want to be specific about order, I'll do it as a separate PR. |
Sounds good to me |
@@ -10,6 +10,7 @@ | |||
|
|||
from tableaudocumentapi import Connection, xfile | |||
from tableaudocumentapi import Field | |||
from tableaudocumentapi.multilookup_dict import MultiLookupDict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't address the renaming, I'm working on that next.
I'm writing against the new api changes in a local branch, and it feels pretty good! |
yay! is that a "LGTM" for merging? |
Yup. LGTM to merge. Just wrote some random lines against it, and it's feeling pretty good. Since it's ultimately a dict, the iteration is over the keys by default, that does mean the code has to do something like: But that's easily fixed with a I'll share the script I was able to generate when combining this with the REST API! IT TOTALLY DOES WHAT I NEED NOW. |
@t8y8 Awesome, merging in just a moment. for k, v in datasources.items():
# k is the key in the dictionary (in this case the id)
# v is the value (the field object) |
Addresses issue #42 . This enables the ability to read columns. I want to do more extensive testing, and I still need to add documentation into the code (pydoc stuff), but this is the initial attempt for feedback on the approach.