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

channelmap updates #78

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

channelmap updates #78

wants to merge 5 commits into from

Conversation

iguinn
Copy link

@iguinn iguinn commented Jan 6, 2025

Updated behavior of channelmap arguments

  • If an on argument is provided, a system argument must be provided or an error will be thrown. If no on is provided default to "all". This has the goal of avoiding confusion/ambiguity caused by the "all" default. See Unexpected behavior for channel map system #76
  • For on can provide period and run instead of just a timestamp. This will use the runinfo database to look up the timestamp. This is just a mild QoL improvement to interfacing with it.

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 56.33%. Comparing base (838ca85) to head (b051873).
Report is 30 commits behind head on main.

Files with missing lines Patch % Lines
src/legendmeta/core.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #78       +/-   ##
===========================================
- Coverage   71.95%   56.33%   -15.62%     
===========================================
  Files           8        8               
  Lines         813      497      -316     
===========================================
- Hits          585      280      -305     
+ Misses        228      217       -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ggmarshall
Copy link
Collaborator

Is it worth having the error instead be the current behaviour and a warning this behaviour is going to change in the future, conscious many people probably have code that calls this, not sure if better just to break it or not?

@iguinn
Copy link
Author

iguinn commented Jan 7, 2025

Yeah, that makes sense, I've changed this to a deprecation warning message


try:
pd, run = re.fullmatch("([pP][0-9]+)\\s*([rR][0-9]+)", on).group(1, 2)
runinfo = self.dataprod.runinfo[pd][run]
Copy link
Member

Choose a reason for hiding this comment

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

Will this generate an understandable error message if the string does not match?

system = "all"

if system is None:
msg = "Use of channelmap with an on arg but no system arg is deprecated and will raise an error in the future. Provide a value (e.g. 'all', 'cal', 'phy', etc.)"
Copy link
Member

@gipert gipert Jan 8, 2025

Choose a reason for hiding this comment

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

Suggested change
msg = "Use of channelmap with an on arg but no system arg is deprecated and will raise an error in the future. Provide a value (e.g. 'all', 'cal', 'phy', etc.)"
msg = (
"Use of channelmap with an on arg but no system arg is "
"deprecated and will raise an error in the future. Provide "
"a value (e.g. 'all', 'cal', 'phy', etc.)"
)


if system is None:
msg = "Use of channelmap with an on arg but no system arg is deprecated and will raise an error in the future. Provide a value (e.g. 'all', 'cal', 'phy', etc.)"
log.warning(msg)
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
log.warning(msg)
import warnings
warnings.warn(msg, DeprecationWarning, stacklevel=2)

Comment on lines 141 to +144

>>> channel = lmeta.channelmap(on=datetime.now(), system='cal').V05267B

>>> channel = lmeta.channelmap('p08 r005', system='cal').V05267B
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
>>> channel = lmeta.channelmap(on=datetime.now(), system='cal').V05267B
>>> channel = lmeta.channelmap('p08 r005', system='cal').V05267B
>>> channel = lmeta.channelmap(on=datetime.now(), system='cal').V05267B
>>> channel = lmeta.channelmap('p08 r005', system='cal').V05267B

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