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-29042: Remove support for old-style names in ap_verify #146

Merged
merged 3 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 0 additions & 6 deletions config/dataset_config.yaml

This file was deleted.

69 changes: 0 additions & 69 deletions python/lsst/ap/verify/config.py

This file was deleted.

63 changes: 3 additions & 60 deletions python/lsst/ap/verify/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,12 @@
__all__ = ["Dataset"]

import os
import warnings

from deprecated.sphinx import deprecated

import lsst.daf.persistence as dafPersistence
import lsst.daf.butler as dafButler
import lsst.obs.base as obsBase
from lsst.utils import getPackageDir

from .config import Config


class Dataset:
"""A dataset supported by ``ap_verify``.
Expand All @@ -60,28 +55,16 @@ class Dataset:

def __init__(self, datasetId):
self._id = datasetId
# daf.persistence.Policy's behavior on missing keys is apparently undefined
# test for __getattr__ *either* raising KeyError or returning None
try:
datasetPackage = self._getDatasetInfo()[datasetId]
if datasetPackage is None:
raise KeyError
else:
warnings.warn(f"The {datasetId} name is deprecated, and will be removed after v24.0. "
f"Use {datasetPackage} instead.", category=FutureWarning)
except KeyError:
# if datasetId not known, assume it's a package name
datasetPackage = datasetId

try:
self._dataRootDir = getPackageDir(datasetPackage)
self._dataRootDir = getPackageDir(datasetId)
except LookupError as e:
error = f"Cannot find the {datasetPackage} package; is it set up?"
error = f"Cannot find the {datasetId} package; is it set up?"
raise ValueError(error) from e
else:
self._validatePackage()

self._initPackage(datasetPackage)
self._initPackage(datasetId)

def _initPackage(self, name):
"""Prepare the package backing this ap_verify dataset.
Expand All @@ -94,46 +77,6 @@ def _initPackage(self, name):
# No initialization required at present
pass

# TODO: remove in DM-29042
@staticmethod
@deprecated(reason="The concept of 'supported' datasets is deprecated. This "
"method will be removed after v24.0.", version="v22.0", category=FutureWarning)
def getSupportedDatasets():
"""The ap_verify dataset IDs that can be passed to this class's constructor.

Returns
-------
datasets : `set` of `str`
the set of IDs that will be accepted

Raises
------
IoError
Raised if the config file does not exist or is not readable
RuntimeError
Raised if the config file exists, but does not contain the expected data
"""
return Dataset._getDatasetInfo().keys()

# TODO: remove in DM-29042
@staticmethod
def _getDatasetInfo():
"""Return external data on supported ap_verify datasets.

If an exception is raised, the program state shall be unchanged.

Returns
-------
datasetToPackage : `dict`-like
a map from dataset IDs to package names.

Raises
------
RuntimeError
Raised if the config file exists, but does not contain the expected data
"""
return Config.instance['datasets']

@property
def datasetRoot(self):
"""The parent directory containing everything related to the
Expand Down
12 changes: 0 additions & 12 deletions python/lsst/ap/verify/testUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

import lsst.utils.tests

from lsst.ap.verify.config import Config


class DataTestCase(lsst.utils.tests.TestCase):
"""Unit test class for tests that need to use the Dataset framework.
Expand All @@ -52,10 +50,6 @@ class DataTestCase(lsst.utils.tests.TestCase):
Set to `None` if ``testDataset`` loads its own dependencies (not
recommended for test datasets).
"""
datasetKey = 'test'
"""The ap_verify dataset name that would be used on the command line (`str`).
"""
# TODO: remove datasetKey in DM-29042

@classmethod
def setUpClass(cls):
Expand All @@ -68,9 +62,3 @@ def setUpClass(cls):
lsst.utils.getPackageDir(cls.obsPackage)
except LookupError:
raise unittest.SkipTest(f'{cls.obsPackage} not set up; needed for {cls.testDataset}')

# Hack the config for testing purposes
# Note that Config.instance is supposed to be immutable, so, depending on initialization order,
# this modification may cause other tests to see inconsistent config values
# TODO: remove in DM-29042
Config.instance._allInfo['datasets.' + cls.datasetKey] = cls.testDataset
15 changes: 0 additions & 15 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ def testRepr(self):
# Required to match constructor call
self.assertEqual(repr(self._testbed), "Dataset(" + repr(self.testDataset) + ")")

# TODO: remove in DM-29042
def testDatasets(self):
"""Verify that a Dataset knows its supported datasets.
"""
with self.assertWarns(FutureWarning):
datasets = Dataset.getSupportedDatasets()
self.assertIn(DatasetTestSuite.datasetKey, datasets) # assumed by other tests

# TODO: remove in DM-29042
def testOldDataset(self):
"""Verify that Dataset construction warns on old-style dataset names.
"""
with self.assertWarns(FutureWarning):
Dataset(DatasetTestSuite.datasetKey)

def testBadDataset(self):
"""Verify that Dataset construction fails gracefully on nonexistent datasets.
"""
Expand Down