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

Change report target_summary method to return dict or None #312

Merged
merged 7 commits into from
Dec 30, 2024

Conversation

jeanconn
Copy link
Contributor

@jeanconn jeanconn commented Dec 10, 2024

Description

Change report target_summary method to return unmasked dict or None

Fixes an issue that downstream code in the reporting was expecting either None or values None, not masked values. This PR is a residual fix from the transition to using Sqsh for the database information. It is a separate question if Sqsh.fetch_one should really return a dictionary with possible None values instead of an astropy table Row with masked values.

Interface impacts

This changes the interface of mica.report.report.target_summary method, which looks to only be used internally.

Testing

Unit tests

  • Linux
 jeanconn-fido> git rev-parse HEAD
b50a7bb8218db72b2d06151446065c932cebaf89
 jeanconn-fido> pytest
=============================================================== test session starts ================================================================
platform linux -- Python 3.11.8, pytest-8.0.2, pluggy-1.4.0
rootdir: /proj/sot/ska/jeanproj/git
configfile: pytest.ini
plugins: timeout-2.2.0, anyio-4.3.0
collected 112 items                                                                                                                                

mica/archive/tests/test_aca_dark_cal.py ..................                                                                                   [ 16%]
mica/archive/tests/test_aca_hdr3.py .                                                                                                        [ 16%]
mica/archive/tests/test_aca_l0.py .....                                                                                                      [ 21%]
mica/archive/tests/test_asp_l1.py .......                                                                                                    [ 27%]
mica/archive/tests/test_cda.py ..............................................                                                                [ 68%]
mica/archive/tests/test_obspar.py .                                                                                                          [ 69%]
mica/report/tests/test_report.py ..                                                                                                          [ 71%]
mica/report/tests/test_write_report.py .                                                                                                     [ 72%]
mica/starcheck/tests/test_catalog_fetches.py ...............                                                                                 [ 85%]
mica/stats/tests/test_acq_stats.py ...                                                                                                       [ 88%]
mica/stats/tests/test_guide_stats.py ....                                                                                                    [ 91%]
mica/vv/tests/test_vv.py .........                                                                                                           [100%]

========================================================= 112 passed in 544.27s (0:09:04

Independent check of unit tests by [REVIEWER NAME]

  • [PLATFORM]:

Functional tests

Two new trivial unit tests have been added.

"Live" functional testing on the obsids that showed the problem - master

In [1]: import mica.report.report

In [2]: mica.report.report.main(30270)
Making report for 30270
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 1
----> 1 mica.report.report.main(30270)

File /proj/sot/ska/jeanproj/git/mica/mica/report/report.py:571, in main(obsid)
    569         raise ValueError("Obsid not found in target table")
    570     report_status["ocat"] = summary["status"]
--> 571     links = obs_links(obsid, summary["seq_nbr"], summary["lts_lt_plan"])
    573 if not er and (summary["status"] in ["canceled", "unobserved", "untriggered"]):
    574     logger.debug(
    575         "Obsid {obsid} has status {status}".format(
    576             obsid=obsid, status=summary["status"]
    577         )
    578     )

File /proj/sot/ska/jeanproj/git/mica/mica/report/report.py:354, in obs_links(obsid, sequence, plan)
    351 # if this is a science observation, only try to get a star catalog if it has a home
    352 # in the schedule either in the past or the near future
    353 if plan is not None:
--> 354     plan_date = Time(datetime.datetime.strptime(plan, "%b %d %Y %I:%M%p"))
    355     if plan_date < Time.now() + 21 * u.day:
    356         mp_dir, status, mp_date = starcheck.get_mp_dir(obsid)

TypeError: strptime() argument 1 must be str, not MaskedConstant

This PR

In [1]: import mica.report.report

In [2]: mica.report.report.main(30270)
Making report for 30270
Generating V&V for obsid 30270
No V&V available
Writing out full report to /proj/sot/ska/data/mica/archive/report/webreports/30/30270/index.html

@jeanconn jeanconn marked this pull request as ready for review December 10, 2024 21:22
@jeanconn jeanconn requested a review from Copilot December 11, 2024 13:27

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no suggestions.

@jeanconn jeanconn changed the title Change report target_summary method to return unmasked dict or None Change report target_summary method to return dict or None Dec 11, 2024
@jeanconn
Copy link
Contributor Author

Updated per comment and unit testing re-run.

@jeanconn jeanconn requested a review from taldcroft December 27, 2024 15:51
@jeanconn jeanconn merged commit 083bffa into master Dec 30, 2024
2 checks passed
@jeanconn jeanconn deleted the masked-ocat-data branch December 30, 2024 00:36
This was referenced Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants