laniakea.db package¶
Submodules¶
laniakea.db.archive module¶
- class laniakea.db.archive.ArchiveArchitecture(name)¶
Bases:
BaseA system architecture software can be compiled for. Usually associated with an :ArchiveSuite
- pkgs_binary: Mapped[list[BinaryPackage]]¶
- suites: Mapped[list[ArchiveSuite]]¶
- class laniakea.db.archive.ArchiveComponent(name)¶
Bases:
BaseInformation about an archive component within a suite.
- is_nonfree()¶
- is_primary()¶
- parent_component: Mapped[ArchiveComponent]¶
- suites: Mapped[list[ArchiveSuite]]¶
- class laniakea.db.archive.ArchiveConfig(**kwargs)¶
Bases:
BaseGeneral archive configuration that applies to all repositories and suites.
- primary_repo: Mapped[ArchiveRepository]¶
- exception laniakea.db.archive.ArchiveError¶
Bases:
ExceptionSome issue occurred with the package archive.
- class laniakea.db.archive.ArchiveFile(fname, repo=None)¶
Bases:
BaseA file in the archive.
- property absolute_repo_path: str | PathLike¶
Absolute path to the file in its repository.
NOTE: Files may also be in the queue directory of a repository, if they are pending review.
- make_url(urlbase)¶
- pkg_binary: Mapped[BinaryPackage]¶
- pkgs_source: Mapped[list[SourcePackage]]¶
- repo: Mapped[ArchiveRepository]¶
- class laniakea.db.archive.ArchiveQueueNewEntry(spkg, dest)¶
Bases:
BaseQueue for package NEW processing.
- destination: Mapped[ArchiveSuite]¶
- package: Mapped[SourcePackage]¶
- class laniakea.db.archive.ArchiveRepoSuiteSettings(repo, suite)¶
Bases:
BaseSettings that are specific to a suite in a particular repository, but will not apply to the suite globally.
- repo: Mapped[ArchiveRepository]¶
- suite: Mapped[ArchiveSuite]¶
- class laniakea.db.archive.ArchiveRepository(name)¶
Bases:
BaseA repository of packages.
- debug_repo_for: Mapped[ArchiveRepository]¶
- suite_settings: Mapped[list[ArchiveRepoSuiteSettings]]¶
- uploaders: Mapped[list[ArchiveUploader]]¶
- class laniakea.db.archive.ArchiveSection(name, title, summary=None)¶
Bases:
BaseKnown sections in the archive that packages are sorted into. See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections for reference.
- class laniakea.db.archive.ArchiveSuite(name, alias=None)¶
Bases:
BaseInformation about suite in a distribution repository.
- architectures: Mapped[list[ArchiveArchitecture]]¶
- components: Mapped[list[ArchiveComponent]]¶
- dbgsym_policy: Mapped[DbgSymPolicy]¶
- debug_suite: Mapped[ArchiveSuite | None]¶
- debug_suite_for: Mapped[ArchiveSuite | None]¶
- parents: Mapped[list[ArchiveSuite]]¶
- pkgs_binary: Mapped[list[BinaryPackage]]¶
- pkgs_source: Mapped[list[SourcePackage]]¶
- property primary_architecture¶
- repo_settings: Mapped[list[ArchiveRepoSuiteSettings]]¶
- class laniakea.db.archive.ArchiveUploader(email)¶
Bases:
BaseEntities who are permitted to upload data to archive repositories.
- repos: Mapped[list[ArchiveRepository]]¶
- class laniakea.db.archive.ArchiveVersionMemory(**kwargs)¶
Bases:
BaseRemember the highest version number for a source package that a repository has seen.
- highest_version: Mapped[DebVersion]¶
- repo_suite: Mapped[ArchiveRepoSuiteSettings]¶
- class laniakea.db.archive.BinaryPackage(name, version, repo=None)¶
Bases:
BaseData of a binary package.
- architecture: Mapped[ArchiveArchitecture]¶
- bin_file: Mapped[ArchiveFile]¶
- component: Mapped[ArchiveComponent]¶
- static generate_uuid(repo_name, name, version, arch_name)¶
- repo: Mapped[ArchiveRepository]¶
- source: Mapped[SourcePackage]¶
- suites: Mapped[list[ArchiveSuite]]¶
- sw_cpts: Mapped[list[SoftwareComponent]]¶
- update_uuid()¶
- class laniakea.db.archive.ChangesUrgency(*values)¶
Bases:
EnumUrgency for how important it is to upgrade to a new package version from previous ones. https://www.debian.org/doc/debian-policy/ch-controlfields.html#urgency
- CRITICAL = 4¶
- EMERGENCY = 5¶
- HIGH = 3¶
- LOW = 1¶
- MEDIUM = 2¶
- UNKNOWN = 0¶
- static from_string(s)¶
Convert the text representation into the enumerated type.
- Return type:
- to_string()¶
- class laniakea.db.archive.DbgSymPolicy(*values)¶
Bases:
EnumPolicy for debug symbol handling for suites.
- DEBUG_ALLOWED = 3¶
- INVALID = 0¶
- NO_DEBUG = 1¶
- ONLY_DEBUG = 2¶
- static from_string(s)¶
Convert the text representation into the enumerated type.
- Return type:
- to_string()¶
- class laniakea.db.archive.DebType(*values)¶
Bases:
IntEnumType of the Debian package.
- DEB = 1¶
- UDEB = 2¶
- UNKNOWN = 0¶
- static from_string(s)¶
Convert the text representation into the enumerated type.
- Return type:
- static to_string(e)¶
- class laniakea.db.archive.NewPolicy(*values)¶
Bases:
EnumPolicy for how new packages are processed.
- ALWAYS_NEW = 2¶
- DEFAULT = 1¶
- INVALID = 0¶
- NEVER_NEW = 3¶
- static from_string(s)¶
Convert the text representation into the enumerated type.
- Return type:
- to_string()¶
- class laniakea.db.archive.PackageInfo(deb_type=DebType.DEB, name=None, version=None, component='main', section=None, essential=False, priority=PackagePriority.UNKNOWN, architectures=None)¶
Bases:
objectBasic package information, used by :SourcePackage to refer to binary packages.
- priority: PackagePriority = 0¶
- class laniakea.db.archive.PackageOverride(pkgname, repo, suite)¶
Bases:
BaseOverridable “archive organization” data of a binary package.
- component: Mapped[ArchiveComponent]¶
- priority: Mapped[PackagePriority]¶
- repo: Mapped[ArchiveRepository]¶
- section: Mapped[ArchiveSection]¶
- suite: Mapped[ArchiveSuite]¶
- class laniakea.db.archive.PackagePriority(*values)¶
Bases:
IntEnumPriority of a Debian package.
- EXTRA = 5¶
- IMPORTANT = 2¶
- OPTIONAL = 4¶
- REQUIRED = 1¶
- STANDARD = 3¶
- UNKNOWN = 0¶
- static from_string(s)¶
Convert the text representation into the enumerated type.
- Return type:
- static to_string(e)¶
- class laniakea.db.archive.PackageType(*values)¶
Bases:
EnumType of the package.
- BINARY = 2¶
- SOURCE = 1¶
- UNKNOWN = 0¶
- static from_string(s)¶
Convert the text representation into the enumerated type.
- Return type:
- static to_string(e)¶
- class laniakea.db.archive.SoftwareComponent(**kwargs)¶
Bases:
BaseDescription of a software component as described by the AppStream specification.
- flatpakref: Mapped[FlatpakRef]¶
- pkgs_binary: Mapped[list[BinaryPackage]]¶
- update_uuid()¶
Update the unique identifier for this component.
- static uuid_for_gcid(gcid)¶
Create an entity UUID from a component GCID
- class laniakea.db.archive.SourcePackage(name, version, repo=None)¶
Bases:
BaseData of a source package.
- binaries: Mapped[list[BinaryPackage]]¶
- changes_urgency: Mapped[ChangesUrgency]¶
- component: Mapped[ArchiveComponent]¶
- property dsc_file: ArchiveFile | None¶
- property expected_binaries: list[PackageInfo]¶
- files: Mapped[list[ArchiveFile]]¶
- static generate_source_uuid(repo_name, name)¶
- static generate_uuid(repo_name, name, version)¶
- get_metadata_dir(lconf=None)¶
Get the metadata storage location for this package.
- mark_remove()¶
Mark this source package for removal during next maintenance run.
- repo: Mapped[ArchiveRepository]¶
- section: Mapped[ArchiveSection]¶
- suites: Mapped[list[ArchiveSuite]]¶
- update_source_uuid()¶
- update_uuid()¶
- laniakea.db.archive.package_version_compare(pkg1, pkg2)¶
Comparison function helper to compare package versions.
laniakea.db.base module¶
- class laniakea.db.base.Base(**kwargs)¶
Bases:
objectThe base class of the class hierarchy.
When called, it accepts no arguments and returns a new featureless instance that has no instance attributes and cannot be given any.
- metadata = MetaData()¶
- registry = <sqlalchemy.orm.decl_api.registry object>¶
- class laniakea.db.base.DebVersion¶
Bases:
UserDefinedType- bind_processor(dialect)¶
Return a conversion function for processing bind values.
Returns a callable which will receive a bind parameter value as the sole positional argument and will return a value to send to the DB-API.
If processing is not necessary, the method should return
None.Tip
This method is only called relative to a dialect specific type object, which is often private to a dialect in use and is not the same type object as the public facing one, which means it’s not feasible to subclass a
types.TypeEngineclass in order to provide an alternate_types.TypeEngine.bind_processor()method, unless subclassing the_types.UserDefinedTypeclass explicitly.To provide alternate behavior for
_types.TypeEngine.bind_processor(), implement a_types.TypeDecoratorclass and provide an implementation of_types.TypeDecorator.process_bind_param().See also
types_typedecorator
- Parameters:
dialect – Dialect instance in use.
- cache_ok: bool | None = True¶
Indicate if statements using this
ExternalTypeare “safe to cache”.The default value
Nonewill emit a warning and then not allow caching of a statement which includes this type. Set toFalseto disable statements using this type from being cached at all without a warning. When set toTrue, the object’s class and selected elements from its state will be used as part of the cache key. For example, using aTypeDecorator:class MyType(TypeDecorator): impl = String cache_ok = True def __init__(self, choices): self.choices = tuple(choices) self.internal_only = True
The cache key for the above type would be equivalent to:
>>> MyType(["a", "b", "c"])._static_cache_key (<class '__main__.MyType'>, ('choices', ('a', 'b', 'c')))
The caching scheme will extract attributes from the type that correspond to the names of parameters in the
__init__()method. Above, the “choices” attribute becomes part of the cache key but “internal_only” does not, because there is no parameter named “internal_only”.The requirements for cacheable elements is that they are hashable and also that they indicate the same SQL rendered for expressions using this type every time for a given cache value.
To accommodate for datatypes that refer to unhashable structures such as dictionaries, sets and lists, these objects can be made “cacheable” by assigning hashable structures to the attributes whose names correspond with the names of the arguments. For example, a datatype which accepts a dictionary of lookup values may publish this as a sorted series of tuples. Given a previously un-cacheable type as:
class LookupType(UserDefinedType): """a custom type that accepts a dictionary as a parameter. this is the non-cacheable version, as "self.lookup" is not hashable. """ def __init__(self, lookup): self.lookup = lookup def get_col_spec(self, **kw): return "VARCHAR(255)" def bind_processor(self, dialect): ... # works with "self.lookup" ...
Where “lookup” is a dictionary. The type will not be able to generate a cache key:
>>> type_ = LookupType({"a": 10, "b": 20}) >>> type_._static_cache_key <stdin>:1: SAWarning: UserDefinedType LookupType({'a': 10, 'b': 20}) will not produce a cache key because the ``cache_ok`` flag is not set to True. Set this flag to True if this type object's state is safe to use in a cache key, or False to disable this warning. symbol('no_cache')
If we did set up such a cache key, it wouldn’t be usable. We would get a tuple structure that contains a dictionary inside of it, which cannot itself be used as a key in a “cache dictionary” such as SQLAlchemy’s statement cache, since Python dictionaries aren’t hashable:
>>> # set cache_ok = True >>> type_.cache_ok = True >>> # this is the cache key it would generate >>> key = type_._static_cache_key >>> key (<class '__main__.LookupType'>, ('lookup', {'a': 10, 'b': 20})) >>> # however this key is not hashable, will fail when used with >>> # SQLAlchemy statement cache >>> some_cache = {key: "some sql value"} Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'dict'
The type may be made cacheable by assigning a sorted tuple of tuples to the “.lookup” attribute:
class LookupType(UserDefinedType): """a custom type that accepts a dictionary as a parameter. The dictionary is stored both as itself in a private variable, and published in a public variable as a sorted tuple of tuples, which is hashable and will also return the same value for any two equivalent dictionaries. Note it assumes the keys and values of the dictionary are themselves hashable. """ cache_ok = True def __init__(self, lookup): self._lookup = lookup # assume keys/values of "lookup" are hashable; otherwise # they would also need to be converted in some way here self.lookup = tuple((key, lookup[key]) for key in sorted(lookup)) def get_col_spec(self, **kw): return "VARCHAR(255)" def bind_processor(self, dialect): ... # works with "self._lookup" ...
Where above, the cache key for
LookupType({"a": 10, "b": 20})will be:>>> LookupType({"a": 10, "b": 20})._static_cache_key (<class '__main__.LookupType'>, ('lookup', (('a', 10), ('b', 20))))
Added in version 1.4.14: - added the
cache_okflag to allow some configurability of caching forTypeDecoratorclasses.Added in version 1.4.28: - added the
ExternalTypemixin which generalizes thecache_okflag to both theTypeDecoratorandUserDefinedTypeclasses.See also
sql_caching
- get_col_spec(**kw)¶
- result_processor(dialect, coltype)¶
Return a conversion function for processing result row values.
Returns a callable which will receive a result row column value as the sole positional argument and will return a value to return to the user.
If processing is not necessary, the method should return
None.Tip
This method is only called relative to a dialect specific type object, which is often private to a dialect in use and is not the same type object as the public facing one, which means it’s not feasible to subclass a
types.TypeEngineclass in order to provide an alternate_types.TypeEngine.result_processor()method, unless subclassing the_types.UserDefinedTypeclass explicitly.To provide alternate behavior for
_types.TypeEngine.result_processor(), implement a_types.TypeDecoratorclass and provide an implementation of_types.TypeDecorator.process_result_value().See also
types_typedecorator
- Parameters:
dialect – Dialect instance in use.
coltype – DBAPI coltype argument received in cursor.description.
- class laniakea.db.base.UUID(as_uuid=True)¶
Bases:
Uuid,NativeForEmulatedRepresent the SQL UUID type.
This is the SQL-native form of the
_types.Uuiddatabase agnostic datatype, and is backwards compatible with the previous PostgreSQL-only version ofUUID.The
_sqltypes.UUIDdatatype only works on databases that have a SQL datatype namedUUID. It will not function for backends which don’t have this exact-named type, including SQL Server. For backend-agnostic UUID values with native support, including for SQL Server’sUNIQUEIDENTIFIERdatatype, use the_sqltypes.Uuiddatatype.Added in version 2.0.
See also
_sqltypes.Uuid- classmethod adapt_emulated_to_native(impl, **kw)¶
Given an impl, adapt this type’s class to the impl assuming “native”.
The impl will be an
Emulatedclass but not aNativeForEmulated.e.g.: postgresql.ENUM produces a type given an Enum instance.
- laniakea.db.base.create_tsvector(*args)¶
- laniakea.db.base.print_query(query, literals=True)¶
Print a SQLAlchemy query with literals inserted and adjusted for the PostgreSQL dialect.
- laniakea.db.base.session_scope(*, autoflush=True)¶
Provide a transactional scope around a series of operations.
laniakea.db.core module¶
- class laniakea.db.core.ConfigEntry(mod, identifier, value=None)¶
Bases:
BaseA generic, multi-purpose configuration entry.
- set_value(mod, key, value)¶
- class laniakea.db.core.LkModule¶
Bases:
objectString identifiers of Laniakea modules.
- ADMINCLI = 'admin-cli'¶
- ARCHIVE = 'archive'¶
- ARIADNE = 'ariadne'¶
- BASE = 'core'¶
- DEBCHECK = 'debcheck'¶
- ISOTOPE = 'isotope'¶
- KEYTOOL = 'keytool'¶
- LIGHTHOUSE = 'lighthouse'¶
- PLANTER = 'planter'¶
- RUBICON = 'rubicon'¶
- SPEARS = 'spears'¶
- SYNCHROTRON = 'synchrotron'¶
- TESTSUITE = 'test'¶
- UNKNOWN = ''¶
- WEBDASH = 'webdash'¶
- WEBSWVIEW = 'webswview'¶
- laniakea.db.core.config_get_distro_tag()¶
Retrieve version tag for this distribution (“pureos”, “tanglu”, …) - will usually be part of a package version, e.g. “1.0-0tanglu1”
- laniakea.db.core.config_get_project_name()¶
Get the name of the distribution or project (“Tanglu”, “PureOS”, …)
- laniakea.db.core.config_get_value(mod, key)¶
Get a value from the configuration store.
- laniakea.db.core.config_set_distro_tag(value)¶
Set version tag for this distribution (“pureos”, “tanglu”, …) - will usually be part of a package version, e.g. “1.0-0tanglu1”
- laniakea.db.core.config_set_project_name(value)¶
Set the name of the distribution or project (“Tanglu”, “PureOS”, …)
- laniakea.db.core.config_set_value(mod, key, value)¶
Set a value in the configuration store
laniakea.db.debcheck module¶
- class laniakea.db.debcheck.DebcheckIssue(**kwargs)¶
Bases:
BaseData for a package migration excuse, as emitted by Britney
- property conflicts¶
- static generate_uuid(issue, repo, suite)¶
Issue entities have a UUID based on a set of data, this function generates the UUID.
- property missing¶
- package_type: Mapped[PackageType]¶
- package_version: Mapped[DebVersion]¶
- repo: Mapped[ArchiveRepository]¶
- suite: Mapped[ArchiveSuite]¶
- update_uuid(repo=None, suite=None)¶
- class laniakea.db.debcheck.PackageConflict(*, only=None, exclude=(), many=None, load_only=(), dump_only=(), partial=None, unknown=None)¶
Bases:
SchemaInformation about a conflict between packages.
- class laniakea.db.debcheck.PackageIssue(*, only=None, exclude=(), many=None, load_only=(), dump_only=(), partial=None, unknown=None)¶
Bases:
SchemaInformation about the package issue reason.
- package_type: PackageType¶
laniakea.db.flatpak module¶
- class laniakea.db.flatpak.FlatpakRef(**kwargs)¶
Bases:
BaseFlatpak object/app/runtime reference.
- architecture: Mapped[ArchiveArchitecture]¶
- kind: Mapped[FlatpakRefKind]¶
- repo: Mapped[FlatpakRepository]¶
- version: Mapped[DebVersion]¶
- class laniakea.db.flatpak.FlatpakRefKind(*values)¶
Bases:
EnumKind of a Flatpak Ref.
- APP = 2¶
- RUNTIME = 3¶
- UNKNOWN = 1¶
- to_string()¶
laniakea.db.isotope module¶
- class laniakea.db.isotope.ImageBuildRecipe(**kwargs)¶
Bases:
BaseInstructions on how to do an automatic ISO image build.
- format: Mapped[ImageFormat]¶
laniakea.db.jobs module¶
- class laniakea.db.jobs.Job(**kwargs)¶
Bases:
BaseA task to be performed (e.g. by a Spark worker)
- has_result()¶
- is_failed()¶
- is_taken()¶
- suite: Mapped[ArchiveSuite]¶
- version: Mapped[DebVersion]¶
- class laniakea.db.jobs.JobKind¶
Bases:
objectThe different job kind identifier strings used by the different Laniakea modules which can enqueue jobs.
- OS_IMAGE_BUILD = 'os-image-build'¶
- PACKAGE_BUILD = 'package-build'¶
laniakea.db.spears module¶
- class laniakea.db.spears.SpearsExcuse(**kwargs)¶
Bases:
BaseData for a package migration excuse, as emitted by Britney
- get_manual_block_hints()¶
- get_old_binaries()¶
- make_idname()¶
- migration_task: Mapped[SpearsMigrationTask]¶
- set_old_binaries(obins)¶
- source_package: Mapped[SourcePackage]¶
- class laniakea.db.spears.SpearsHint(**kwargs)¶
Bases:
BaseUser-defined hints for Britney.
- migration_task: Mapped[SpearsMigrationTask]¶
- class laniakea.db.spears.SpearsMigrationTask(**kwargs)¶
Bases:
BaseDescription of a migration task from one or multiple suites to a target.
- make_migration_shortname()¶
get a short name for this migration that can be used in file paths.
- Return type:
- make_migration_unique_name()¶
Get a unique identifier for this migration task
- repo: Mapped[ArchiveRepository]¶
- source_suites: Mapped[list[ArchiveSuite]]¶
- property source_suites_str: str¶
Get a string identifying the source suites packages are migrated from.
- target_suite: Mapped[ArchiveSuite]¶
laniakea.db.synchrotron module¶
- class laniakea.db.synchrotron.SyncBlacklistEntry(**kwargs)¶
Bases:
BaseSynchrotron blacklist
- config: Mapped[SynchrotronConfig]¶
- class laniakea.db.synchrotron.SynchrotronConfig(**kwargs)¶
Bases:
BaseConfiguration for automatic synchrotron tasks.
- destination_suite: Mapped[ArchiveSuite]¶
- repo: Mapped[ArchiveRepository]¶
- source: Mapped[SynchrotronSource]¶
- class laniakea.db.synchrotron.SynchrotronIssue(**kwargs)¶
Bases:
BaseHints about why packages are not synchronized with a source distribution/suite.
- config: Mapped[SynchrotronConfig]¶
- kind: Mapped[SynchrotronIssueKind]¶
- source_version: Mapped[DebVersion]¶
- target_version: Mapped[DebVersion]¶
laniakea.db.workers module¶
- class laniakea.db.workers.SparkWorker(**kwargs)¶
Bases:
BaseAn external machine/service that takes tasks from a Lighthouse server.
- status: Mapped[WorkerStatus]¶