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

Tap 1.2.1 #1266

Merged
merged 92 commits into from
May 17, 2019
Merged

Tap 1.2.1 #1266

merged 92 commits into from
May 17, 2019

Conversation

jcsegovia
Copy link
Contributor

New capabilities added:
-Tables sharing.
-Tables editing.
-Tables deleting.
-Tables upload using pytables & jobs results.
-Cross match.
-Data access.
-Datalink access.

@astropy-bot
Copy link

astropy-bot bot commented Oct 29, 2018

Check results are now reported in the status checks at the bottom of this page.

@pep8speaks
Copy link

pep8speaks commented Oct 29, 2018

Hello @jcsegovia! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-05-16 15:35:59 UTC

@codecov
Copy link

codecov bot commented Oct 30, 2018

Codecov Report

Merging #1266 into master will decrease coverage by 2.89%.
The diff coverage is 31.87%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #1266     +/-   ##
=========================================
- Coverage    64.6%   61.71%   -2.9%     
=========================================
  Files         166      172      +6     
  Lines       12917    13957   +1040     
=========================================
+ Hits         8345     8613    +268     
- Misses       4572     5344    +772
Impacted Files Coverage Δ
astroquery/gaia/__init__.py 100% <ø> (ø) ⬆️
astroquery/utils/tap/xmlparser/jobSaxParser.py 96.9% <0%> (ø) ⬆️
astroquery/cadc/cadctap/core.py 62.82% <100%> (+0.48%) ⬆️
astroquery/utils/tap/model/tapcolumn.py 92.3% <100%> (ø) ⬆️
astroquery/utils/tap/core.py 28.58% <17.09%> (-22.48%) ⬇️
astroquery/utils/tap/model/group.py 28.57% <28.57%> (ø)
astroquery/utils/tap/xmlparser/groupSaxParser.py 30.95% <30.95%> (ø)
...oquery/utils/tap/xmlparser/sharedItemsSaxParser.py 31.32% <31.32%> (ø)
astroquery/utils/tap/model/shared_item.py 33.33% <33.33%> (ø)
astroquery/utils/tap/model/shared_to_item.py 44.44% <44.44%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0604df7...2e53be9. Read the comment docs.

@jcsegovia
Copy link
Contributor Author

@bsipocz there is an error in Travis CI build, but I am not sure it is due the changes we have done:

Exception occurred: File "/home/travis/build/astropy/astroquery/astropy_helpers/astropy_helpers/extern/automodapi/utils.py", line 82, in <listcomp> pkgitems = [(k, mod.__dict__[k]) for k in mod.__all__] KeyError: 'Conf' The full traceback has been saved in /tmp/sphinx-err-mm1t4pqo.log, if you want to report the issue to the developers. Please also report this if it was a user error, so that a better error message can be provided next time. A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
Please, could you check it...?

@jcsegovia
Copy link
Contributor Author

@keflavich @bsipocz it seems there is an exception when creating documentation. I do not know how to access to the log file that contains the error. In any case, I think it is not related to gaia nor tap modules.
Please, could you check it?

Exception occurred: File "/home/travis/build/astropy/astroquery/astropy_helpers/astropy_helpers/extern/automodapi/utils.py", line 82, in <listcomp> pkgitems = [(k, mod.__dict__[k]) for k in mod.__all__] KeyError: 'Conf' The full traceback has been saved in /tmp/sphinx-err-dq1um9x7.log, ...

@keflavich
Copy link
Contributor

@jcsegovia I'll have a look, but I bet @bsipocz knows better. Have you built successfully locally?

@jcsegovia
Copy link
Contributor Author

@keflavich I do not create Travis builds locally. I have never used Travis before.
I usually develop my python module using an IDE and I test it using 'python setup.py install' in an specific environment, so I can use Anaconda with it (for instance).
I have done those tests locally, and my changes are working.

@pllim
Copy link
Member

pllim commented Nov 6, 2018

@jcsegovia , (tldr) if the error is coming from doc build, you can probably reproduce it by running python setup.py build_sphinx python setup.py build_docs. Unit tests will not run into doc build errors.

p.s. I see that you are TAPping into the service's full potential. 😏

@keflavich
Copy link
Contributor

I am able to reproduce the failure locally, so there is a real issue.

