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-39996: Code modernization and ruff configuration #462

Merged
merged 23 commits into from
Jul 14, 2023
Merged

Conversation

timj
Copy link
Member

@timj timj commented Jul 12, 2023

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@timj timj requested a review from andy-slac July 13, 2023 01:17
Copy link
Contributor

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

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

Looks good, few minor comments.

python/lsst/obs/base/_instrument.py Outdated Show resolved Hide resolved
python/lsst/obs/base/_read_curated_calibs.py Outdated Show resolved Hide resolved
Comment on lines +631 to +636
"Call Registry.expandDataId before Butler.get to avoid this.",
# It is not entirely obvious what the correct stacklevel
# should be for a formatter. Outside of obs_base will be
# the butler datastore. Outside of daf_butler might be
# the right answer and could be the caller using butler.get
# or could be a runQuantum method.
Copy link
Contributor

Choose a reason for hiding this comment

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

If we cannot be sure where the actual cause is located, would it be better to print a full traceback?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe I leave it warning from the formatter. @TallJimbo do you have an opinion on where a warning from a formatter should appear to be coming from?

Copy link
Member

Choose a reason for hiding this comment

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

We definitely don't want to fully lose any of the traceback, but if we have any control over what users see most prominently, it's probably whatever low-level I/O code the formatter is calling (e.g. if it's coming from cfitsio, I'd want to see cfitsio's error message).

Copy link
Member Author

Choose a reason for hiding this comment

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

This question is specifically about what line and file this warning is reported as coming from. For a formatter that was not directly called by the user maybe the formatter is the right source of the warning message. The only other alternative would be the place that called butler.get.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry, didn't look closely enough. For this particular warning, whatever called QuantumContext.get would be ideal.

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 could extend find_outside_stacklevel a bit. My initial thought was to takes *args and so use it here with:

stacklevel=find_outside_stacklevel("lsst.obs.base", "lsst.daf.butler")

and then it would be reported as coming from QuantumContext.get in the pipeline execution environment. At least it would come from the user code if they called butler.get(). Making it come from the caller of QuantumContext.get seems a bit trickier. One option is to add lsst.pipe.base.QuantumContext to the list as well and so be able to filter out classes. I can give that a try but it would have to be on a new ticket. For now then I'll merge this and then come back later to fix it up (I'll add a TODO ticket).

Copy link
Member

Choose a reason for hiding this comment

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

Deferring is completely fine. This particular warning should be sufficiently rare that if somebody asks on Slack every time they see it and I have to answer them it still won't be much of a burden, so on its own I don't think this is sufficient motivation for big enhancements to find_outside_stacklevel (though I agree that might provide useful elsewhere).

python/lsst/obs/base/ingest_tests.py Show resolved Hide resolved
python/lsst/obs/base/script/ingestRaws.py Outdated Show resolved Hide resolved
python/lsst/obs/base/tests.py Outdated Show resolved Hide resolved
python/lsst/obs/base/yamlCamera.py Outdated Show resolved Hide resolved
tests/test_cliCmdTestIngest.py Outdated Show resolved Hide resolved
tests/test_filters.py Show resolved Hide resolved
tests/test_fitsRawFormatter.py Outdated Show resolved Hide resolved
timj and others added 17 commits July 13, 2023 16:19
What should the stacklevel really be though?
It should probably be outside of obs_base and daf_butler
and this will require a slight modification to
find_outside_stacklevel to take *args.
This appeases bugbear linting by showing that you
know that the property access will be doing something.
If a class has no abstract methods making it abstract
with "abc" is pointless.
This will let daf_butler and pipe_base references resolve.
Co-authored-by: Andy Salnikov <[email protected]>
@timj timj merged commit e640815 into main Jul 14, 2023
6 checks passed
@timj timj deleted the tickets/DM-39996 branch July 14, 2023 17:32
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.

3 participants