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

Gaia astroquery 1.1 #2376

Merged
merged 9 commits into from
Jun 13, 2022
Merged

Conversation

mhsarmiento
Copy link
Contributor

Dear Astroquery Team,
This pull request contains a new feature in the Gaia module and an update in the default value of one of the parameters of the method 'load_data'

  • Now the users of the Astroquery/Gaia module will know if there is a planned downtime of the Archive or if there is any issue on-going on the Gaia archive.
  • For the method 'load_data' it has been updated the default value of the parameter 'valid_data' to 'False'. With this change the epoch photometry service will returns all data associated to a given source. This change also mimics the behaviours of the current UI of the archive.

Thank you in advance,
all the best,
Maria

mhsarmientoc pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request Apr 25, 2022
mhsarmientoc pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request Apr 25, 2022
@codecov
Copy link

codecov bot commented Apr 25, 2022

Codecov Report

Merging #2376 (fc8d45b) into main (9526b6f) will increase coverage by 0.00%.
The diff coverage is 66.66%.

@@           Coverage Diff           @@
##             main    #2376   +/-   ##
=======================================
  Coverage   62.92%   62.92%           
=======================================
  Files         133      133           
  Lines       17269    17289   +20     
=======================================
+ Hits        10866    10879   +13     
- Misses       6403     6410    +7     
Impacted Files Coverage Δ
astroquery/gaia/core.py 71.47% <66.66%> (-0.47%) ⬇️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@bsipocz bsipocz added the gaia label Apr 25, 2022
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

There are some commit duplications and merge commits, please rebase and maybe squash them down a bit, too.

@@ -911,5 +915,20 @@ def launch_job_async(self, query, name=None, output_file=None,
upload_table_name=upload_table_name,
autorun=autorun)

