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

Add gaiatap module in order to access to the European Space Agency Gaia Archive #836

Merged
merged 89 commits into from Mar 14, 2017

Conversation

jcsegovia
Copy link
Contributor

I am Juan-Carlos Segovia, a software engineer working for the European Space Agency.
(You can contact me at: juan.carlos.segovia@sciops.esa.int or juancarlos.segovia@gmail.com)

The ESAC Space Data Centre (ESDC) has developed a module to access the European Space Agency Gaia Archive.

We would like to add this module to astroquery library.

Gaia Archive access is based on a TAP+ REST service.

TAP+ is an extension of Table Access Protocol (TAP: http://www.ivoa.net/documents/TAP/) specified by the International Virtual Observatory Alliance (IVOA: http://www.ivoa.net).

The gaiatap module allows the access to the archive using astroquery API (query_object), and also, provides some TAP+ capabilities.

Please, will you be so kind to review and check gaiatap module?

Thank you very much.

Best regards,

Juan-Carlos Segovia Serrato

ESAC Science Data Centre
Science Archives and Computer Engineering Unit
Operations Department, Directorate of Science
European Space Astronomy Centre (ESAC)
European Space Agency (ESA)

email: juan.carlos.segovia@sciops.esa.int
Phone: (34)-91-8131-175 - 70175 internal
Fax: (34)-91-8131-308

European Space Astronomy Centre (ESAC)
Camino Bajo del Castillo s/n
Urb. Villafranca del Castillo
28692 Villanueva de la Cañada, Madrid, Spain.

@bsipocz
Copy link
Member

bsipocz commented Jan 27, 2017

Thanks you @jcsegovia for this awesome contribution. We'll try to review it in details soon.

@bsipocz
Copy link
Member

bsipocz commented Jan 27, 2017

I'm pinging @eteq and @andycasey as participants of previous discussions about Gaia TAP.

@jcsegovia jcsegovia closed this Jan 27, 2017
@jcsegovia jcsegovia reopened this Jan 27, 2017
@bsipocz
Copy link
Member

bsipocz commented Jan 27, 2017

A few quick, mainly stylistic comments I have to start with.

I think the example directories are superfluous at their current place. However a narrative documentation is missing. Could you rework it under docs/gaiatap with a little bit more narrative text? One good examples is e.g. the docs/esasky/esasky.rst.

We follow the naming conventions of functions and methods are lower case (in the tests, too) while classes are CamelCase.

We have our testing suite set up with py.test. While unittest is compatible with it, I see issues when using python 3.6. It's basically only the esasky module that use unittest and as a workaround for the py3.6 issue, I'm planning to refactor it to be pure pytest. If it's not too controversial, would it be possible to rework the tests here, too to be pure pytest?

@bsipocz
Copy link
Member

bsipocz commented Jan 27, 2017

Oh, and I think it would make sense to rename the module to gaia. Any tap functionality then can be factored out either into gaia.utils, or to a more generic astroquery.utils.tap location, so other modules could possibly use them. (However that all that refactoring be part of a future PR).

@bsipocz bsipocz added the gaia label Jan 27, 2017
@jcsegovia
Copy link
Contributor Author

jcsegovia commented Jan 27, 2017

Thanks.

Currently, we have created gaiatap/gaiatap.rst with the explanations. I think it should be moved to docs/gaia/gaia.rst

Changes:

  • rename gaiatap to gaia
  • create docs/gaia/gaia.rst (move current gaiatap/gaiatap.rst to docs/gaia/gaia.rst)
  • follow python naming convention for tests
  • unittest -> pytest

Question: shall we change 'private' method names also?

About TAP: fine with us to move to a more generic place.

@jcsegovia
Copy link
Contributor Author

Sorry, I forgot unittest:

OK, we can remove unittest, but it will take a bit of time because we are using some mocking capabilities.

@bsipocz
Copy link
Member

bsipocz commented Jan 27, 2017

@jcsegovia - Thanks, it sounds good. Before you do much work on it, it may be worth waiting for comments from @keflavich, he may have a few generic points too that I missed.

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.

A few minor comments.

return self.__gaiatap.query_object_async(coordinate, radius=radius, width=width, height=height, verbose=verbose)

def query_region(self, coordinate, radius=None, width=None):
print ("Not available")
Copy link
Contributor

Choose a reason for hiding this comment

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

For these 'not available' methods, could you just leave them commented out for now? I wouldn't want users tricked into thinking that method is available when it's not yet.

Also, we prefer to raise NotImplementedError() rather than print a statement like this

-------
A Job object
"""
return self.__gaiatap.launch_async_job(query, name=name, output_file=output_file, output_format=output_format, verbose=verbose, dump_to_file=dump_to_file, background=background, upload_resource=upload_resource, upload_table_name=upload_table_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor style issue: could you make sure these long lines are wrapped at 80 characters, or at least close to 80?

if jobs is None:
print ("No jobs")
else:
for j in jobs:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you just print(jobs) here? Or is the formatting ugly in this case?

#python 2
from urllib import urlencode as urlEncode

class DummyConnHandler:
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 probably be class DummyConnHandler(object):

"""
import os

def get_pakcage_data():
Copy link
Contributor

Choose a reason for hiding this comment

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

pakcage->package

assert r.getMethod() == 'POST', "Request method. Expected %s, found %s" % ('POST', r.getMethod())
assert r.getContext() == context, "Request context. Expected %s, found %s" % (context, r.getContext())
assert r.getBody() == data, "Request body. Expected %s, found %s" % (data, str(r.getBody()))
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

a pass statement here and in other surrounding functions is unnecessary

---------------------------

Authenticated users are able to access to TAP+ capabilities (shared tables, persistent jobs, etc.)
In order to authenticate a user, ``login`` or ``login_gui`` methods must be called. After a successful
Copy link
Contributor

Choose a reason for hiding this comment

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

You should include a note here that Tkinter is required for the login gui

@keflavich
Copy link
Contributor

@jcsegovia Thanks for this contribution, it is awesome! I've left a handful of minor comments above.

@bsipocz's comments were spot on - we would certainly prefer to stick with an all-pytest framework if that is possible. In particular, I couldn't quite tell from skimming the code - do any of your tests require a remote connection? If so, we need to disable those by default and only enable them when the --remote-data flag is set.

I won't be able to do a complete review of this module, as it is huge and has a lot of capabilities I don't fully understand. But, I'm happy to have it!

@keflavich
Copy link
Contributor

@jcsegovia I edited your comment above to have a checklist for the items to be changed.

@jcsegovia
Copy link
Contributor Author

@bsipocz, @keflavich: thank you very much for your inputs.

About remote connection for tests: no we do not need it. Out tests are run in a isolated (mocked) environment.

We are working on the implementation of these changes...

Thanks again!

@jcsegovia
Copy link
Contributor Author

@bsipocz , @keflavich where do you want me to put tap.rst? Currently, it is under astroquery/docs/tap/tap.rst (I haven't seen an astroquery/docs/utils section...)

Also, in which index.rst section shall I put tap?
Shall I modify utils.rst in some way...?

@keflavich
Copy link
Contributor

Good questions. I think docs/tap/tap.rst is fine for now. Add a link to it in utils.rst as well as on the main index. Filling out utils.rst is a big to-do item.

@bsipocz
Copy link
Member

bsipocz commented Mar 13, 2017

@jcsegovia - Probably the index page could use a bit of reorganizing, until that happens tap could go under "Other" I think: http://astroquery.readthedocs.io/en/latest/#other

@bsipocz
Copy link
Member

bsipocz commented Mar 13, 2017

Also I've just noticed that all the svn files are getting included.
However we can remove them once this is merged and make sure they will never get back (doesn't matter whether you do it in this PR or we do separately as they are already in the history (as unless there is a large rebase/squash operation done which could be messy at this time, so I don't recommend it)).

@jcsegovia
Copy link
Contributor Author

@bsipocz .svn entries: my fault (sorry). They are removed.

@bsipocz
Copy link
Member

bsipocz commented Mar 14, 2017

@jcsegovia - I've pushed directly to this branch a few tweaks to the organization of the docs pages to make sure the tests pass. Once CI is all green, I'll merge.

@bsipocz bsipocz merged commit 8dc7547 into astropy:master Mar 14, 2017
@bsipocz
Copy link
Member

bsipocz commented Mar 14, 2017

Thank you @jcsegovia again for this contribution!

@bsipocz bsipocz added this to the 0.3.5 milestone Mar 14, 2017
@jcsegovia
Copy link
Contributor Author

@bsipocz , @keflavich thank you for your help and support.

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.

None yet

3 participants