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-30685: Issue warning if lookup key dimension is not known to universe #534

Merged
merged 2 commits into from
Jun 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 18 additions & 3 deletions python/lsst/daf/butler/core/configSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,28 @@ def __init__(self, name: Optional[str] = None,
raise ValueError(f"Supplied name must be str not: '{name}'")

if "+" in name:
if universe is None:
raise ValueError(f"Cannot construct LookupKey for {name} without dimension universe.")

# If we are given a single dimension we use the "+" to
# indicate this but have to filter out the empty value
dimension_names = [n for n in name.split("+") if n]
if universe is None:
raise ValueError(f"Cannot construct LookupKey for {name} without dimension universe.")
else:
try:
self._dimensions = universe.extract(dimension_names)
except KeyError:
# One or more of the dimensions is not known to the
# universe. This could be a typo or it could be that
# a config is being used that is not compatible with
# this universe. Use the name directly as a lookup key
# but issue a warning. This will be potentially annoying
# in the scenario where a lookup key comes from a
# default config but the users are using an external
# universe.
unknown = [name for name in dimension_names if universe.get(name) is None]
log.warning("A LookupKey '%s' uses unknown dimensions: %s. Possible typo?"
" Using the name explicitly.",
name, unknown)
self._name = name
else:
self._name = name

Expand Down