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

Db monitor #52

Merged
merged 39 commits into from
May 31, 2018
Merged

Db monitor #52

merged 39 commits into from
May 31, 2018

Conversation

hover2pi
Copy link
Collaborator

@hover2pi hover2pi commented Apr 2, 2018

Wrote database monitor to count files in MAST #48

@hover2pi hover2pi requested a review from bourque April 2, 2018 16:59
@bourque
Copy link
Collaborator

bourque commented Apr 11, 2018

Sorry for the delay @hover2pi, I'll look at this tomorrow or Friday

Copy link
Collaborator

@bourque bourque left a comment

Choose a reason for hiding this comment

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

Thanks @hover2pi, very nicely written. I have a few questions and requests, but the code is shaping up nicely.

>>> inventory, keywords = dbmonitor.jwst_inventory()

"""
import sys
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hover2pi Please order imports based on the PEP 8 suggestion of three groups (and in alphabetical order)

Imports should be grouped in the following order:

1. standard library imports
2. related third party imports
3. local application/library specific imports

You should put a blank line between each group of imports.

from astroquery.mast import Mast
import astropy.table as at

JWST_INSTRUMENTS = ['NIRISS', 'NIRCam', 'NIRSpec', 'MIRI', 'FGS']
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hover2pi It would probably be a good idea to stick global lists like these in the utils.py module and import them. Then they could easily be used by other modules. Could you put those in there?

'EVENTLIST', 'CUBE', 'CATALOG', 'ENGINEERING', 'NULL']


def listMissions():
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hover2pi Per our style guide, could you order the function definitions in alphabetical order?

return_data: bool
Return the actual data instead of counts only

Returns
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hover2pi You might want to add a note here that all results are returned if return_data is True

{'paramName': 'dataproduct_type', 'values': dataproduct}]

# Include additonal filters
for k, v in add_filters.items():
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hover2pi PEP 8 discourages single letter variable names, but this naming convention seems like somewhat of a standard amongst the python community, so I'll allow it! I'm only mentioning this because I have given @bhilbert4 grief about this before and I want to play fair ;)

return request


def mastQuery(request):
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hover2pi Could you instead use the MAST API directly, instead of having to establish connections and sending POSTs? i.e.:

response = astroquery.mast.Mast.service_request_async('Mast.Caom.Filtered', params)
result = resonse[0].json()

Similar to how we are querying MAST in this notebook. It seems simpler to me.

count = instrument_inventory(instruments, dataproduct=dataproducts)
inventory.add_row(['*', '*', count])

# Retrieve one dataset to get header keywords
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hover2pi It will be nice to have an understanding of these keywords that come out of the Mast.Caom.Filtered service, but I would also like to be tracking the number of keywords that come out of the instrument specific services (e.g. Mast.Jwst.Filtered.Niriss). Could that be added?

@hover2pi hover2pi dismissed bourque’s stale review May 2, 2018 16:13

All changes were made

@hover2pi
Copy link
Collaborator Author

hover2pi commented May 2, 2018

Ok @bourque , this should be ready to go. I'm going to add the plots in the Web app in a separate branch.

@hover2pi
Copy link
Collaborator Author

@bourque I fixed some docstrings, modified the queries to accept filters (just in case), and broke out the keyword queries into their own functions so feeding it to the Web app is easier.

@bourque
Copy link
Collaborator

bourque commented May 14, 2018

Thanks @hover2pi, I'm going to try to review this today or tomorrow.

Copy link
Collaborator

@bourque bourque left a comment

Choose a reason for hiding this comment

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

@hover2pi This looks and works great, and exactly what I had in mind.

My only comment is that it seems the jwst_inventory and jwst_inventory_caom functions are mostly the same and do not follow the DRY principle (Don't Repeat Yourself) very well. I wonder if it would be better to add a parameter called service and use conditions to distingish the calls to the instrument_inventory functions, i.e.

def jwst_inventory(service, instruments=JWST_INSTRUMENTS, dataproducts=['image', 'spectrum', 'cube'],
plot=False):

...

if service == 'filtered':
    count = instrument_inventory(instrument, dataproduct=dp)
elif service == 'caom':
    count = instrument_inventory_caom(instrument, dataproduct=dp)

...

if service == 'filtered':
    keywords[instrument] = instrument_keywords(instrument)
elif service == 'caom':
    keywords[instrument] = instrument_keywords(instrument)

...

What do you think?


JWST_INSTRUMENTS = ['NIRISS', 'NIRCam', 'NIRSpec', 'MIRI', 'FGS']
Copy link
Collaborator

Choose a reason for hiding this comment

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

@hover2pi Oops, somehow this got defined twice. Could you remove this?

@hover2pi
Copy link
Collaborator Author

@bourque I combined the CAOM and filtered queries and removed that weird duplicate global variable definition. Should be good to go.

Copy link
Collaborator

@bourque bourque left a comment

Choose a reason for hiding this comment

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

Im not actually approving this now, just trying something out

@bourque
Copy link
Collaborator

bourque commented May 30, 2018

@hover2pi Random question that may or may not have to do with our rebase vs pull discussion: which text editor do you use to develop?

@bourque
Copy link
Collaborator

bourque commented May 31, 2018

@hover2pi This is good to go! Great work. I made a few additional commits to this, namely to save the plots to the jwql central storage area instead of just showing them, and some minor API doc formatting stuff.

Also, I had to switch to using bokeh.charts with bokeh v0.12.5 instead of bkcharts v0.2 in order to get this to work and the tests to pass. I wasn't able to get this to work with the latest version of bkcharts and the latest version of bokeh -- which versions were you using?

Anyways, this is a good working version, so I am going to merge it. I can already think of a few ways to improve these charts, but we can deal with that in a separate PR.

@bourque bourque merged commit 88beea3 into spacetelescope:master May 31, 2018
@bourque bourque deleted the db_monitor branch May 31, 2018 15:47
This was referenced May 31, 2018
bourque added a commit to bourque/jwql that referenced this pull request Apr 2, 2019
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