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.cassandra.config.ApdbCassandraConfig Class Reference
Inheritance diagram for lsst.dax.apdb.cassandra.config.ApdbCassandraConfig:
lsst.dax.apdb.config.ApdbConfig

Public Member Functions

tuple[str, str] check_ra_dec (cls, Iterable[str] v)
 
ApdbConfig from_uri (cls, ResourcePathExpression uri)
 
None save (self, ResourcePathExpression uri)
 

Static Public Attributes

tuple contact_points
 
str keyspace
 
ApdbCassandraConnectionConfig connection_config
 
ApdbCassandraPartitioningConfig partitioning
 
list dia_object_columns
 
str prefix
 
tuple ra_dec_columns
 
bool replica_skips_diaobjects
 
int replica_sub_chunk_count
 
int batch_statement_limit
 
int batch_size_limit
 
str schema_file
 
str ss_schema_file
 
str schema_name
 
int read_sources_months
 
int read_forced_sources_months
 
bool enable_replica
 
int replica_chunk_seconds
 

Static Protected Attributes

ClassVar _implementation_type [str]
 

Detailed Description

Configuration class for Cassandra-based APDB implementation.

Definition at line 181 of file config.py.

Member Function Documentation

◆ check_ra_dec()

tuple[str, str] lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.check_ra_dec ( cls,
Iterable[str] v )

Definition at line 252 of file config.py.

252 def check_ra_dec(cls, v: Iterable[str]) -> tuple[str, str]:
253 # This validation method is needed in case we initialize model from
254 # JSON in strict mode, in that mode JSON list is rejected by default.
255 vtup = tuple(v)
256 if len(vtup) != 2:
257 raise ValueError("ra_dec_columns must have exactly two column names")
258 return vtup
259
260

◆ from_uri()

ApdbConfig lsst.dax.apdb.config.ApdbConfig.from_uri ( cls,
ResourcePathExpression uri )
inherited
Load configuration object from external file.

Parameters
----------
uri : `~lsst.resources.ResourcePathExpression`
    Location of the file containing serialized configuration in YAML
    format.

Returns
-------
config : `ApdbConfig`
    Apdb configuration object.

Definition at line 91 of file config.py.

91 def from_uri(cls, uri: ResourcePathExpression) -> ApdbConfig:
92 """Load configuration object from external file.
93
94 Parameters
95 ----------
96 uri : `~lsst.resources.ResourcePathExpression`
97 Location of the file containing serialized configuration in YAML
98 format.
99
100 Returns
101 -------
102 config : `ApdbConfig`
103 Apdb configuration object.
104 """
105 if isinstance(uri, str) and uri.startswith("label:"):
106 tag, _, label = uri.partition(":")
107 index = ApdbIndex()
108 # Try to find YAML format first, and pex_config if YAML is not
109 # found. During transitional period we support conversion of
110 # pex_config format to a new pydantic format.
111 try:
112 uri = index.get_apdb_uri(label, "yaml")
113 except ValueError as yaml_exc:
114 try:
115 uri = index.get_apdb_uri(label, "pex_config")
116 except ValueError:
117 # If none is found then re-raise exception from yaml
118 # attempt, but add a note that pex_config is missing too.
119 yaml_exc.add_note(f"Legacy label {label}/pex_config is also missing.")
120 raise yaml_exc from None
121
122 path = ResourcePath(uri)
123 config_bytes = path.read()
124
125 # During transitional period we support loading of configurations from
126 # both pex_config and pydantic/YAML formats. We have to look at the
127 # contents for figure out which is which.
128 if config_bytes.startswith(b"import lsst.dax.apdb"):
129 from . import legacy_config
130
131 pex_config = legacy_config.ApdbConfig.legacy_load(config_bytes)
132 new_config = pex_config.to_model()
133 warnings.warn(
134 (
135 f"APDB is instantiated using legacy pex_config format from file {path}. "
136 "Support for pex_config format will be removed after v29. Please update "
137 "configuration to new YAML format with `apdb-cli convert-legacy-config` command."
138 ),
139 category=FutureWarning,
140 stacklevel=2,
141 )
142 return new_config
143
144 config_object = yaml.full_load(config_bytes)
145 if not isinstance(config_object, Mapping):
146 raise TypeError("YAML configuration file does not represent valid object")
147 config_dict: dict[str, Any] = dict(config_object)
148 type_name = config_dict.pop("implementation_type", None)
149 if not type_name:
150 raise LookupError("YAML configuration file does not have `implementation_type` key")
151 klass = config_type_for_name(cast(str, type_name))
152 return klass.model_validate(config_dict)
153

◆ save()

None lsst.dax.apdb.config.ApdbConfig.save ( self,
ResourcePathExpression uri )
inherited
Save configuration to a specified location in YAML format.

Parameters
----------
uri : `ResourcePathExpression`
    Location to save configuration

Definition at line 154 of file config.py.

154 def save(self, uri: ResourcePathExpression) -> None:
155 """Save configuration to a specified location in YAML format.
156
157 Parameters
158 ----------
159 uri : `ResourcePathExpression`
160 Location to save configuration
161 """
162 config_dict = self.model_dump(exclude_unset=True, exclude_defaults=True)
163 config_dict["implementation_type"] = self._implementation_type
164 config_yaml = yaml.dump(config_dict)
165
166 path = ResourcePath(uri)
167 path.write(config_yaml.encode())