def get_status_messages(self):
"""Retrieve the messages to inform users about
the status of JWST TAP
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
the status of JWST TAP
the status of Gaia TAP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Thank you

@@ -74,6 +74,10 @@ def __init__(self, tap_plus_conn_handler=None,
else:
self.__gaiadata = datalink_handler

# Enable notifications
if show_messages:
Copy link
Member

Choose a reason for hiding this comment

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

Please add a test with show_messages=True case that parses a dummy response with a message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test added with show_message=True

@@ -51,7 +51,7 @@ def __init__(self, tap_plus_conn_handler=None,
gaia_data_server='https://gea.esac.esa.int/',
tap_server_context="tap-server",
data_server_context="data-server",
verbose=False):
verbose=False, show_messages=True):
Copy link
Member

Choose a reason for hiding this comment

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

Somewhat tangential to this PR, but it would be great if all these __init__ parameters had a short docstring. And you could also consider making them keyword only arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your comment. I have brought your question to the team for internal discussion. We will came back to you soon.

Copy link
Member

Choose a reason for hiding this comment

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

I recommend you replace show_messages with something more descriptive so that it would be more obvious how it differs from verbose.

CHANGES.rst Outdated
casda
^^^^^

- Add the ability to produce 2D and 3D cutouts from ASKAP images and cubes. [#2366]
Copy link
Member

Choose a reason for hiding this comment

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

This should not be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Restored! Thanks

Copy link
Member

Choose a reason for hiding this comment

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

The statement about not removing change log entries applies to all of them, not just this one entry individually.

Copy link
Member

Choose a reason for hiding this comment

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

@eerovaher - This is a rebase issue, I can fix it when the PR otherwise ready to be merged rather than nitpick on the need of multiple round of rebases.

@@ -39,6 +39,8 @@ class Conf(_config.ConfigNamespace):
'MCMC_GSPPHOT',
'MCMC_MSC']

GAIA_MESSAGES = _config.ConfigItem("notification?action=GetNotifications", "Gaia Messages")
Copy link
Member

Choose a reason for hiding this comment

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

What are the other possibilities for this configitem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry. Not sure if I have understood your question. This is the way we use to add a modifier to the request.

Copy link
Member

Choose a reason for hiding this comment

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

If this configuration item can only take one value then it is not configurable and should not be managed by the configuration system. So if you have implemented this as a configuration item then there must be more values it can take, but they are not documented anywhere.

Copy link
Member

Choose a reason for hiding this comment

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

This has to be deleted now

string_message = line.decode("utf-8")
print(string_message[string_message.index('=') + 1:])
except OSError as e:
print("Status messages could not be retrieved")
Copy link
Member

Choose a reason for hiding this comment

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

Why the try/except, why not raise this as an exception instead? Is it expected to be unstable?

Also, no need for catching the exception (as e) if you don't use it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated. Thank you!

Comment on lines 928 to 929
string_message = line.decode("utf-8")
print(string_message[string_message.index('=') + 1:])
Copy link
Member

Choose a reason for hiding this comment

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

Equivalent, but shorter and clearer code:

Suggested change
string_message = line.decode("utf-8")
print(string_message[string_message.index('=') + 1:])
print(line.decode("utf-8").split('=', 1)[1])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for your inputs. Updated!

mhsarmiento added a commit to esdc-esac-esa-int/astroquery that referenced this pull request May 24, 2022
mhsarmiento added a commit to esdc-esac-esa-int/astroquery that referenced this pull request May 24, 2022
mhsarmiento added a commit to esdc-esac-esa-int/astroquery that referenced this pull request May 24, 2022
mhsarmiento added a commit to esdc-esac-esa-int/astroquery that referenced this pull request May 24, 2022
@bsipocz
Copy link
Member

bsipocz commented May 24, 2022

A rebase went wrong here. Make sure you rebase on astropy/main instead of the main of your fork or esdc's fork.

@pep8speaks
Copy link

pep8speaks commented May 24, 2022

Hello @mhsarmiento! 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 2022-06-13 15:46:49 UTC

@bsipocz
Copy link
Member

bsipocz commented May 24, 2022

A rebase went wrong here. Make sure you rebase on astropy/main instead of the main of your fork or esdc's fork.

OK, so I correct this to:

A rebase went wrong here. Make sure you rebase on the freshly fetched astropy/main instead of the main of your fork or esdc's fork.

except ValueError as e:
print(e)
pass
except OSError:
Copy link
Member

Choose a reason for hiding this comment

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

It is best to use the most specific error type possible. In this case it looks like ConnectionError or perhaps even one of its subclasses would be more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have opened a internal ticket to review your proposal

@@ -14,6 +14,7 @@


"""
import unittest
Copy link
Member

Choose a reason for hiding this comment

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

The use of unittest was just removed by 6ec71ce, it should not be reintroduced without a very good reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@eerovaher
Copy link
Member

This pull request makes unannounced and unrelated changes to the XMM-Newton sub-package. It would be better to open a separate pull request for those.

@bsipocz
Copy link
Member

bsipocz commented May 25, 2022

This pull request makes unannounced and unrelated changes to the XMM-Newton sub-package. It would be better to open a separate pull request for those.

Ideally these should indeed be separate PRs, but at this point I don't think we should separate them and manage two parallel PRs. The changelog will need a fixing anyway, but that can be done as a last step.

As for the review, I'll try to get back to it this week or the next.

@jespinosaar
Copy link
Contributor

I have rebased again and removed the unnecessary commits, @mhsarmiento you can now proceed with the required changes.

cc @esdc-esac-esa-int

mhsarmientoc pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request May 31, 2022
@mhsarmiento
Copy link
Contributor Author

I have rebased again and removed the unnecessary commits, @mhsarmiento you can now proceed with the required changes.

cc @esdc-esac-esa-int

done! thanks a lot for your reviewing the rebase and the xmm changes @jespinosaar

@mhsarmiento
Copy link
Contributor Author

Thanks @bsipocz and @eerovaher for your support to the Gaia module in Astroquery. Your comments are very helpful and will be also applied to other ESA projects in Astrouquery. Those projects already pushed the same code to Astroquery to show the TAP notifications to the users (for example at esa/jwst module).

@bsipocz
Copy link
Member

bsipocz commented May 31, 2022

