Skip to content

Commit

Permalink
Turn more RFC-879 deprecations into errors.
Browse files Browse the repository at this point in the history
Dataset type wildcards are no longer permitted in queryDataIds and
queryDimensionRecords, and missing dataset types are now an error in
those contexts.
  • Loading branch information
TallJimbo committed Oct 1, 2022
1 parent f72844b commit 11ce7f4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 45 deletions.
9 changes: 2 additions & 7 deletions python/lsst/daf/butler/registries/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import contextlib
import logging
import warnings
from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -80,6 +79,7 @@
DatasetTypeError,
DimensionNameError,
InconsistentDataIdError,
MissingDatasetTypeError,
NoDefaultCollectionError,
OrphanedRecordError,
Registry,
Expand Down Expand Up @@ -969,12 +969,7 @@ def _standardize_query_dataset_args(
datasets, missing=missing, explicit_only=(mode == "constrain")
)
if missing and mode == "constrain":
# After v26 this should raise MissingDatasetTypeError, to be
# implemented on DM-36303.
warnings.warn(
f"Dataset type(s) {missing} are not registered; this will be an error after v26.",
FutureWarning,
)
raise MissingDatasetTypeError(f"Dataset type(s) {missing} are not registered.")
doomed_by.extend(f"Dataset type {name} is not registered." for name in missing)
elif collections:
raise ArgumentError(f"Cannot pass 'collections' (='{collections}') without 'datasets'.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
)

import logging
import warnings
from typing import TYPE_CHECKING, Any

import sqlalchemy
from lsst.utils.ellipsis import Ellipsis

from ....core import DatasetId, DatasetRef, DatasetType, DimensionUniverse, ddl
from ..._collection_summary import CollectionSummary
from ..._exceptions import ConflictingDefinitionError, DatasetTypeError, OrphanedRecordError
from ..._exceptions import (
ConflictingDefinitionError,
DatasetTypeError,
DatasetTypeExpressionError,
OrphanedRecordError,
)
from ...interfaces import DatasetIdGenEnum, DatasetRecordStorage, DatasetRecordStorageManager, VersionTuple
from ...wildcards import DatasetTypeWildcard
from ._storage import (
Expand Down Expand Up @@ -363,10 +367,8 @@ def resolve_wildcard(
result.append(storage.datasetType)
elif wildcard.patterns:
if explicit_only:
# be implemented on DM-36303.
warnings.warn(
"Passing wildcard patterns here is deprecated and will be prohibited after v26.",
FutureWarning,
raise DatasetTypeExpressionError(
"Dataset type wildcard expressions are not supported in this context."
)
for storage in self._byName.values():
if any(p.fullmatch(storage.datasetType.name) for p in wildcard.patterns):
Expand Down
33 changes: 9 additions & 24 deletions python/lsst/daf/butler/registry/tests/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
ConflictingDefinitionError,
DataIdValueError,
DatasetTypeError,
DatasetTypeExpressionError,
InconsistentDataIdError,
MissingCollectionError,
MissingDatasetTypeError,
Expand Down Expand Up @@ -2402,26 +2403,12 @@ def testQueryResultSummaries(self):
["potato"],
),
]
# The behavior of these additional queries is slated to change in the
# future, so we also check for deprecation warnings.
with self.assertWarns(FutureWarning):
queries_and_snippets.append(
(
# Dataset type name doesn't match any existing dataset
# types.
registry.queryDataIds(["detector"], datasets=["nonexistent"], collections=...),
["nonexistent"],
)
)
with self.assertWarns(FutureWarning):
queries_and_snippets.append(
(
# Dataset type name doesn't match any existing dataset
# types.
registry.queryDimensionRecords("detector", datasets=["nonexistent"], collections=...),
["nonexistent"],
)
)
with self.assertRaises(MissingDatasetTypeError):
# Dataset type name doesn't match any existing dataset types.
registry.queryDataIds(["detector"], datasets=["nonexistent"], collections=...)
with self.assertRaises(MissingDatasetTypeError):
# Dataset type name doesn't match any existing dataset types.
registry.queryDimensionRecords("detector", datasets=["nonexistent"], collections=...)
for query, snippets in queries_and_snippets:
self.assertFalse(query.any(execute=False, exact=False))
self.assertFalse(query.any(execute=True, exact=False))
Expand All @@ -2438,10 +2425,8 @@ def testQueryResultSummaries(self):
messages,
)

# This query does yield results, but should also emit a warning because
# dataset type patterns to queryDataIds is deprecated; just look for
# the warning.
with self.assertWarns(FutureWarning):
# Wildcards on dataset types are not permitted in queryDataIds.
with self.assertRaises(DatasetTypeExpressionError):
registry.queryDataIds(["detector"], datasets=re.compile("^nonexistent$"), collections=...)

# These queries yield no results due to problems that can be identified
Expand Down
8 changes: 0 additions & 8 deletions tests/test_cliCmdQueryDataIds.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,6 @@ def testDatasetsAndCollections(self):
self.assertIsNone(res)
self.assertIn("No dimensions in common", msg)

# Check that we get a reason returned if no dataset type is found.
with self.assertWarns(FutureWarning):
res, msg = self._queryDataIds(
repo=self.root, dimensions=("visit",), collections=("foo",), datasets="raw"
)
self.assertIsNone(res)
self.assertEqual(msg, "Dataset type raw is not registered.")

# Check that we get a reason returned if no dataset is found in
# collection.
res, msg = self._queryDataIds(
Expand Down

0 comments on commit 11ce7f4

Please sign in to comment.