Member Data Documentation

◆ _implementation_type

ClassVar lsst.dax.apdb.config.ApdbConfig._implementation_type [str]
staticprotectedinherited

Definition at line 47 of file config.py.

◆ batch_size_limit

int lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.batch_size_limit
static
Initial value:
= Field(
default=1_000_000,
description=(
"Limit on a size of BatchStatement in bytes. Batch size is estimated approximately. "
"Set to 0 or negative to disable this limit. "
"Server-side batch size warning threshold needs to be set to at least this value."
),
)

Definition at line 241 of file config.py.

◆ batch_statement_limit

int lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.batch_statement_limit
static
Initial value:
= Field(
default=65_535,
description=(
"Limit on a number of rows in a BatchStatement. Default is the same as Cassandra limit of 65535."
),
)

Definition at line 234 of file config.py.

◆ connection_config

ApdbCassandraConnectionConfig lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.connection_config
static
Initial value:
= Field(
default_factory=ApdbCassandraConnectionConfig,
description="Database connection configuration",
)

Definition at line 196 of file config.py.

◆ contact_points

tuple lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.contact_points
static
Initial value:
= Field(
default=("127.0.0.1",),
description="The list of contact points to try connecting for cluster discovery.",
)

Definition at line 186 of file config.py.

◆ dia_object_columns

list lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.dia_object_columns
static
Initial value:
= Field(
default=[],
description="List of columns to read from DiaObject[Last], by default read all columns.",
)

Definition at line 206 of file config.py.

◆ enable_replica

bool lsst.dax.apdb.config.ApdbConfig.enable_replica
staticinherited
Initial value:
= Field(
default=False,
description="If True, make and fill additional tables used for replication.",
)

Definition at line 78 of file config.py.

◆ keyspace

str lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.keyspace
static
Initial value:
= Field(
default="apdb",
description="Keyspace name for APDB tables.",
)

Definition at line 191 of file config.py.

◆ partitioning

ApdbCassandraPartitioningConfig lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.partitioning
static
Initial value:
= Field(
default_factory=ApdbCassandraPartitioningConfig,
description="Configuration for partitioning.",
)

Definition at line 201 of file config.py.

◆ prefix

str lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.prefix
static
Initial value:
= Field(
default="",
description="Prefix to add to table names.",
)

Definition at line 211 of file config.py.

◆ ra_dec_columns

tuple lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.ra_dec_columns
static
Initial value:
= Field(
default=("ra", "dec"),
description="Names of ra/dec columns in DiaObject table",
)

Definition at line 216 of file config.py.

◆ read_forced_sources_months

int lsst.dax.apdb.config.ApdbConfig.read_forced_sources_months
staticinherited
Initial value:
= Field(
default=12,
description="Number of months of history to read from DiaForcedSource",
)

Definition at line 73 of file config.py.

◆ read_sources_months

int lsst.dax.apdb.config.ApdbConfig.read_sources_months
staticinherited
Initial value:
= Field(
default=12,
description="Number of months of history to read from DiaSource.",
)

Definition at line 68 of file config.py.

◆ replica_chunk_seconds

int lsst.dax.apdb.config.ApdbConfig.replica_chunk_seconds
staticinherited
Initial value:
= Field(
default=600,
description=(
"Time extent for replica chunks, new chunks are created every specified number of seconds."
),
)

Definition at line 83 of file config.py.

◆ replica_skips_diaobjects

bool lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.replica_skips_diaobjects
static
Initial value:
= Field(
default=False,
description=(
"If True then do not store DiaObjects when enable_replica is True "
"(DiaObjectsChunks has the same data)."
),
)

Definition at line 221 of file config.py.

◆ replica_sub_chunk_count

int lsst.dax.apdb.cassandra.config.ApdbCassandraConfig.replica_sub_chunk_count
static
Initial value:
= Field(
default=64,
description="Number of sub-partitions in replica chunk tables.",
)

Definition at line 229 of file config.py.

◆ schema_file

str lsst.dax.apdb.config.ApdbConfig.schema_file
staticinherited
Initial value:
= Field(
default="resource://lsst.sdm.schemas/apdb.yaml",
description="Location of (YAML) configuration file with standard APDB schema.",
)

Definition at line 49 of file config.py.

◆ schema_name

str lsst.dax.apdb.config.ApdbConfig.schema_name
staticinherited
Initial value:
= Field(
default="ApdbSchema",
description="Name of the schema in YAML configuration file (not used and deprecated).",
)

Definition at line 63 of file config.py.

◆ ss_schema_file

str lsst.dax.apdb.config.ApdbConfig.ss_schema_file
staticinherited
Initial value:
= Field(
default="resource://lsst.sdm.schemas/sso.yaml",
description=(
"Location of (YAML) configuration file with SSO schema. "
"This file is only loaded if SSObject/SSSource tables are not present in APDB schema file. "
"Can be set to empty string to avoid loading even if tables are not in APDB schema."
),
)

Definition at line 54 of file config.py.


The documentation for this class was generated from the following file: