Loading [MathJax]/jax/output/HTML-CSS/config.js
LSST Applications g04a91732dc+cc8870d3f5,g07dc498a13+5aa0b8792f,g0fba68d861+80045be308,g1409bbee79+5aa0b8792f,g1a7e361dbc+5aa0b8792f,g1fd858c14a+f64bc332a9,g208c678f98+1ae86710ed,g35bb328faa+fcb1d3bbc8,g4d2262a081+47ad8a29a8,g4d39ba7253+9633a327c1,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+9633a327c1,g668ecb457e+25d63fd678,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8852436030+8b64ca622a,g89139ef638+5aa0b8792f,g89e1512fd8+04325574d3,g8d6b6b353c+9633a327c1,g9125e01d80+fcb1d3bbc8,g989de1cb63+5aa0b8792f,g9f33ca652e+b196626af7,ga9baa6287d+9633a327c1,gaaedd4e678+5aa0b8792f,gabe3b4be73+1e0a283bba,gb1101e3267+71e32094df,gb58c049af0+f03b321e39,gb90eeb9370+2807b1ad02,gcf25f946ba+8b64ca622a,gd315a588df+a39986a76f,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+4e42d81ab7,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,gfe73954cf8+a1301e4c20,w.2025.11
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