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

DM-34186: Add has_simulated_content and group_counter_* #55

Merged
merged 6 commits into from May 9, 2022

Conversation

timj
Copy link
Member

@timj timj commented Mar 25, 2022

  • has_simulated_content has become necessary now that we are taking ComCam data in the lab that is pretending to be on sky.
  • group_counter_* are needed to allow the new LSSTCam visit definitions to work. Headers now say they are N of M so the first and last values for observation_counter_* can be determined from a header.

@timj timj changed the title DM-34186: Add is_simulated and group_counter_* DM-34186: Add has_simulated_content and group_counter_* Mar 25, 2022
@codecov
Copy link

codecov bot commented Apr 7, 2022

Codecov Report

Merging #55 (c0aea8e) into main (1ca0471) will increase coverage by 0.33%.
The diff coverage is 82.35%.

@@            Coverage Diff             @@
##             main      #55      +/-   ##
==========================================
+ Coverage   77.79%   78.12%   +0.33%     
==========================================
  Files          36       36              
  Lines        2968     3045      +77     
  Branches      471      476       +5     
==========================================
+ Hits         2309     2379      +70     
- Misses        542      548       +6     
- Partials      117      118       +1     
Impacted Files Coverage Δ
python/astro_metadata_translator/properties.py 100.00% <ø> (ø)
tests/test_cfht.py 90.90% <ø> (ø)
tests/test_decam.py 85.71% <ø> (ø)
tests/test_sdss.py 85.71% <ø> (ø)
tests/test_subaru.py 94.28% <ø> (ø)
...ython/astro_metadata_translator/observationInfo.py 76.86% <41.66%> (-1.65%) ⬇️
python/astro_metadata_translator/indexing.py 70.14% <76.47%> (+7.88%) ⬆️
python/astro_metadata_translator/tests.py 80.37% <100.00%> (ø)
python/astro_metadata_translator/translator.py 76.40% <100.00%> (+0.58%) ⬆️
tests/test_indexing.py 98.40% <100.00%> (+0.46%) ⬆️
... and 1 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 1ca0471...c0aea8e. Read the comment docs.

@@ -336,4 +336,25 @@ class PropertyDefinition:
"int",
int,
),
"has_simulated_content": PropertyDefinition(
"Boolean indicating whether any part of this observation was" " simulated.", "bool", bool, None, None
Copy link
Contributor

Choose a reason for hiding this comment

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

Strange formatting.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha. Thank you black (was on two lines before black got involved). Will fix.

None,
None,
),
"group_counter_end": PropertyDefinition(
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we know the observation counter for the end of the exposure group at the time the observation is taken? Surely weather or instrumental problems can ruin plans and therefore the header. Are you expecting that we will skip exposure identifiers?

Copy link
Member Author

Choose a reason for hiding this comment

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

A modern visit is defined by the tuple of start_num, end_num. If the second observation does not turn up as expected the next observation will have a different start_num (or will not be there at all) so there won't be a problem. When visits are defined it will define the visit with just the first one in. I do complain in define-visits if I get the second file of a pair since that implies the first one must have been taken.

path: str,
*,
force_dict: Literal[False],
) -> Union[ObservationGroup, MutableMapping[str, Union[MutableMapping[str, Any], ObservationInfo]]]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth aliasing the MutableMapping[str, Union[MutableMapping[str, Any], ObservationInfo]] since you use it multiple times.
MutableMapping[str, Any] too.

Copy link
Member Author

Choose a reason for hiding this comment

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

What I'd really like is to fix ObservationInfo so it can take a Mapping[str, Any].

def process_index_data(
content: MutableMapping[str, Any], *, force_metadata: bool = False, force_dict: bool = False
) -> Union[ObservationGroup, MutableMapping[str, Union[MutableMapping[str, Any], ObservationInfo]]]:
...
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't you missing a combination? What do I get if force_metadata = True and force_dict = True?

Copy link
Member Author

Choose a reason for hiding this comment

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

force_metadata = True makes force_dict irrelevant but I'll see if it makes a difference.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had a quick look and it seemed to trigger a bunch of warnings from the other overloads that I'd rather not try to sort out at the moment. I was going down a maze of twisty passages all alike.

@@ -266,7 +321,7 @@ def process_index_data(
obs_infos: List[ObservationInfo] = []
# This type annotation is really MutableMapping[str, ObservationInfo]
# but mypy needs it to look like the function return value.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this would be fixed if you added the missing overload?

Copy link
Member Author

Choose a reason for hiding this comment

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

force_metadata = False is the only way to get to this branch so I don't think the missing overload matters.

timj added 6 commits May 9, 2022 12:17
* has_simulated_content has become necessary now that we are taking ComCam
  data in the lab that is pretending to be on sky.
* group_counter is needed to allow the new LSSTCam visit definitions
  to work. Headers now say they are N of M so the first and last
  values for observation_counter can be determined from a
  header.
This is a hack to allow old index/sidecar files containing
serialized ObservationInfo to be read back in with defaults
filling in the recent property additions.
booleans are stored as YAML boolean so there is no processing
to be done.
This tests that the fallback constructor code triggers
correctly.
@timj timj merged commit 2425970 into main May 9, 2022
@timj timj deleted the tickets/DM-34186 branch May 9, 2022 19:55
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.

None yet

2 participants