@keflavich
Copy link
Contributor

The problem is that you commented out the entire configuration block in astroquery/gaia/__init__.py, but left Conf in __all__. Did you intentionally remove the configuration block?

Copy link
Contributor

@keflavich keflavich left a comment

Choose a reason for hiding this comment

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

Unless you have a strong motivation for moving the configuration stuff out of __init__.py, please leave it there; that's where it resides for all other astroquery modules.

astroquery/gaia/__init__.py Outdated Show resolved Hide resolved
astroquery/gaia/__init__.py Show resolved Hide resolved
astroquery/gaia/core.py Outdated Show resolved Hide resolved
@jcsegovia
Copy link
Contributor Author

@pllim @keflavich thanks! I was able to find the error by executing 'python setup.py build_sphinx'
I see no reason for moving conf into gaia core.py. I have moved it into init.py (original location).

keflavich
keflavich previously approved these changes Nov 7, 2018
@keflavich
Copy link
Contributor

lgtm. @bsipocz, anything else, or shall we merge today?

@bsipocz bsipocz added this to the v0.3.9 milestone Nov 8, 2018
@bsipocz
Copy link
Member

bsipocz commented Nov 8, 2018

Ohh, I'm sorry, I totally lost track of this. Let me do a review tomorrow (but given the size of the PR I suppose I could mostly do nitpicks, etc rather than anything thorough and trust that this works as it suppose to work).

@keflavich keflavich dismissed their stale review November 8, 2018 16:48

Re-reviewing

astroquery/gaia/core.py Outdated Show resolved Hide resolved
@bsipocz
Copy link
Member

bsipocz commented Nov 8, 2018

Actually I would like to ping @smoh to ask whether she is interested doing a review, I suppose she has most of the insights of this module besides the authors of it.

@smoh
Copy link
Contributor

smoh commented Nov 9, 2018

On the last master merge commit: Isn't it a bad idea to merge master into this pull request branch and introduce irrelevant changes from MAST/TESS stuff?

@keflavich
Copy link
Contributor

@smoh Merging master won't pull in any irrelevant changes because the diff against master is still zero. There is preference in astropy to rebase rather than merge PRs, but it's not a very big deal.

>>> full_qualified_table_name = 'user_<your_login_name>.table_test_from_url'
>>> query = 'select * from ' + full_qualified_table_name
>>> job = Gaia.launch_job(query=query)
>>> results = job.get_resultsjob)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
>>> results = job.get_resultsjob)
>>> results = job.get_results(job)

typo: missing (

Copy link
Contributor

@smoh smoh Nov 9, 2018

Choose a reason for hiding this comment

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

I think there are 9 other same typos ;-).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. This must be fixed.

@bsipocz
Copy link
Member

bsipocz commented Nov 9, 2018

On the last master merge commit: Isn't it a bad idea to merge master into this pull request branch and introduce irrelevant changes from MAST/TESS stuff?

You're right, in case of conflicting changes it can definitely can mess up the diff. Right now it's not the case as the TESS changes happened on totally disjunct part of the package.
But definitely would like to see rebases rather than merges for branch clarity, also maybe some squashing, but latter is not that crucial.

Copy link
Contributor

@smoh smoh left a comment

Choose a reason for hiding this comment

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

Hi @jcsegovia ,

I've only looked at (part of) tap/core.py and some related modules.
General changes I would suggest are:

  • Remove unnecessary __internal_init.
  • Reduce __attribute only to occasions actually needed. Make most attributes plain (public) and use _attribute for things not intended to be exposed.
  • Normalize methods in camelCases to underscore_names (I think this was mentioned in the original Tap pull request but quite a bit still left).

Other things I found (not part of code added in this PR):

  • __parseUrl is a utility method with no reference to self.
  • Similarly TapConn.url_encode simply runs urlencode imported from astropy.extern.six.moves.urllib.parse.

I find it too messy and overwhelming to mark comments on all individual places on Github and I suppose it will be same to the authors, too. If the authors are open to it, I will make a pull request to their fork or just let authors make the changes.

If the maintainers or authors would rather let this out first, I wouldn't want to hold back.

datalink_context=datalink_context,
port=port,
sslport=sslport)
self.__connHandler = tap
# if connectionHandler is set, use it (useful for testing)
Copy link
Contributor