I did some investigating to see what went wrong with the previous rebases and concluded that it was rebased on esdc-esac-esa-int/main instead of astropy/main.
The issue is that the esdc-esac-esa-int/main is not tracking the canonical copy, but frozen in time to the point when the fork was created. So whenever you rebased on that branch, it will pull in a lot of extra commits and causing a conflicting nightmare.

My assumption is because of the confusing nature of calling the personal fork and these origin/upstream. I think that this git default naming is unfortunate and not is not fit for purpose for any workflow that deals with multiple accounts and is therefore a cause of great pain.

So to fix the workflow my suggestion is to rename all the remotes you work with to reflect the user/organization name on github. That way it's always clear which versions you are using as e.g. the base of a rebase. The workflow for a rebase, in that case, would be:

# check that all the remotes are set
$ git remote -v

astropy	git@github.com:astropy/astroquery.git (fetch)
astropy	git@github.com:astropy/astroquery.git (push)
esdc-esac-esa-int	git@github.com:esdc-esac-esa-int/astroquery (fetch)
esdc-esac-esa-int	git@github.com:esdc-esac-esa-int/astroquery (push)

# check that you're on the correct feature branch
$ git branch --show-current

gaia-astroquery-1.1

# Update all remotes. If you list all the branches, this command will update what's in `remotes/<username>/<branchname>`

$ git fetch --all  

Fetching astropy
Fetching esdc-esac-esa-int

$ # Optionally remove all outdated branches as well with the following. (also, strictly speaking --all is not mandatory, but I think it's good practice)
$ # git fetch --all --prune

# Do the rebase, it pops up the editor, select commits for squash/removal/move around. Fix conflicts and keep doing `git rebase --continue` until done.
$ git -rebase -i astropy/main

# when done, force push it to esdc... You don't need to be, but I think it's a good practice to be specific.
$ git push esdc-esac-esa-int HEAD:<name_of_branch> --force

Hope it helps.

(of course, the other approach is what you did, is to stash all commits done to one, but that also removes all granularity in the PR that may be useful later when one tries to trace the origin of a bug (which can be a bit problematic for very large PRs))

bsipocz pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request May 31, 2022
bsipocz pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request May 31, 2022
@bsipocz
Copy link
Member

bsipocz commented Jun 1, 2022

We already have the remotes with different names and a well-defined procedure documented, so maybe this has been just a small slip.

no worries, this takes time and practice for everyone, I feel the workflow got much easier already (at least on the reviewer end), so thank you!

