LSST Applications g00d0e8bbd7+edbf708997,g03191d30f7+9ce8016dbd,g1955dfad08+0bd186d245,g199a45376c+5137f08352,g1fd858c14a+a888a50aa2,g262e1987ae+45f9aba685,g29ae962dfc+1c7d47a24f,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3fd5ace14f+eed17d2c67,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+c4107e45b5,g67b6fd64d1+6dc8069a4c,g74acd417e5+f452e9c21a,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+2025e9ce17,g7cc15d900a+2d158402f9,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d4809ba88+c4107e45b5,g8d7436a09f+e96c132b44,g8ea07a8fe4+db21c37724,g98df359435+aae6d409c1,ga2180abaac+edbf708997,gac66b60396+966efe6077,gb632fb1845+88945a90f8,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gca7fc764a6+6dc8069a4c,gd7ef33dd92+6dc8069a4c,gda68eeecaf+7d1e613a8d,gdab6d2f7ff+f452e9c21a,gdbb4c4dda9+c4107e45b5,ge410e46f29+6dc8069a4c,ge41e95a9f2+c4107e45b5,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