Choose a reason for hiding this comment

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

  • This should be checked first since if connhandler is set there's no need to check other keywords and initialize another TapConn.
  • Although I imagine no user is actually going to mess around much with this initialization, there is no consistency check between parameters that may be obtained from url and parameters that can be given directly as keywords nor a requirement for them to be mutually exclusive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. If connHandler is set, no need to create connections.
About arguments consistency, again, you are right. I did not include these checks because the code would grow with multiple if's and, as you have said, this is a quite internal initialization.

@@ -67,34 +91,54 @@ def __init__(self, url=None, host=None, server_context=None,
"""
self.__internalInit()
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove __internalInit and do initialization directly here.

datalink_context=datalink_context,
port=port,
sslport=sslport)
self.__connHandler = tap
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest make connHandler public and make it not camelCase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fine. Thanks.

tsp.parseData(response)
print("Done.")
return tsp.get_table()

def __load_tables(self, only_names=False, include_shared_tables=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Move this method to TapPlus.load_tables. The more complicated method which can handle additional TAP+ keywords is implemented here in the simpler classTap. It seems very unnatural to implement a more complex function in the simpler class, not use it within that class and call it from subclass that extends this class (TapPlus) as _Tap__load_tables (https://github.com/astropy/astroquery/pull/1266/files#diff-59b6077f0dc145f56a2320f3b5b83e6eR813). This is the opposite of the intended usage of __attribute which is converted to _Class__attribute to ensure __attribute is that set within that Class not the base class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. __load_tables should be move to TapPlus. Thanks.

@bsipocz
Copy link
Member

bsipocz commented Nov 10, 2018

Thanks you @smoh.

If the maintainers or authors would rather let this out first, I wouldn't want to hold back.

I would prefer to have the cleanup rather than merge this as is.

@jcsegovia - let us know otherwise, e.g. if you have a pressing deadline by this has to be deployed.

@smoh
Copy link
Contributor

smoh commented Nov 11, 2018

A couple of more thoughts from tap/core.py:Tap:

  • Similar to Tap.__parseUrl, Tap.__appendData has no reference to self and has no external usage so the code can just be directly where it is call (only) once in __launchJobMultipart. As an aside, the goal of this code is to build "key1=value1&key2=value2&..." string. Have the authors considered using package like requests which is already a requirement for astroquery and would make these sort of things unnecessary?

  • I suggest to reduce the print statements and use logging for debugging. Many print statements (usually activated with verbose=) are seemingly written for debugging and may not be user-oriented. With logging it's easy to set the desired verbosity for the entire script or just one code block. Currently there are more than 3x print calls in utils/tap than other modules combined.

❯ grep "[^>]\sprint(" astroquery -r | grep 'utils/tap' | wc -l
     182
❯ grep "[^>]\sprint(" astroquery -r | grep -v 'utils/tap' | wc -l
      54

@jcsegovia
Copy link
Contributor Author

@bsipocz about deadline: no we do not have a deadline. We can work on this changes before merging this PR.

@jcsegovia
Copy link
Contributor Author

@smoh thanks for your comments. Please, feel free to modify the code if you want. Probably, we are not going to modify the code until next Thursday. About requests, I did not know it was a requirement for astroquery: I did not test it and I am not sure whether we are going to find any problem or not (we use cookies and multipart forms in several places, we need to check that it works with requests).

@keflavich
Copy link
Contributor

@jcsegovia requests is a great package, and astroquery would be a total mess without it. It handles all of the heavy lifting for remote queries, including cookies and multipart form data.

astroquery wraps request in the BaseQuery class, where we've added a layer that caches the returned content from the remote service. You can choose whether or not to use that layer; it is sometimes very helpful, e.g., when you expect the same query to always return the same data, but should not be activated when the returns are dynamic and changing.

...we probably need more developer-directed documentation on these base classes...

@keflavich keflavich merged commit fbf335b into astropy:master May 17, 2019
@bsipocz
Copy link
Member

bsipocz commented May 17, 2019

I plan to open a follow-up PR that resurrects some of the cleanup from esdc-esac-esa-int#1, hopefully in the next couple of days, but feel free to open your own follow-ups as needed.

@jcsegovia jcsegovia deleted the tap_1_2 branch April 2, 2020 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants