Loading [MathJax]/extensions/tex2jax.js
LSST Applications g0000d66e7c+4a51730b0a,g0485b4d2cb+be65c9c1d7,g0fba68d861+f95c35e0c3,g1ec0fe41b4+3ea9d11450,g1fd858c14a+41d169aaf2,g2440f9efcc+8c5ae1fdc5,g35bb328faa+8c5ae1fdc5,g4d2262a081+30937b6477,g53246c7159+8c5ae1fdc5,g55585698de+c657de43f9,g56a49b3a55+7eddd92ad8,g60b5630c4e+c657de43f9,g67b6fd64d1+97cc007aa2,g78460c75b0+7e33a9eb6d,g786e29fd12+668abc6043,g7ac00fbb6c+9304e3655a,g8352419a5c+8c5ae1fdc5,g8852436030+3f3bba821f,g89139ef638+97cc007aa2,g94187f82dc+c657de43f9,g989de1cb63+97cc007aa2,g9d31334357+c657de43f9,g9f33ca652e+06d39d8afb,ga815be3f0b+8e7c4d07ad,gabe3b4be73+8856018cbb,gabf8522325+977d9fabaf,gb1101e3267+12c96a40b1,gb89ab40317+97cc007aa2,gc91f06edcd+2ffb87f22b,gcf25f946ba+3f3bba821f,gd6cbbdb0b4+1cc2750d2e,gde0f65d7ad+bbe98f05bf,ge278dab8ac+6b863515ed,ge410e46f29+97cc007aa2,gf35d7ec915+97dd712d81,gf5e32f922b+8c5ae1fdc5,gf67bdafdda+97cc007aa2,gf6800124b1+bb7d8e732a,w.2025.19
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
lsst.dax.apdb.tests._apdb Namespace Reference

Classes

class  ApdbSchemaUpdateTest
 
class  ApdbTest
 
class  TestCaseMixin
 

Functions

Region _make_region (tuple[float, float, float] xyz=(1.0, 1.0, -1.0))
 
Iterator[str] update_schema_yaml (str schema_file, bool drop_metadata=False, str|None version=None)
 

Function Documentation

◆ _make_region()

Region lsst.dax.apdb.tests._apdb._make_region ( tuple[float, float, float] xyz = (1.0, 1.0, -1.0))
protected
Make a region to use in tests

Definition at line 65 of file _apdb.py.

65def _make_region(xyz: tuple[float, float, float] = (1.0, 1.0, -1.0)) -> Region:
66 """Make a region to use in tests"""
67 pointing_v = UnitVector3d(*xyz)
68 fov = 0.0013 # radians
69 region = Circle(pointing_v, Angle(fov / 2))
70 return region
71
72
73@contextlib.contextmanager

◆ update_schema_yaml()

Iterator[str] lsst.dax.apdb.tests._apdb.update_schema_yaml ( str schema_file,
bool drop_metadata = False,
str | None version = None )
Update schema definition and return name of the new schema file.

Parameters
----------
schema_file : `str`
    Path for the existing YAML file with APDB schema.
drop_metadata : `bool`
    If `True` then remove metadata table from the list of tables.
version : `str` or `None`
    If non-empty string then set schema version to this string, if empty
    string then remove schema version from config, if `None` - don't change
    the version in config.

Yields
------
Path for the updated configuration file.

Definition at line 74 of file _apdb.py.

78) -> Iterator[str]:
79 """Update schema definition and return name of the new schema file.
80
81 Parameters
82 ----------
83 schema_file : `str`
84 Path for the existing YAML file with APDB schema.
85 drop_metadata : `bool`
86 If `True` then remove metadata table from the list of tables.
87 version : `str` or `None`
88 If non-empty string then set schema version to this string, if empty
89 string then remove schema version from config, if `None` - don't change
90 the version in config.
91
92 Yields
93 ------
94 Path for the updated configuration file.
95 """
96 with open(schema_file) as yaml_stream:
97 schemas_list = list(yaml.load_all(yaml_stream, Loader=yaml.SafeLoader))
98 # Edit YAML contents.
99 for schema in schemas_list:
100 # Optionally drop metadata table.
101 if drop_metadata:
102 schema["tables"] = [table for table in schema["tables"] if table["name"] != "metadata"]
103 if version is not None:
104 if version == "":
105 del schema["version"]
106 else:
107 schema["version"] = version
108
109 with TemporaryDirectory(ignore_cleanup_errors=True) as tmpdir:
110 output_path = os.path.join(tmpdir, "schema.yaml")
111 with open(output_path, "w") as yaml_stream:
112 yaml.dump_all(schemas_list, stream=yaml_stream)
113 yield output_path
114
115