LSST Applications g00274db5b6+edbf708997,g00d0e8bbd7+edbf708997,g199a45376c+5137f08352,g1fd858c14a+1d4b6db739,g262e1987ae+f4d9505c4f,g29ae962dfc+7156fb1a53,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3e17d7035e+5b3adc59f5,g3fd5ace14f+852fa6fbcb,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+9f17e571f4,g67b6fd64d1+6dc8069a4c,g74acd417e5+ae494d68d9,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+536efcc10a,g7cc15d900a+d121454f8d,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d7436a09f+28c28d8d6d,g8ea07a8fe4+db21c37724,g92c671f44c+9f17e571f4,g98df359435+b2e6376b13,g99af87f6a8+b0f4ad7b8d,gac66b60396+966efe6077,gb88ae4c679+7dec8f19df,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gc24b5d6ed1+9f17e571f4,gca7fc764a6+6dc8069a4c,gcc769fe2a4+97d0256649,gd7ef33dd92+6dc8069a4c,gdab6d2f7ff+ae494d68d9,gdbb4c4dda9+9f17e571f4,ge410e46f29+6dc8069a4c,geaed405ab2+e194be0d2b,w.2025.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.dax.apdb.tests._apdb Namespace Reference

Classes

class  ApdbSchemaUpdateTest
 
class  ApdbTest
 

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 66 of file _apdb.py.

66def _make_region(xyz: tuple[float, float, float] = (1.0, 1.0, -1.0)) -> Region:
67 """Make a region to use in tests"""
68 pointing_v = UnitVector3d(*xyz)
69 fov = 0.0013 # radians
70 region = Circle(pointing_v, Angle(fov / 2))
71 return region
72
73
74@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 75 of file _apdb.py.

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