the status of Gaia TAP
"""
try:
print("parsing notification messages")
Copy link
Member

Choose a reason for hiding this comment

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

I know that many users don't like default verbosity. OTOH from the archive's side, I understand why these messages are desirable.
So maybe a middle ground here to add another sentence to say how to turn it off?

Also, add a short paragraph about it in the narrative docs, users should know how to turn this off.

Copy link
Contributor

Choose a reason for hiding this comment

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

This call to our TAP will tell the user if the TAP is under maintenance or it is not working, so they know if what they will do will be working in advance. But it is ok, we can add in the documentation how to turn it off. @mhsarmiento, could you please add this in the documentation of the python file and the .rst file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know that many users don't like default verbosity. OTOH from the archive's side, I understand why these messages are desirable. So maybe a middle ground here to add another sentence to say how to turn it off?

Also, add a short paragraph about it in the narrative docs, users should know how to turn this off.

Hi @bsipocz , yes, the same code to show messages from the tap sever (before implementing the changes proposed in this PR) , can be found at esa/jwst/core.py line 681. In fact, the code implemented in Gaia was based on that. This is the reason because I was saying that your comments are really useful. We can use your comments to correct also this method under esa/jwst/core.py but in another PR

@bsipocz
Copy link
Member

bsipocz commented Jun 1, 2022

The documentation needs to be updated, because the current code examples do not expect any notifications from the server, and I would rename the new show_messages argument to something like show_server_notifications so that it would be clear how it differs from the already existing verbose argument.

@mhsarmiento , why not 'show_tap_notifications'?

I don't think we have a precedent yet, in other modules (maybe @keflavich you can recall something). Do we know of any other servers where this would be useful? But I would suggest using something that can be reused generally for the other, non-tap modules, too. I don't really have a strong preference, beyond the potential reusability of the name for other modules. What about show_server_messages?

@jespinosaar
Copy link
Contributor

It is ok from our side.

bsipocz pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request Jun 2, 2022
bsipocz pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request Jun 2, 2022
Comment on lines 934 to 939
except ValueError as e:
print(e)
pass
except IndexError as e:
print("Archive down for maintenance")
pass
Copy link
Member

Choose a reason for hiding this comment

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

pass is a null operation which is meant for situations where the Python syntax requires an indented code block, but no code should be executed. There is no need to use pass here because the print() calls form the indented code blocks that Python expects. Furthermore, in the case of an IndexError, e would be an unused variable.

Suggested change
except ValueError as e:
print(e)
pass
except IndexError as e:
print("Archive down for maintenance")
pass
except ValueError as e:
print(e)
except IndexError:
print("Archive down for maintenance")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Implemented. Thanks for the tip

mhsarmientoc pushed a commit to esdc-esac-esa-int/astroquery that referenced this pull request Jun 7, 2022
…/gaia/core.py, method 'def get_status_messages'
@mhsarmiento
Copy link
Contributor Author

The only remaining item is the GAIA_MESSAGES conf item. Is there any situation where a user is expected to interact with it? If not, then hardwire it in core.py rather than as a confitem.

Thanks @bsipocz!. GAIA_MESSAGES has been removed as conf item and hardwired at 'core.py'. If in the future there is a situation in which the user can interact with that we will put it back as conf item but for now there isn't any plan for that.
Thanks again for your help.

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

One more comment, otherwise I think this is good to go. (The archive is now down, so I see test failures with the docs, but that is unrelated to this PR, so address any actual issues that may come up separately when DR3 is out.)

@@ -39,6 +39,8 @@ class Conf(_config.ConfigNamespace):
'MCMC_GSPPHOT',
'MCMC_MSC']

GAIA_MESSAGES = _config.ConfigItem("notification?action=GetNotifications", "Gaia Messages")
Copy link
Member

Choose a reason for hiding this comment

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

This has to be deleted now

@bsipocz
Copy link
Member

bsipocz commented Jun 13, 2022

I'm cleaning up the duplicate merges etc, and will do the init cleanups and merge this.

…ations service to notify users of service availability problems
…etrieval_Type = "ALL" VS. Retrieval_type = "Epoch Photometry"
…/gaia/core.py, method 'def get_status_messages'
Renamed "show_messages" by "show_server_messages"
Corrected test case as it was not contemplating the user case in which Gaia archive is down for maintenance.
@mhsarmiento
Copy link
Contributor Author

One more comment, otherwise I think this is good to go. (The archive is now down, so I see test failures with the docs, but that is unrelated to this PR, so address any actual issues that may come up separately when DR3 is out.)

Thanks! I think that I forgot to commit this file. sorry for that.

Yes, today at 12h CEST DR3 will be out! Very exciting times! :-)

@bsipocz bsipocz merged commit cbe6d20 into astropy:main Jun 13, 2022
@bsipocz
Copy link
Member

bsipocz commented Jun 13, 2022

Thank you @mhsarmiento!

@jespinosaar
Copy link
Contributor

Many thanks @bsipocz and @mhsarmiento !

@mhsarmiento mhsarmiento deleted the gaia-astroquery-1.1 branch June 14, 2022 13:29
@bsipocz
Copy link
Member

bsipocz commented Jun 14, 2022

@mhsarmiento @jespinosaar - should we change the default from DR2 to DR3 or it's too early?
(I expect a swarm of issues coming in about it, at least that happened between DR1 and DR2)

@mhsarmiento
Copy link
Contributor Author

@mhsarmiento @jespinosaar - should we change the default from DR2 to DR3 or it's too early? (I expect a swarm of issues coming in about it, at least that happened between DR1 and DR2)

Hi! Yes, it should be changed from DR2 to DR3 as we have done the same the UI of GACS. Thanks for spotting this out

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

Successfully merging this pull request may close these issues.

None yet

5 participants