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-21207: Remove deprecated Policy usage from pex_config, ip_diffim, and meas_algorithms #54

Merged
merged 1 commit into from
Apr 13, 2020
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
11 changes: 0 additions & 11 deletions doc/lsst.pex.config/design-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ Design goals

- Support lists of parameter values.

Relationship to pex\_policy
===========================

The `lsst.pex.Policy` and `lsst.pex.PolicyDictionary` classes in the `pex_policy`_ package provided many of the features of `pex_config`_ in C++ and, via SWIG wrapping, Python.
`pex_config`_ (which contains the :ref:`lsst.pex.config` module) was developed to provide additional features and remove
some shortcomings.

`pex_policy`_ is being replaced with `pex_config`_ in the LSST Data Management System codebase.
To aid the transition, the `makePolicy` a utility function converts a `Config` to a `~lsst.pex.policy.Policy`.

Architecture
============

Expand All @@ -55,4 +45,3 @@ The storage and history for the fields is also maintained in the `Config` object
This allows `Field` classes to be easily inherited.

.. _pex_config: https://github.com/lsst/pex_config
.. _pex_policy: https://github.com/lsst/pex_policy
5 changes: 0 additions & 5 deletions doc/overview.dox
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,6 @@ After using SWIG, the preferred way to create the Config is via the

\section Notes

\subsection pexConfigConvert Relationship to lsst::pex::policy

The Policy and PolicyDictionary classes in the lsst::pex::policy package provided many of the features of lsst::pex::config in C++ and, via SWIG wrapping, Python. lsst::pex::config was developed to provide additional features and remove some shortcomings. lsst::pex::policy is being replaced with lsst::pex::config in the LSST DMS codebase; to aid the transition a utility function is provided to convert a Config to a Policy.


\subsection pexConfigArchitecture Architecture
Config uses a metaclass to record the Field attributes within each Config object in an internal dictionary. The storage and history for the fields is also maintained in the Config, not the Field itself. This allows Fields to be inherited without difficulty.

Expand Down
3 changes: 0 additions & 3 deletions python/lsst/pex/config/SConscript

This file was deleted.

51 changes: 1 addition & 50 deletions python/lsst/pex/config/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__all__ = ('makePropertySet', 'makePolicy')

from deprecated.sphinx import deprecated

try:
import lsst.pex.policy as pexPolicy
except ImportError:
pexPolicy = None
__all__ = ('makePropertySet',)

try:
import lsst.daf.base as dafBase
Expand All @@ -57,7 +50,6 @@ def makePropertySet(config):

See also
--------
makePolicy
lsst.daf.base.PropertySet
"""
if dafBase is None:
Expand All @@ -77,44 +69,3 @@ def _helper(ps, prefix, dict_):
return ps
else:
return None


@deprecated("pex_policy is deprecated, prefer makePropertySet (will be removed after v19)",
category=FutureWarning)
def makePolicy(config):
"""Convert a configuration into a `lsst.pex.policy.Policy`.

Parameters
----------
config : `lsst.pex.config.Config`
Configuration instance.

Returns
-------
policy : `lsst.pex.policy.Policy`
A `~lsst.pex.policy.Policy` that is equivalent to the ``config``
instance. If ``config`` is `None` then return value is also `None`.

See also
--------
makePropertySet
lsst.pex.policy.Policy
"""
if pexPolicy is None:
raise RuntimeError("lsst.pex.policy is not available")

def _helper(dict_):
p = pexPolicy.Policy()
for k, v in dict_.items():
if isinstance(v, dict):
p.set(k, _helper(v))
elif isinstance(v, list):
for vi in v:
p.add(k, vi)
elif v is not None:
p.set(k, v)
return p
if config:
return _helper(config.toDict())
else:
return None
22 changes: 2 additions & 20 deletions tests/test_Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@

import lsst.pex.config as pexConfig

# Some tests depend on daf_base or pex_policy.
# Skip them if they are not found.
# Some tests depend on daf_base.
# Skip them if it is not found.
try:
import lsst.daf.base as dafBase
except ImportError:
dafBase = None
try:
import lsst.pex.policy as pexPolicy
except ImportError:
pexPolicy = None

GLOBAL_REGISTRY = {}

Expand Down Expand Up @@ -332,20 +328,6 @@ class III(AAA):
self.assertEqual(III.a.default, 5)
self.assertEqual(AAA.a.default, 4)

@unittest.skipIf(pexPolicy is None, "lsst.pex.policy is required")
def testConvertPolicy(self):
with self.assertWarns(FutureWarning):
pol = pexConfig.makePolicy(self.simple)
self.assertFalse(pol.exists("i"))
self.assertEqual(pol.get("f"), self.simple.f)
self.assertEqual(pol.get("b"), self.simple.b)
self.assertEqual(pol.get("c"), self.simple.c)
self.assertEqual(pol.getArray("ll"), list(self.simple.ll))

with self.assertWarns(FutureWarning):
pol = pexConfig.makePolicy(self.comp)
self.assertEqual(pol.get("c.f"), self.comp.c.f)

@unittest.skipIf(dafBase is None, "lsst.daf.base is required")
def testConvertPropertySet(self):
ps = pexConfig.makePropertySet(self.simple)
Expand Down
1 change: 0 additions & 1 deletion ups/pex_config.table
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ setupRequired(numpy)
setupRequired(pybind11)
setupRequired(python)
setupOptional(daf_base)
setupOptional(pex_policy)

envPrepend(LD_LIBRARY_PATH, ${PRODUCT_DIR}/lib)
envPrepend(DYLD_LIBRARY_PATH, ${PRODUCT_DIR}/lib)
Expand Down