lsst-pex-config 30.0.0__py3-none-any.whl → 30.0.0rc2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lsst/pex/config/config.py CHANGED
@@ -38,7 +38,6 @@ __all__ = (
38
38
  import copy
39
39
  import importlib
40
40
  import io
41
- import logging
42
41
  import math
43
42
  import numbers
44
43
  import os
@@ -48,13 +47,9 @@ import sys
48
47
  import tempfile
49
48
  import warnings
50
49
  from collections.abc import Mapping
51
- from contextlib import contextmanager
52
- from contextvars import ContextVar
53
50
  from types import GenericAlias
54
51
  from typing import Any, ForwardRef, Generic, TypeVar, cast, overload
55
52
 
56
- from lsst.resources import ResourcePath, ResourcePathExpression
57
-
58
53
  # if YAML is not available that's fine and we simply don't register
59
54
  # the yaml representer since we know it won't be used.
60
55
  try:
@@ -79,25 +74,6 @@ else:
79
74
  YamlLoaders = ()
80
75
  doImport = None
81
76
 
82
- _LOG = logging.getLogger(__name__)
83
-
84
-
85
- # Tracks the current config directory for the current context.
86
- _config_dir_stack: ContextVar[ResourcePath | None] = ContextVar("_config_dir_stack", default=None)
87
-
88
-
89
- def _get_config_root() -> ResourcePath | None:
90
- return _config_dir_stack.get()
91
-
92
-
93
- @contextmanager
94
- def _push_config_root(dirname: ResourcePath):
95
- token = _config_dir_stack.set(dirname)
96
- try:
97
- yield
98
- finally:
99
- _config_dir_stack.reset(token)
100
-
101
77
 
102
78
  class _PexConfigGenericAlias(GenericAlias):
103
79
  """A Subclass of python's GenericAlias used in defining and instantiating
@@ -1195,51 +1171,15 @@ class Config(metaclass=ConfigMeta): # type: ignore
1195
1171
  e.add_note(f"No field of name {name} exists in config type {_typeStr(self)}")
1196
1172
  raise
1197
1173
 
1198
- def _filename_to_resource(
1199
- self, filename: ResourcePathExpression | None = None
1200
- ) -> tuple[ResourcePath | None, str]:
1201
- """Create resource path from filename.
1202
-
1203
- Parameters
1204
- ----------
1205
- filename : `lsst.resources.ResourcePathExpression` or `None`
1206
- The URI expression associated with this config. Can be `None`
1207
- if no file URI is known.
1208
-
1209
- Returns
1210
- -------
1211
- resource : `lsst.resources.ResourcePath` or `None`
1212
- The resource version of the filename. Returns `None` if no filename
1213
- was given or refers to unspecified value.
1214
- file_string : `str`
1215
- String form of the resource for use in ``__file__``
1216
- """
1217
- if filename is None or filename in ("?", "<unknown>"):
1218
- return None, "<unknown>"
1219
- base = _get_config_root()
1220
- resource = ResourcePath(filename, forceAbsolute=True, forceDirectory=False, root=base)
1221
-
1222
- # Preferred definition of __file__ is the full OS path. If a config
1223
- # is loaded with a relative path it must be converted to the absolute
1224
- # path to avoid confusion with later relative paths referenced inside
1225
- # the config.
1226
- if resource.scheme == "file":
1227
- file_string = resource.ospath
1228
- else:
1229
- file_string = str(resource)
1230
-
1231
- return resource, file_string
1232
-
1233
1174
  def load(self, filename, root="config"):
1234
1175
  """Modify this config in place by executing the Python code in a
1235
1176
  configuration file.
1236
1177
 
1237
1178
  Parameters
1238
1179
  ----------
1239
- filename : `lsst.resources.ResourcePathExpression`
1240
- Name of the configuration URI. A configuration file is a Python
1241
- module. Since configuration files are Python code, remote URIs
1242
- are not allowed.
1180
+ filename : `str`
1181
+ Name of the configuration file. A configuration file is Python
1182
+ module.
1243
1183
  root : `str`, optional
1244
1184
  Name of the variable in file that refers to the config being
1245
1185
  overridden.
@@ -1259,21 +1199,9 @@ class Config(metaclass=ConfigMeta): # type: ignore
1259
1199
  lsst.pex.config.Config.saveToStream
1260
1200
  lsst.pex.config.Config.saveToString
1261
1201
  """
1262
- resource, file_string = self._filename_to_resource(filename)
1263
- if resource is None:
1264
- # A filename is required.
1265
- raise ValueError(f"Undefined URI provided to load command: {filename}.")
1266
-
1267
- if resource.scheme not in ("file", "eups", "resource"):
1268
- raise ValueError(f"Remote URI ({resource}) can not be used to load configurations.")
1269
-
1270
- # Push the directory of the file we are now reading onto the stack
1271
- # so that nested loads are relative to this file.
1272
- with _push_config_root(resource.dirname()):
1273
- _LOG.debug("Updating config from URI %s", str(resource))
1274
- with resource.open("r") as f:
1275
- code = compile(f.read(), filename=file_string, mode="exec")
1276
- self._loadFromString(code, root=root, filename=file_string)
1202
+ with open(filename) as f:
1203
+ code = compile(f.read(), filename=filename, mode="exec")
1204
+ self.loadFromString(code, root=root, filename=filename)
1277
1205
 
1278
1206
  def loadFromStream(self, stream, root="config", filename=None, extraLocals=None):
1279
1207
  """Modify this Config in place by executing the Python code in the
@@ -1296,8 +1224,7 @@ class Config(metaclass=ConfigMeta): # type: ignore
1296
1224
  Then this config's field ``myField`` is set to ``5``.
1297
1225
  filename : `str`, optional
1298
1226
  Name of the configuration file, or `None` if unknown or contained
1299
- in the stream. Used for error reporting and to set ``__file__``
1300
- variable in config.
1227
+ in the stream. Used for error reporting.
1301
1228
  extraLocals : `dict` of `str` to `object`, optional
1302
1229
  Any extra variables to include in local scope when loading.
1303
1230
 
@@ -1317,7 +1244,7 @@ class Config(metaclass=ConfigMeta): # type: ignore
1317
1244
  """
1318
1245
  if hasattr(stream, "read"):
1319
1246
  if filename is None:
1320
- filename = getattr(stream, "name", "<unknown>")
1247
+ filename = getattr(stream, "name", "?")
1321
1248
  code = compile(stream.read(), filename=filename, mode="exec")
1322
1249
  else:
1323
1250
  code = stream
@@ -1341,11 +1268,9 @@ class Config(metaclass=ConfigMeta): # type: ignore
1341
1268
  config.myField = 5
1342
1269
 
1343
1270
  Then this config's field ``myField`` is set to ``5``.
1344
- filename : `lsst.resources.ResourcePathExpression`, optional
1345
- URI of the configuration file, or `None` if unknown or contained
1346
- in the stream. Used for error reporting and to set ``__file__``
1347
- variable. Required to be set if the string config attempts to
1348
- load other configs using either relative path or ``__file__``.
1271
+ filename : `str`, optional
1272
+ Name of the configuration file, or `None` if unknown or contained
1273
+ in the stream. Used for error reporting.
1349
1274
  extraLocals : `dict` of `str` to `object`, optional
1350
1275
  Any extra variables to include in local scope when loading.
1351
1276
 
@@ -1366,24 +1291,7 @@ class Config(metaclass=ConfigMeta): # type: ignore
1366
1291
  if filename is None:
1367
1292
  # try to determine the file name; a compiled string
1368
1293
  # has attribute "co_filename",
1369
- filename = getattr(code, "co_filename", "<unknown>")
1370
-
1371
- resource, file_string = self._filename_to_resource(filename)
1372
- if resource is None:
1373
- # No idea where this config came from so no ability to deal with
1374
- # relative paths. No reason to use context.
1375
- self._loadFromString(code, root=root, filename=filename, extraLocals=extraLocals)
1376
- else:
1377
- # Push the directory of the file we are now reading onto the stack
1378
- # so that nested loads are relative to this file.
1379
- with _push_config_root(resource.dirname()):
1380
- self._loadFromString(code, root=root, filename=file_string, extraLocals=extraLocals)
1381
-
1382
- def _loadFromString(self, code, root="config", filename=None, extraLocals=None):
1383
- """Update config from string.
1384
-
1385
- Assumes relative directory path context has been setup by caller.
1386
- """
1294
+ filename = getattr(code, "co_filename", "?")
1387
1295
  with RecordingImporter() as importer:
1388
1296
  globals = {"__file__": filename}
1389
1297
  local = {root: self}
@@ -192,7 +192,7 @@ class ConfigInstanceDict(collections.abc.Mapping[str, Config]):
192
192
  result._typemap = self._typemap
193
193
  if self._selection is not None:
194
194
  if self._field.multi:
195
- result._selection = SelectionSet(self, self._selection._set)
195
+ result._selection = SelectionSet(result._dict, self._selection._set)
196
196
  else:
197
197
  result._selection = self._selection
198
198
  return result
@@ -76,7 +76,7 @@ class ConfigDict(Dict[str, Config]):
76
76
  return type(self)(
77
77
  config,
78
78
  self._field,
79
- {k: v.copy() for k, v in self._dict.items()},
79
+ {k: v._copy() for k, v in self._dict.items()},
80
80
  at=None,
81
81
  label="copy",
82
82
  setHistory=False,
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "30.0.0"
2
+ __version__ = "30.0.0rc2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lsst-pex-config
3
- Version: 30.0.0
3
+ Version: 30.0.0rc2
4
4
  Summary: A flexible configuration system using Python files.
5
5
  Author-email: Rubin Observatory Data Management <dm-admin@lists.lsst.org>
6
6
  License-Expression: BSD-3-Clause OR GPL-3.0-or-later
@@ -9,12 +9,12 @@ Keywords: lsst
9
9
  Classifier: Intended Audience :: Science/Research
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.14
12
+ Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Topic :: Scientific/Engineering :: Astronomy
17
- Requires-Python: >=3.11.0
17
+ Requires-Python: >=3.10.0
18
18
  Description-Content-Type: text/x-rst
19
19
  License-File: COPYRIGHT
20
20
  License-File: LICENSE
@@ -22,7 +22,6 @@ License-File: gpl-v3.0.txt
22
22
  License-File: bsd_license.txt
23
23
  Requires-Dist: pyyaml>=5.1
24
24
  Requires-Dist: numpy>=1.17
25
- Requires-Dist: lsst-resources
26
25
  Provides-Extra: test
27
26
  Requires-Dist: pytest>=3.2; extra == "test"
28
27
  Requires-Dist: pytest-openfiles>=0.5.0; extra == "test"
@@ -5,9 +5,9 @@ lsst/pex/config/_doNotImportMe.py,sha256=AYqqE8aIHH711hPcZJssplBsIIW4xCbz2oZqRNh
5
5
  lsst/pex/config/callStack.py,sha256=HxcH1QpYERsR68sBLs8jqX3Gj85e28vhCCjCy6lnVaE,5917
6
6
  lsst/pex/config/choiceField.py,sha256=S_ygw6coQaKNIstpQxKF-MMsX0agdEZtqZuEcK1EYJg,4277
7
7
  lsst/pex/config/comparison.py,sha256=2zbOdMD5aOC3ccI2NJSxtiI59wLMmssuP9oxdXBvzaE,6320
8
- lsst/pex/config/config.py,sha256=bGlaQ9F5dtmXXbnlyzvUisT7UXn7SYBaZ4GS14LRANI,66935
9
- lsst/pex/config/configChoiceField.py,sha256=gWBODt4Vbw7IcMTNLBBizWdXBXyJSCN0SRl8c2zafL4,24431
10
- lsst/pex/config/configDictField.py,sha256=_OjAj8DSwyF8HPoIRjCvyw3Bt1IcP0GACdl-SHggR1M,12892
8
+ lsst/pex/config/config.py,sha256=DPlN6tLVJawAaJPuxTjjDZQGYPnwWOv1cGq5myFoNQU,63028
9
+ lsst/pex/config/configChoiceField.py,sha256=CbISBYgMuKEJyed2G6f8XEodL-98O3L2Haxc8Dx_s1I,24439
10
+ lsst/pex/config/configDictField.py,sha256=gnVi52CHB3B0K-NNC3NUZDxi556pFJnVSF4-73JlJw4,12893
11
11
  lsst/pex/config/configField.py,sha256=9jSPSHO_9p-499SmJgvMWBbizAl4p1jTQrtlib1gXHo,11655
12
12
  lsst/pex/config/configurableField.py,sha256=-nYA54G6UJLVzB_lQgPRiCMQJ_yv9c-43uxyCJkH198,18995
13
13
  lsst/pex/config/convert.py,sha256=dBTLjkcoh3lM6FxtY9DV33iLOtD6V0PMni6O2b9K4Ww,2397
@@ -17,19 +17,19 @@ lsst/pex/config/listField.py,sha256=H0j1TR3jTxUM80vcBWmoNlCCjd1HFSP15UxiR56gBxY,
17
17
  lsst/pex/config/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  lsst/pex/config/rangeField.py,sha256=VmfcAoLYRJIdIsnFQIFlVYKrmNnfGX6Ef9enEYkFTx8,5429
19
19
  lsst/pex/config/registry.py,sha256=JKy6kXOumSYDoOdHlg4oBGeQN7pmMSOgCJCXylEI6yM,15790
20
- lsst/pex/config/version.py,sha256=--s7nTlXrHcUGZfOJGTF8_DCdIUv7QPWWD7as9kq0iY,49
20
+ lsst/pex/config/version.py,sha256=CrAQNQjb1NNXqaNvScI53U2GvkmrnpRtyOiy0bIrcl4,52
21
21
  lsst/pex/config/wrap.py,sha256=t8s5KzN2kJ-oW8AJTZrz4xAl0Qtpvnqo9H6rQKRBK_s,12964
22
22
  lsst/pex/config/configurableActions/__init__.py,sha256=kwMbhFr3LirwEqzgHij7CxWF_xki3UYeajzveb4vpTI,1039
23
23
  lsst/pex/config/configurableActions/_configurableAction.py,sha256=KZiYYzIQHNeUhDxS1DMb_D9X28_LOzLyNXclaOW-ApY,2784
24
24
  lsst/pex/config/configurableActions/_configurableActionField.py,sha256=E1uVrGIvu64QDJL76sW3LlIrR30-NJs0ZQeofy-iVEs,5353
25
25
  lsst/pex/config/configurableActions/_configurableActionStructField.py,sha256=HL53MsLh1DaKmZBD3midrHcB8tbJ46lNBwerjne0qrg,17754
26
26
  lsst/pex/config/configurableActions/tests.py,sha256=aisHgzghfR4NFQD22NU2K5pNilCjAwcJTSMs0vK7dzI,3039
27
- lsst_pex_config-30.0.0.dist-info/licenses/COPYRIGHT,sha256=J3bcuh9PTaTU9iNjxE-9THWEwoo5drYshgYvZVgUKoI,381
28
- lsst_pex_config-30.0.0.dist-info/licenses/LICENSE,sha256=pRExkS03v0MQW-neNfIcaSL6aiAnoLxYgtZoFzQ6zkM,232
29
- lsst_pex_config-30.0.0.dist-info/licenses/bsd_license.txt,sha256=7MIcv8QRX9guUtqPSBDMPz2SnZ5swI-xZMqm_VDSfxY,1606
30
- lsst_pex_config-30.0.0.dist-info/licenses/gpl-v3.0.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
31
- lsst_pex_config-30.0.0.dist-info/METADATA,sha256=SPApsBpLniqRdGlFRj_PWVpG11dFyomRHVqS7RRFfjs,2233
32
- lsst_pex_config-30.0.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
33
- lsst_pex_config-30.0.0.dist-info/top_level.txt,sha256=eUWiOuVVm9wwTrnAgiJT6tp6HQHXxIhj2QSZ7NYZH80,5
34
- lsst_pex_config-30.0.0.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
35
- lsst_pex_config-30.0.0.dist-info/RECORD,,
27
+ lsst_pex_config-30.0.0rc2.dist-info/licenses/COPYRIGHT,sha256=J3bcuh9PTaTU9iNjxE-9THWEwoo5drYshgYvZVgUKoI,381
28
+ lsst_pex_config-30.0.0rc2.dist-info/licenses/LICENSE,sha256=pRExkS03v0MQW-neNfIcaSL6aiAnoLxYgtZoFzQ6zkM,232
29
+ lsst_pex_config-30.0.0rc2.dist-info/licenses/bsd_license.txt,sha256=7MIcv8QRX9guUtqPSBDMPz2SnZ5swI-xZMqm_VDSfxY,1606
30
+ lsst_pex_config-30.0.0rc2.dist-info/licenses/gpl-v3.0.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
31
+ lsst_pex_config-30.0.0rc2.dist-info/METADATA,sha256=mJscy7ZVKy3me7ddU2jrehkQdhZWvt1gQ4J0jM2wYho,2206
32
+ lsst_pex_config-30.0.0rc2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ lsst_pex_config-30.0.0rc2.dist-info/top_level.txt,sha256=eUWiOuVVm9wwTrnAgiJT6tp6HQHXxIhj2QSZ7NYZH80,5
34
+ lsst_pex_config-30.0.0rc2.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
35
+ lsst_pex_config-30.0.0rc2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.10.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5