thoth.storages.graph package

Submodules

thoth.storages.graph.enums module

Enum types used in thoth-storages code.

class thoth.storages.graph.enums.EnvironmentTypeEnum(value)[source]

Bases: enum.Enum

Class for the environment types.

BUILDTIME = 'BUILDTIME'
RUNTIME = 'RUNTIME'
class thoth.storages.graph.enums.InspectionSyncStateEnum(value)[source]

Bases: enum.Enum

Class for the inspection syncs state.

PENDING = 'PENDING'
SYNCED = 'SYNCED'
class thoth.storages.graph.enums.KebechetManagerEnum(value)[source]

Bases: enum.Enum

Class for Kebechet manager enum.

INFO_MANAGER = 1
PIPFILE_REQUIREMENTS_MANAGER = 2
THOTH_ADVISE_MANAGER = 5
THOTH_PROVENANCE_MANAGER = 6
UPDATE_MANAGER = 3
VERSION_MANAGER = 4
class thoth.storages.graph.enums.MetadataDistutilsTypeEnum(value)[source]

Bases: enum.Enum

Class for the requirements format.

OBSOLETE = 'OBSOLETE'
PROVIDED = 'PROVIDED'
REQUIRED = 'REQUIRED'
class thoth.storages.graph.enums.PlatformEnum(value)[source]

Bases: enum.Enum

Class for platform enum.

LINUX_X86_64 = 'linux-x86_64'
class thoth.storages.graph.enums.QuerySortTypeEnum(value)[source]

Bases: enum.Enum

Class for the requirements format.

PACKAGE_NAME = 'package_name'
PACKAGE_VERSION = 'package_version'
class thoth.storages.graph.enums.RecommendationTypeEnum(value)[source]

Bases: enum.Enum

Class for the reccomendation type.

LATEST = 'LATEST'
PERFORMANCE = 'PERFORMANCE'
SECURITY = 'SECURITY'
STABLE = 'STABLE'
TESTING = 'TESTING'
class thoth.storages.graph.enums.RequirementsFormatEnum(value)[source]

Bases: enum.Enum

Class for the requirements format.

PIPENV = 'PIPENV'
class thoth.storages.graph.enums.SoftwareStackTypeEnum(value)[source]

Bases: enum.Enum

Class for the software stack types.

ADVISED = 'ADVISED'
INSPECTION = 'INSPECTION'
USER = 'USER'

thoth.storages.graph.models module

Models for SQL based database.

class thoth.storages.graph.models.Advised(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A relation stating advised software stack.

adviser_run
adviser_run_id
python_software_stack
python_software_stack_id
class thoth.storages.graph.models.AdviserRun(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A class representing a single adviser run.

additional_stack_info
advised_configuration_changes
advised_software_stacks
adviser_document_id
adviser_error
adviser_name
adviser_version
count
datetime
debug
duration
external_build_software_environment
external_build_software_environment_id
external_hardware_information
external_hardware_information_id
external_run_software_environment
external_run_software_environment_id
id
is_s2i
limit
limit_latest_versions
need_re_run
origin
python_package_version_entities
re_run_adviser_id
recommendation_type
requirements_format
source_type
user_software_stack
user_software_stack_id
class thoth.storages.graph.models.CVE(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Information about a CVE.

aggregated_at
cve_id
details
id
python_package_version_entities
class thoth.storages.graph.models.CVETimestamp(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Information about CVE aggregation maintained by cve-update-job.

id
timestamp
class thoth.storages.graph.models.DebDependency(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A Debian dependency.

deb_package_versions_depends
deb_package_versions_pre_depends
deb_package_versions_replaces
id
package_name
class thoth.storages.graph.models.DebDepends(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Depending relation of a deb package.

deb_dependency
deb_dependency_id
deb_package_version
deb_package_version_id
id
version_range
class thoth.storages.graph.models.DebPackageVersion(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Debian-specific package version.

arch
depends
epoch
id
package_extract_runs
package_name
package_version
pre_depends
replaces
class thoth.storages.graph.models.DebPreDepends(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Pre-depending relation of a deb package.

deb_dependency
deb_dependency_id
deb_package_version
deb_package_version_id
version_range
class thoth.storages.graph.models.DebReplaces(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A relation of a deb package capturing package replacement..

deb_dependency
deb_dependency_id
deb_package_version
deb_package_version_id
version_range
class thoth.storages.graph.models.DependencyMonkeyRun(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A class representing a single dependency-monkey run.

build_hardware_information
build_hardware_information_id
build_software_environment
build_software_environment_id
count
datetime
debug
decision
dependency_monkey_document_id
dependency_monkey_error
dependency_monkey_name
dependency_monkey_version
duration
id
inspection_runs
limit_latest_versions
python_package_requirements
run_hardware_information
run_hardware_information_id
run_software_environment
run_software_environment_id
seed
class thoth.storages.graph.models.DependsOn(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Dependency of a Python package version.

entity
entity_id
extra
marker
marker_evaluation_result
version
version_id
version_range
class thoth.storages.graph.models.DetectedSymbol(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A relation stating a package extract run detected a symbol.

package_extract_run
package_extract_run_id
versioned_symbol
versioned_symbol_id
class thoth.storages.graph.models.EcosystemSolver(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Record for an ecosystem solver.

ecosystem
id
os_name
os_version
python_version
solver_name
solver_version
versions
class thoth.storages.graph.models.ExternalHardwareInformation(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

External Hardware information base class to derive for specific HW environments.

adviser_runs
cpu_cores
cpu_family
cpu_model
cpu_model_name
cpu_physical_cpus
cpu_vendor
gpu_cores
gpu_memory_size
gpu_model_name
gpu_vendor
id
ram_size
class thoth.storages.graph.models.ExternalPythonRequirements(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Requirements for a user software stack.

external_python_requirements
external_python_software_stack
id
requirements_hash
class thoth.storages.graph.models.ExternalPythonRequirementsLock(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A pinned down requirements for a user application.

external_python_requirements_locks
external_python_software_stack
id
requirements_lock_hash
class thoth.storages.graph.models.ExternalPythonSoftwareStack(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A Python software stack definition from users.

adviser_runs
external_python_package_requirements
external_python_requirements_id
external_python_requirements_lock
external_python_requirements_lock_id
id
kebechet_github_installation
provenance_checker_runs
class thoth.storages.graph.models.ExternalSoftwareEnvironment(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A base class for environment types.

adviser_inputs_build
adviser_inputs_run
cuda_version
env_image_name
env_image_tag
environment_name
environment_type
external_package_extract_runs
id
image_name
image_sha
kebechet_github_installation
os_name
os_version
python_version
thoth_image_name
thoth_image_version
versioned_symbols
class thoth.storages.graph.models.FoundDeb(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

State a package extract run found a Debian package.

deb_package_version
deb_package_version_id
package_extract_run
package_extract_run_id
class thoth.storages.graph.models.FoundImportPackage(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

State an PPV for import package.

import_package
import_package_id
python_package_version
python_package_version_id
class thoth.storages.graph.models.FoundPythonFile(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

State a package extract run found a Python file.

file
package_extract_run
package_extract_run_id
python_file_digest
python_file_digest_id
class thoth.storages.graph.models.FoundPythonInterpreter(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

State a package extract run found a Python interpreter.

package_extract_run
package_extract_run_id
python_interpreter
python_interpreter_id
class thoth.storages.graph.models.FoundRPM(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

State a package extract run found an RPM package.

package_extract_run
package_extract_run_id
rpm_package_version
rpm_package_version_id
class thoth.storages.graph.models.HardwareInformation(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Hardware information base class to derive for specific HW environments.

cpu_cores
cpu_family
cpu_model
cpu_model_name
cpu_physical_cpus
cpu_vendor
dependency_monkey_runs_build
dependency_monkey_runs_run
gpu_cores
gpu_memory_size
gpu_model_name
gpu_vendor
id
inspection_runs_build
inspection_runs_run
ram_size
class thoth.storages.graph.models.HasArtifact(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The given package has the given artifact.

python_artifact
python_artifact_id
python_package_version_entity
python_package_version_entity_id
class thoth.storages.graph.models.HasExternalPythonRequirements(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The requirement from user Pipfile.

external_python_package_requirement
external_python_requirements_id
external_requirements
python_package_requirement_id
class thoth.storages.graph.models.HasExternalPythonRequirementsLock(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The requirement from Pipfile.lock.

external_python_requirements_lock
external_python_requirements_locked_id
python_package_version_entity
python_package_version_entity_id
class thoth.storages.graph.models.HasMetadataClassifier(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The Python package has the given classifier in the metadata.

python_package_metadata
python_package_metadata_classifier_id
python_package_metadata_classifiers
python_package_metadata_id
class thoth.storages.graph.models.HasMetadataDistutils(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The Python package has the given distutils in the metadata.

python_package_metadata
python_package_metadata_distutils
python_package_metadata_distutils_id
python_package_metadata_id
class thoth.storages.graph.models.HasMetadataPlatform(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The Python package has the given platform in the metadata.

python_package_metadata
python_package_metadata_id
python_package_metadata_platform_id
python_package_metadata_platforms
class thoth.storages.graph.models.HasMetadataProjectUrl(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The Python package has the given project URL in the metadata.

python_package_metadata
python_package_metadata_id
python_package_metadata_project_url_id
python_package_metadata_project_urls
class thoth.storages.graph.models.HasMetadataProvidesExtra(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The Python package has the given optional feature in the metadata.

python_package_metadata
python_package_metadata_id
python_package_metadata_provides_extra_id
python_package_metadata_provides_extras
class thoth.storages.graph.models.HasMetadataRequiresExternal(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The Python package has the given dependency in the metadata.

python_package_metadata
python_package_metadata_id
python_package_metadata_requires_external_id
python_package_metadata_requires_externals
class thoth.storages.graph.models.HasMetadataSupportedPlatform(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The Python package has the given supported platform in the metadata.

python_package_metadata
python_package_metadata_id
python_package_metadata_supported_platform_id
python_package_metadata_supported_platforms
class thoth.storages.graph.models.HasPythonRequirements(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The requirement from Pipfile.

python_package_requirement
python_package_requirement_id
python_requirements
python_requirements_id
class thoth.storages.graph.models.HasPythonRequirementsLock(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The requirement from Pipfile.lock.

python_package_version
python_package_version_id
python_requirements_lock
python_requirements_lock_id
class thoth.storages.graph.models.HasSymbol(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A relation stating a software environment has a symbol.

external_software_environment
external_software_environment_id
software_environment
software_environment_id
versioned_symbol
versioned_symbol_id
class thoth.storages.graph.models.HasUnresolved(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A relation representing a Python package version entity unresolved identified in adviser run.

adviser_run
adviser_run_id
python_package_version_entity
python_package_version_entity_id
class thoth.storages.graph.models.HasVulnerability(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

The given package version has a vulnerability.

cve
cve_id
python_package_version_entity
python_package_version_entity_id
class thoth.storages.graph.models.Identified(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A relation representing a Python package version identified by a package-extract run.

location
package_extract_run
package_extract_run_id
python_package_version_entity
python_package_version_entity_id
class thoth.storages.graph.models.ImportPackage(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Packages imported as a result of solver run.

id
import_package_name
python_package_versions
class thoth.storages.graph.models.IncludedFile(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A relation representing file found in the given artifact.

file
python_artifact
python_artifact_id
python_file_digest
python_file_digest_id
class thoth.storages.graph.models.InspectionRun(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A class representing a single inspection.

amun_version
build_hardware_information
build_hardware_information_id
build_requests_cpu
build_requests_memory
build_software_environment
build_software_environment_id
conv1d_perf_indicators
conv2d_perf_indicators
datetime
dependency_monkey_run
dependency_monkey_run_id
id
inspection_document_id
inspection_result_number
inspection_software_stack
inspection_software_stack_id
inspection_sync_state
matmul_perf_indicators
pybench_perf_indicators
run_hardware_information
run_hardware_information_id
run_requests_cpu
run_requests_memory
run_software_environment
run_software_environment_id
class thoth.storages.graph.models.KebechetGithubAppInstallations(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Kebechet Github App Installations.

slug = namespace/repository (ex - thoth-station/advisor) repo_name = repository (ex - advisor) private = True or False installation_id = provided by github (ex - 236821515)

advised_python_software_stack_id
advised_software_stack
external_python_software_stack_id
external_software_environment
external_software_environment_id
id
info_manager
installation_id
is_active
last_run
pipfile_requirements_manager
private
repo_name
runtime_environment_name
slug
thoth_advise_manager
thoth_provenance_manager
update_manager
user_software_stack
version_manager
class thoth.storages.graph.models.PackageExtractRun(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A class representing a single package-extract (image analysis) run.

analysis_document_id
datetime
debug
duration
environment_type
external_software_environment
external_software_environment_id
found_debs
found_python_files
found_python_interpreters
found_rpms
id
image_size
image_tag
origin
os_id
os_name
os_version_id
package_extract_error
package_extract_name
package_extract_version
python_package_version_entities
software_environment
software_environment_id
versioned_symbols
class thoth.storages.graph.models.ProvenanceCheckerRun(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A class representing a single provenance-checker run.

datetime
debug
duration
id
origin
provenance_checker_document_id
provenance_checker_error
provenance_checker_name
provenance_checker_version
user_software_stack
user_software_stack_id
class thoth.storages.graph.models.PythonArtifact(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

An artifact for a python package in a specific version.

artifact_hash_sha256
artifact_name
id
present
python_files
python_package_version_entities
versioned_symbols
class thoth.storages.graph.models.PythonDependencyMonkeyRequirements(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Requirements for a software stack as run on Dependency Monkey.

dependency_monkey_run
dependency_monkey_run_id
id
python_package_requirement
python_package_requirement_id
class thoth.storages.graph.models.PythonFileDigest(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A class representing a single file digests.

id
package_extract_runs
python_artifacts
sha256
class thoth.storages.graph.models.PythonInterpreter(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A class representing a single python interpreter.

id
package_extract_runs
path
version
class thoth.storages.graph.models.PythonPackageIndex(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Representation of a Python package Index.

enabled
id
only_if_package_seen
python_package_requirements
python_package_version_entities
python_package_versions
url
verify_ssl
warehouse_api_url
class thoth.storages.graph.models.PythonPackageLicense(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Representation of a License.

id
license_identifier
license_name
license_version
python_package_version
class thoth.storages.graph.models.PythonPackageMetadata(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Metadata extracted for a Python Package.

Source: https://packaging.python.org/specifications/core-metadata/

author
author_email
classifiers
description
description_content_type
distutils
download_url
home_page
id
keywords
license
maintainer
maintainer_email
metadata_version
name
platforms
project_urls
provides_extras
python_package_versions
requires_externals
requires_python
summary
supported_platforms
version
class thoth.storages.graph.models.PythonPackageMetadataClassifier(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Classification value (part of metadata) for the Python Package.

classifier
id
python_packages_metadata
class thoth.storages.graph.models.PythonPackageMetadataDistutils(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Distutils (part of metadata).

REQUIRED: it means that the distribution (Python package) requires it.

PROVIDED: it means that the distribution (Python package) has it.

OBSOLETE: it means that the distribution (Python package) renders obsolete. This means that the two projects should not be installed at the same time.

distutils
distutils_type
id
python_packages_metadata
class thoth.storages.graph.models.PythonPackageMetadataPlatform(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Platform (part of metadata) describing an operating system supported by the Python Package.

id
platform
python_packages_metadata
class thoth.storages.graph.models.PythonPackageMetadataProjectUrl(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Browsable URL (part of metadata) for the project of the Python Package and a label for it.

id
label
python_packages_metadata
url
class thoth.storages.graph.models.PythonPackageMetadataProvidesExtra(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Optional feature (part of metadata) for the Python Package.

May be used to make a dependency conditional on whether the optional feature has been requested.

id
optional_feature
python_packages_metadata
class thoth.storages.graph.models.PythonPackageMetadataRequiresExternal(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Dependency field (part of metadata) in the system that the distribution (Python package) is to be used.

This field is intended to serve as a hint to downstream project maintainers, and has no semantics which are meaningful to the distutils distribution.

dependency
id
python_packages_metadata
class thoth.storages.graph.models.PythonPackageMetadataSupportedPlatform(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Supported-Platform field (part of metadata) used in binary distributions containing a PKG-INFO file.

It is used to specify the OS and CPU for which the binary distribution was compiled.

id
python_packages_metadata
supported_platform
class thoth.storages.graph.models.PythonPackageRequirement(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A requirement as stated by a software stack.

dependency_monkey_runs
develop
external_python_requirement
id
index
name
python_package_index_id
python_requirement
version_range
class thoth.storages.graph.models.PythonPackageVersion(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Representation of a Python package version running on a specific software environment.

dependencies
entity
entity_id
id
import_packages
index
is_missing
licenses
os_name
os_version
package_license
package_license_warning
package_name
package_version
provides_source_distro
python_package_index_id
python_package_metadata
python_package_metadata_id
python_software_stacks
python_version
si_aggregated
solvers
class thoth.storages.graph.models.PythonPackageVersionEntity(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Representation of a Python package not running in any environment.

adviser_runs
cves
external_python_software_stacks
id
index
package_extract_runs
package_name
package_version
python_artifacts
python_package_index_id
python_package_versions
rules
si_aggregated_runs
versions
class thoth.storages.graph.models.PythonPackageVersionEntityRule(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Rules for packages which can occur in the system.

description
entities
id
index
package_name
python_package_index_id
version_range
class thoth.storages.graph.models.PythonPackageVersionEntityRulesAssociation(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Connect Python rules with corresponding package entities.

entity
python_package_version_entity_id
python_package_version_entity_rule_id
rule
class thoth.storages.graph.models.PythonRequirements(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Requirements for a software stack.

id
python_software_stack
requirements
requirements_hash
class thoth.storages.graph.models.PythonRequirementsLock(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A pinned down requirements for an application.

id
python_requirements_lock
python_software_stack
requirements_lock_hash
class thoth.storages.graph.models.PythonSoftwareStack(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A Python software stack definition.

advised_by
id
inspection_runs
kebechet_github_installation
overall_score
performance_score
python_package_requirements
python_package_requirements_locked
python_requirements_id
python_requirements_lock_id
software_stack_type
class thoth.storages.graph.models.RPMPackageVersion(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

RPM-specific package version.

arch
epoch
id
package_extract_runs
package_identifier
package_name
package_version
release
rpm_requirements
src
class thoth.storages.graph.models.RPMRequirement(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

Requirement of an RPM as stated in a spec file.

id
rpm_package_versions
rpm_requirement_name
class thoth.storages.graph.models.RPMRequires(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

RPM requirement mapping.

rpm_package_version
rpm_package_version_id
rpm_requirement
rpm_requirement_id
class thoth.storages.graph.models.RequiresSymbol(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A relation stating a software environment requires a symbol.

python_artifact
python_artifact_id
versioned_symbol
versioned_symbol_id
class thoth.storages.graph.models.SIAggregated(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A relation representing a Python package version entity analyzed by a si_aggregated_run.

python_package_version
python_package_version_entity
python_package_version_entity_id
python_package_version_id
si_aggregated_run
si_aggregated_run_id
class thoth.storages.graph.models.SecurityIndicatorAggregatedRun(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

SecurityIndicatorAggregatedRun.

datetime
error
id
number_of_analyzed_files
number_of_blank_lines_in_python_files
number_of_files_total
number_of_files_with_severities
number_of_filtered_files
number_of_lines_with_code_in_python_files
number_of_lines_with_comments_in_python_files
number_of_python_files
python_package_version_entities
severity_high_confidence_high
severity_high_confidence_low
severity_high_confidence_medium
severity_high_confidence_undefined
severity_low_confidence_high
severity_low_confidence_low
severity_low_confidence_medium
severity_low_confidence_undefined
severity_medium_confidence_high
severity_medium_confidence_low
severity_medium_confidence_medium
severity_medium_confidence_undefined
si_aggregated_run_document_id
total_number_of_blank_lines
total_number_of_files
total_number_of_lines
total_number_of_lines_with_code
total_number_of_lines_with_comments
class thoth.storages.graph.models.SoftwareEnvironment(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A base class for environment types.

cuda_version
dependency_monkey_runs_build
dependency_monkey_runs_run
env_image_name
env_image_tag
environment_name
environment_type
id
image_name
image_sha
inspection_runs_build
inspection_runs_run
os_name
os_version
package_extract_runs
python_version
thoth_image_name
thoth_image_version
versioned_symbols
class thoth.storages.graph.models.Solved(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A solver solved a package-version.

datetime
document_id
duration
ecosystem_solver
ecosystem_solver_id
error
error_unparseable
error_unsolvable
is_provided
version
version_id
class thoth.storages.graph.models.VersionedSymbol(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension

A system symbol.

id
library_name
package_extract_runs
python_artifacts
software_environments
symbol

thoth.storages.graph.models_base module

A base and utilities for implementing SQLAlchemy based models.

class thoth.storages.graph.models_base.BaseExtension[source]

Bases: object

Extend base class with additional functionality.

classmethod attribute_names()[source]

Get names of attributes for the given model declaration.

classmethod get_or_create(session, **kwargs)[source]

Query for the given entity, create if it does not exist yet.

to_dict(without_id: bool = True) dict[source]

Convert model to a dictionary representation keeping just rows as attributes.

thoth.storages.graph.models_base.get_python_package_version_index_combinations() List[sqlalchemy.sql.schema.Index][source]

Create index for all possible combinations which we can query.

thoth.storages.graph.models_performance module

Performance indicators (models) used in Thoth with their schemas.

class thoth.storages.graph.models_performance.PerformanceIndicatorBase[source]

Bases: object

A base class for implementing performance indicators.

component = Column(None, String(length=256), table=None, nullable=False)
classmethod create_from_report(session: sqlalchemy.orm.session.Session, inspection_specification: Dict[str, Any], inspection_result: Dict[str, Any], inspection_run_id: int) thoth.storages.graph.models_performance.PerformanceIndicatorBase[source]

Create performance indicator record together with related observed performance edge based on inspection.

exit_code = Column(None, Integer(), table=None, nullable=False)
classmethod from_report(inspection_result: Dict[str, Any], partial_model: type) thoth.storages.graph.models_performance.PerformanceIndicatorBase[source]

Create model from the inspection report respecting parameters and result reported by the indicator.

origin = Column(None, String(length=256), table=None, nullable=False)
overall_score = Column(None, Float(), table=None)
ru_idrss = Column(None, Integer(), table=None, nullable=False)
ru_inblock = Column(None, Integer(), table=None, nullable=False)
ru_isrss = Column(None, Integer(), table=None, nullable=False)
ru_ixrss = Column(None, Integer(), table=None, nullable=False)
ru_majflt = Column(None, Integer(), table=None, nullable=False)
ru_maxrss = Column(None, Integer(), table=None, nullable=False)
ru_minflt = Column(None, Integer(), table=None, nullable=False)
ru_msgrcv = Column(None, Integer(), table=None, nullable=False)
ru_msgsnd = Column(None, Integer(), table=None, nullable=False)
ru_nivcsw = Column(None, Integer(), table=None, nullable=False)
ru_nsignals = Column(None, Integer(), table=None, nullable=False)
ru_nswap = Column(None, Integer(), table=None, nullable=False)
ru_nvcsw = Column(None, Integer(), table=None, nullable=False)
ru_oublock = Column(None, Integer(), table=None, nullable=False)
ru_stime = Column(None, Float(), table=None, nullable=False)
ru_utime = Column(None, Float(), table=None, nullable=False)
version = Column(None, String(length=256), table=None, nullable=False)
class thoth.storages.graph.models_performance.PiConv1D(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension, thoth.storages.graph.models_performance.PerformanceIndicatorBase

A class for representing a conv1D micro-performance test.

batch
component
data_format
device
dtype
elapsed
exit_code
filter_width
id
input_channels
input_width
inspection_run
inspection_run_id
origin
output_channels
overall_score
padding
rate
reps
ru_idrss
ru_inblock
ru_isrss
ru_ixrss
ru_majflt
ru_maxrss
ru_minflt
ru_msgrcv
ru_msgsnd
ru_nivcsw
ru_nsignals
ru_nswap
ru_nvcsw
ru_oublock
ru_stime
ru_utime
strides
version
class thoth.storages.graph.models_performance.PiConv2D(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension, thoth.storages.graph.models_performance.PerformanceIndicatorBase

A class for representing a conv2D micro-performance test.

batch
component
data_format
device
dtype
elapsed
exit_code
filter_height
filter_width
id
input_channels
input_height
input_width
inspection_run
inspection_run_id
origin
output_channels
overall_score
padding
rate
reps
ru_idrss
ru_inblock
ru_isrss
ru_ixrss
ru_majflt
ru_maxrss
ru_minflt
ru_msgrcv
ru_msgsnd
ru_nivcsw
ru_nsignals
ru_nswap
ru_nvcsw
ru_oublock
ru_stime
ru_utime
strides
version
class thoth.storages.graph.models_performance.PiMatmul(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension, thoth.storages.graph.models_performance.PerformanceIndicatorBase

A class for representing a matrix multiplication micro-performance test.

component
device
dtype
elapsed
exit_code
id
inspection_run
inspection_run_id
matrix_size
origin
overall_score
rate
reps
ru_idrss
ru_inblock
ru_isrss
ru_ixrss
ru_majflt
ru_maxrss
ru_minflt
ru_msgrcv
ru_msgsnd
ru_nivcsw
ru_nsignals
ru_nswap
ru_nvcsw
ru_oublock
ru_stime
ru_utime
version
class thoth.storages.graph.models_performance.PiPyBench(**kwargs)[source]

Bases: sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension, thoth.storages.graph.models_performance.PerformanceIndicatorBase

A class for representing Pybench results for Python Interpreter.

built_in_function_calls_average
built_in_method_lookup_average
compare_floats_average
compare_floats_integers_average
compare_integers_average
compare_interned_strings_average
compare_longs_average
compare_strings_average
compare_unicode_average
component
concat_strings_average
concat_unicode_average
create_instances_average
create_new_instances_average
create_strings_with_concat_average
create_unicode_with_concat_average
dict_creation_average
dict_with_float_keys_average
dict_with_integer_keys_average
dict_with_string_keys_average
exit_code
for_loops_average
id
if_then_else_average
inspection_run
inspection_run_id
list_slicing_average
nested_for_loops_average
normal_class_attribute_average
normal_instance_attribute_average
origin
overall_score
python_function_calls_average
python_method_calls_average
recursion_average
rounds
ru_idrss
ru_inblock
ru_isrss
ru_ixrss
ru_majflt
ru_maxrss
ru_minflt
ru_msgrcv
ru_msgsnd
ru_nivcsw
ru_nsignals
ru_nswap
ru_nvcsw
ru_oublock
ru_stime
ru_utime
second_import_average
second_package_import_average
second_submodule_import_average
simple_complex_arithmetic_average
simple_dict_manipulation_average
simple_float_arithmetic_average
simple_int_float_arithmetic_average
simple_integer_arithmetic_average
simple_list_manipulation_average
simple_long_arithmetic_average
small_lists_average
small_tuples_average
special_class_attribute_average
special_instance_attribute_average
string_mappings_average
string_predicates_average
string_slicing_average
totals_average
try_except_average
try_raise_except_average
tuple_slicing_average
unicode_mappings_average
unicode_predicates_average
unicode_properties_average
unicode_slicing_average
version

thoth.storages.graph.postgres module

An SQL database for storing Thoth data.

class thoth.storages.graph.postgres.GraphDatabase(engine: Optional[sqlalchemy.engine.base.Engine] = None, sessionmaker=None)[source]

Bases: thoth.storages.graph.sql_base.SQLBase

A SQL database adapter providing graph-like operations on top of SQL queries.

DEFAULT_COUNT = 100
adviser_document_id_exist(adviser_document_id: str) bool[source]

Check if there is a adviser document record with the given id.

analysis_document_id_exist(analysis_document_id: str) bool[source]

Check if there is an analysis document record with the given id.

analysis_records_exist(analysis_document: dict) bool[source]

Check whether the given analysis document records exist in the graph database.

cache_clear() None[source]

Drop cache of records.

connect() None[source]

Connect to the database.

static construct_connection_string() str[source]

Construct a connection string needed to connect to database.

create_github_app_installation(slug: str, repo_name: str, private: bool, installation_id: str) bool[source]

Create a record for new installation or reactivate uninstalled installation.

Example -

“installation_id”: “236796147”, “repo_name”: “advisor”, “slug”: “thoth-station/advisor”, “private”: False

Accepts installation details passed down by Github. :rtype: True, False :returns True: if installation existed and was updated :returns False: if installation was newly added.

create_hardware_information(hardware: Dict[str, Any], is_external: bool = True) int[source]

Create hardware information in the database.

create_python_cve_record(package_name: str, package_version: str, index_url: str, *, cve_id: str, details: str, link: Optional[str]) bool[source]

Store information about a CVE in the graph database for the given Python package.

create_python_package_version_entity(package_name: str, package_version: Optional[str] = None, index_url: Optional[str] = None, *, only_if_package_seen: bool = False) Optional[Tuple[thoth.storages.graph.models.PythonPackageVersionEntity, bool]][source]

Create a Python package version entity record in the system.

By creating this entity, the system will record and track the given package.

create_python_rule(package_name: str, *, version_specifier: Optional[str] = None, index_url: Optional[str] = None, description: Optional[str] = None) Dict[str, Any][source]

Create the given Python rule.

delete_adviser_result(adviser_document_id: str) int[source]

Delete the corresponding adviser result.

delete_adviser_run(*, end_datetime: Optional[datetime.datetime] = None, adviser_version: Optional[str] = None) int[source]

Delete corresponding adviser data.

delete_analysis_result(analysis_document_id: str) int[source]

Delete the given package-extract entry.

delete_hardware_information(hardware_information_id: int, is_external: bool = True) None[source]

Delete hardware information entry with the given id.

delete_kebechet_github_app_installations(*, id: Optional[int] = None, slug: Optional[str] = None, private: Optional[bool] = None, installation_id: Optional[str] = None, is_active: Optional[bool] = None, runtime_environment_name: Optional[str] = None, info_manager: Optional[bool] = None, pipfile_requirements_manager: Optional[bool] = None, update_manager: Optional[bool] = None, version_manager: Optional[bool] = None, thoth_advise_manager: Optional[bool] = None, thoth_provenance_manager: Optional[bool] = None, last_run_before: Optional[datetime.datetime] = None, last_run_after: Optional[datetime.datetime] = None, external_python_software_stack_id: Optional[int] = None, external_software_environment_id: Optional[int] = None, advised_python_software_stack_id: Optional[int] = None) int[source]

Delete github kebechet installations which match the given filters.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.delete_kebechet_github_app_installations(slug=”foo/bar”, runtime_environment_name=”baz”) [

{

“id”: 0, “slug”: “thoth-station/storages”, “repo_name”: “storages”, “private”: False, “is_active”: True, “info_manager”: True, “pipfile_requirements_manager”: True, …

] :rtype: int :returns: Number of entries which have been deleted

delete_package_extract_run(*, end_datetime: Optional[datetime.datetime] = None, package_extract_version: Optional[str] = None) int[source]

Delete corresponding container image analysis data.

delete_python_package_index(index_url: str) None[source]

Delete the given Python package index.

delete_python_rule(rule_id: int) int[source]

Delete the given Python rule.

delete_solved(*, os_name: str, os_version: str, python_version: str) int[source]

Delete corresponding solver data.

delete_solver_result(solver_document_id: str) int[source]

Delete the corresponding solver result.

dependency_monkey_document_id_exists(dependency_monkey_document_id: str) bool[source]

Check if the given dependency monkey report record exists in the graph database.

drop_all()[source]

Drop all content stored in the database.

get_active_kebechet_github_installations_repos() List[str][source]

Get all active repositories names with active Kebechet installation.

Examples:

>>> from thoth.storages import GraphDatabase
>>> graph = GraphDatabase()
>>> graph.get_active_kebechet_github_installations_repos()
['repository_foo_fullname', 'repository_bar_fullname', ...]
get_active_kebechet_github_installations_repos_count_all() int[source]

Return the count of active repos with Kebechet installation.

Example: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.connect() >>> graph.get_active_kebechet_github_installations_repos_count_all() 165

get_adviser_run_count_per_source_type() Dict[str, int][source]

Retrieve number of Adviser run per source type in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_adviser_run_count_per_source_type() {‘GITHUB_APP’: 154, ‘CLI’: 71}

get_adviser_run_document_ids_all(initial_date: Optional[str] = None, final_date: Optional[str] = None, source_type: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100) List[str][source]

Retrieve adviser run document ids.

@params initial_date: DD-MM-YY @params final_date: DD-MM-YY

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_adviser_run_document_ids_all() [‘adviser-343231d’]

get_adviser_run_origins_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) List[str][source]

Retrieve all origins (git repos URLs) in Adviser Run.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_adviser_run_origins_all() [’https://github.com/thoth-station/storages’,

get_alembic_version_count_all() int[source]

Get number of records in alembic version table (1 expected).

get_analysis_metadata(analysis_document_id: str) Dict[str, Any][source]

Get metadata stored for the given analysis document.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_analysis_metadata() {

‘analysis_datetime’: datetime(2019, 10, 7, 18, 57, 22, 658131), ‘analysis_document_id’: ‘package-extract-2ef02c9cea8b1ef7’, ‘package_extract_name’: ‘thoth-package-extract’, ‘package_extract_version’: ‘1.0.1’ }

get_analyzed_image_symbols_all(os_name: str, os_version: str, *, python_version: Optional[str] = None, cuda_version: Optional[str] = None) List[str][source]

Get symbols associated with a given image.

get_analyzer_documents_count_all() int[source]

Get number of image analysis documents synced into graph.

get_bloat_data() List[Dict[str, Any]][source]

Get table bloat data.

documenation: https://raw.githubusercontent.com/pgexperts/pgx_scripts/master/bloat/table_bloat_check.sql It returns data for each table present in the database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_bloat_data() [

{

‘databasename’: ‘postgres’, ‘schemaname’: ‘public’, ‘tablename’: ‘advised’, ‘can_estimate’: True, ‘table_bytes’: 49152.0, ‘table_mb’: 0.047, ‘expected_bytes’: 49152.0, ‘expected_mb’: 0.047, ‘pct_bloat’: 0.0, ‘mb_bloat’: 0.0, ‘est_rows’: 1158.0

}, {

‘databasename’: ‘postgres’, ‘schemaname’: ‘public’, ‘tablename’: ‘adviser_run’, ‘can_estimate’: True, ‘table_bytes’: 720896.0, ‘table_mb’: 0.688, ‘expected_bytes’: 712704.0, ‘expected_mb’: 0.68, ‘pct_bloat’: 1.0, ‘mb_bloat’: 0.01, ‘est_rows’: 3600.0

}, …

]

get_build_software_environment_all(start_offset: int = 0, count: Optional[int] = 100) List[str][source]

Get all software environments available for build.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_run_software_environment_all() [‘quay.io/thoth-station/thoth-pylint:v0.7.0-ubi8’]

get_build_software_environment_analyses_all(build_software_environment_name: str, start_offset: int = 0, count: Optional[int] = 100, convert_datetime: bool = True, is_external: bool = False) List[dict][source]

Get listing of analyses available for the given software environment for build.

get_cve_timestamp() Optional[datetime.datetime][source]

Get CVE timestamp record.

get_database_size() int[source]

Get size of the database in bytes.

get_depends_on(package_name: str, package_version: Optional[str] = None, index_url: Optional[str] = None, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, extras: FrozenSet[Optional[str]] = None, marker_evaluation_result: Optional[bool] = None, is_missing: Optional[bool] = None) Dict[str, List[Tuple[str, str]]][source]

Get dependencies for the given Python package respecting environment and extras.

If no environment is provided, dependencies are returned for all environments as stored in the database.

Extras (as described in PEP-0508) are respected. If no extras is provided (extras=None), all dependencies are returned with all extras specified. A special value of None in extras listing no extra:

  • extras=frozenset((None,)) - return only dependencies which do not have any extra assigned

  • extras=frozenset((None, “postgresql”)) - dependencies without extra and with extra “postgresql”

  • extras=None - return all dependencies (regardless extra)

Environment markers are not taken into account in this query.

get_ecosystem_solver_all() List[str][source]

Get all solvers.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_ecosystem_solver_all() [‘solver-fedora-31-py38’, ‘solver-fedora-32-py37’, ‘solver-fedora-32-py38’, ‘solver-ubi-8-py36’]

get_ecosystem_solver_count_all() int[source]

Get number of solvers.

get_entity_count(entity: Union[sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension]) int[source]

Get count of a specific entity in the database.

get_error_solved_document_id_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, unsolvable: bool = False, unparseable: bool = False, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, limit_results: bool = True) List[str][source]

Retrieve solver document id with error Python package versions in Thoth Database.

if unsolvable=True -> get_unsolvable_python_package_versions if unparseable=True -> get_unparseable_python_package_versions

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_error_solved_document_id_all() [‘solver-fedora-32-py37-324232’]

get_error_solved_python_package_versions_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, unsolvable: bool = False, unparseable: bool = False, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) List[Tuple[str, str, str]][source]

Retrieve solved with error Python package versions in Thoth Database.

if unsolvable=True -> get_unsolvable_python_package_versions if unparseable=True -> get_unparseable_python_package_versions

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_error_solved_python_package_versions_all() [(‘regex’, ‘2018.11.7’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘1.11.0’, ‘https://pypi.org/simple’)]

get_error_solved_python_package_versions_count_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, unsolvable: bool = False, unparseable: bool = False, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) int[source]

Retrieve solved with error Python package versions number in Thoth Database.

if unsolvable=True -> get_unsolvable_python_package_versions_count_all if unparseable=True -> get_unparseable_python_package_versions_count_all

get_hardware_environments_all(is_external: bool = False, *, start_offset: int = 0, count: Optional[int] = 100, without_id: bool = True) List[Dict][source]

Get hardware environments (external or internal) registered in the graph database.

get_index_bloat_data() List[Dict[str, Any]][source]

Get index bloat data.

documenation: https://raw.githubusercontent.com/pgexperts/pgx_scripts/master/bloat/index_bloat_check.sql It returns data for each index/table present in the database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_index_bloat_data() [

{

‘database_name’: ‘postgres’, ‘schema_name’: ‘public’, ‘table_name’: ‘depends_on’, ‘index_name’: ‘depends_on_entity_id_idx’, ‘bloat_pct’: 11.0, ‘bloat_mb’: 623.0, ‘index_mb’: 5821.516, ‘table_mb’: 14053.625, ‘index_scans’: 2

}, {

‘database_name’: ‘postgres’, ‘schema_name’: ‘public’, ‘table_name’: ‘python_package_version’, ‘index_name’: ‘python_package_version_package_name_package_version_python__key’, ‘bloat_pct’: 43.0, ‘bloat_mb’: 35.0, ‘index_mb’: 35.0, ‘table_mb’: 111.344, ‘index_scans’: 0

}, …

]

get_index_url_from_id(package_index_id: int) str[source]

Return index URL from id.

get_kebechet_github_app_installations_all(*, id: Optional[int] = None, slug: Optional[str] = None, private: Optional[bool] = None, installation_id: Optional[str] = None, is_active: Optional[bool] = None, runtime_environment_name: Optional[str] = None, info_manager: Optional[bool] = None, pipfile_requirements_manager: Optional[bool] = None, update_manager: Optional[bool] = None, version_manager: Optional[bool] = None, thoth_advise_manager: Optional[bool] = None, thoth_provenance_manager: Optional[bool] = None, last_run_before: Optional[datetime.datetime] = None, last_run_after: Optional[datetime.datetime] = None, external_python_software_stack_id: Optional[int] = None, external_software_environment_id: Optional[int] = None, advised_python_software_stack_id: Optional[int] = None) List[Dict[str, Any]][source]

Get all github kebechet installations with optional filters on values.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_kebechet_github_installations_all() [

{

“id”: 0, “slug”: “thoth-station/storages”, “repo_name”: “storages”, “private”: False, “is_active”: True, “info_manager”: True, “pipfile_requirements_manager”: True, …

] :rtype: List[Dict[str, Any]] :returns: A list of kebechet installations which match the applied filters

get_kebechet_github_installation_info_with_software_environment_all(*, python_version: Optional[str] = None, image_name: Optional[str] = None, image_sha: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, thoth_image_name: Optional[str] = None, thoth_image_version: Optional[str] = None, env_image_name: Optional[str] = None, env_image_tag: Optional[str] = None, cuda_version: Optional[str] = None, environment_type: Optional[str] = None) List[Dict[str, Any]][source]

Get all github kebechet installations with optional filters on software environment.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_kebechet_github_installation_info_with_software_environment_all() [

{

“id”: 0, “slug”: “thoth-station/storages”, “repo_name”: “storages”, “private”: False, “is_active”: True, “info_manager”: True, “pipfile_requirements_manager”: True, …

] :rtype: List[Dict[str, Any]] :returns: A list of kebechet installations which match the applied filters

get_kebechet_github_installations_active_managers(slug: str, runtime_environment_name: Optional[str] = None) list[source]

Return the list of active managers for a particular repository.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_kebechet_github_installations_active_managers(

slug=”thoth-station/srcops-testing”

) [‘thoth_advise_manager’]

get_kebechet_github_installations_active_managers_count_all(kebechet_manager: str, distinct: bool = False) int[source]

Return the number of repos with specific manager active.

Return type

int

:returns Number of active records for registered Kebechet manager.

get_kebechet_github_installations_info_for_python_package_version(package_name: str, *, package_version: Optional[str] = None, index_url: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None) Dict[str, Dict[str, Any]][source]

Return info about repo containing Python Package in the software stack.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_kebechet_github_installations_info_for_python_package_version(

package_name=’click’ index_url=”https://pypi.org/simple”,

)

{
‘thoth-station/jupyter-nbrequirements’:
{

‘environment_name’: ‘ubi8’, ‘installation_id’: ‘193650988’, ‘private’: False, ‘package_name’: ‘click’, ‘package_version’: ‘7.1.2’, ‘index_url’: ‘https://pypi.org/simple’}

}

get_kebechet_github_installations_software_stack_count_all(*, is_active: Optional[bool] = None)[source]

Get number of Kebechet maintained software stacks.

get_last_analysis_datetime() datetime.datetime[source]

Get the datetime of the last container image analysis synced in the database.

get_last_analysis_document_id(thoth_image_name: str, thoth_image_version: str, *, is_external: bool = False) Optional[Dict[str, str]][source]

Get last image analysis (if any) for the given container image.

get_last_solver_datetime(os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None) datetime.datetime[source]

Get the datetime of the last solver run synced in the database.

get_main_table_count() Dict[str, int][source]

Retrieve dictionary mapping main tables to records count.

get_origin_count_per_source_type(distinct: bool = False) Dict[str, Dict[Tuple[str, str], int]][source]

Retrieve number of users of adviser per source type.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_origin_count_per_source_type() {‘KEBECHET’: 48, ‘JUPYTER_NOTEBOOK’: 18, ‘CLI’: 513} >>> graph.get_origin_count_per_source_type(distinct=True) {‘KEBECHET’: 5, ‘JUPYTER_NOTEBOOK’: 2, ‘CLI’: 78}

get_performance_table_count() Dict[str, int][source]

Get dictionary mapping performance tables to records count.

get_pi_component_all() List[str][source]

Retrieve pi components in Thoth database.

get_pi_count(component: str) Dict[str, int][source]

Get dictionary with number of Performance Indicators per type for the PI component selected.

get_python_cve_records_all(package_name: str, package_version: Optional[str] = None) List[dict][source]

Get known vulnerabilities for the given package-version.

get_python_cve_records_count() int[source]

Get number of CVE in Thoth database.

get_python_environment_marker(package_name: str, package_version: str, index_url: str, *, dependency_name: str, dependency_version: str, os_name: str, os_version: str, python_version: str, marker_evaluation_result: Optional[bool] = None) Optional[str][source]

Get Python evaluation marker as per PEP-0508.

@raises NotFoundError: if the given package has no entry in the database

get_python_environment_marker_evaluation_result(package_name: str, package_version: str, index_url: str, *, dependency_name: str, dependency_version: str, os_name: str, os_version: str, python_version: str) bool[source]

Get result of the Python evaluation marker.

The extra part of the environment marker (an exception in PEP-0508) is not taken into account and is substituted with a value which always defaults to True (as it would cause an error during context interpreting). See solver implementation for details.

@raises NotFoundError: if the given package has no entry in the database

get_python_package_hashes_sha256(package_name: str, package_version: str, index_url: str, *, distinct: bool = False) List[str][source]

Get all hashes for Python package in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_hashes_sha256() [

‘9d6863f6c70d034b8c34b3355cb7ba7d2ad799583947265efda41fe67127c23f’, ‘8e4a1f6d89cfaadb486237acbfa24700add01da022dfcf3536e5071d21e13ee0’

]

get_python_package_index_all(enabled: Optional[bool] = None) List[Dict[str, Any]][source]

Get listing of Python package indexes registered in the graph database.

get_python_package_index_urls_all(enabled: Optional[bool] = None) List[str][source]

Retrieve all the URLs of registered Python package indexes.

get_python_package_required_symbols(package_name: str, package_version: str, index_url: str) List[str][source]

Get required symbols for a Python package in a specified version.

get_python_package_version_all(analysis_document_id: str) List[Dict[str, str]][source]

Retrieve Python package information for the given container image analysis.

get_python_package_version_dependents_all(package_name: str, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: int = 100) List[Dict[str, Any]][source]

Get dependents for the given package.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_dependents(“selinon”, os_name=”rhel”, os_version=”8”, python_version=”3.6”) [

{

“index_url”: “https://pypi.org/simple”, “package_name”: “thoth-worker”, “package_version”: “0.0.2”, “version_range”: “>=1.0.0”, “marker_evaluation_result”: True, “marker”: None, “extra”: None,

}

]

get_python_package_version_entities_count_all(*, distinct: bool = False) int[source]

Retrieve number of all Python packages in Thoth Database.

get_python_package_version_entities_names_all() List[str][source]

Retrieve names of Python package entities in the Thoth’s knowledge base.

get_python_package_version_import_packages_all(import_name: str, distinct: bool = False) List[Dict[str, str]][source]

Retrieve Python package name for the given import package name.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_version_import_packages_all(“faust.*”) [

{‘import’: ‘faust.web.apps’,

‘index_url’: ‘https://pypi.org/simple’, ‘package_name’: ‘faust’, ‘package_version’: ‘1.9.0’},

{‘import’: ‘faust.web.cache’,

‘index_url’: ‘https://pypi.org/simple’, ‘package_name’: ‘faust’, ‘package_version’: ‘1.9.0’},

{‘import’: ‘faust.web.cache.backends’,

‘index_url’: ‘https://pypi.org/simple’, ‘package_name’: ‘faust’, ‘package_version’: ‘1.9.0’},

{‘import’: ‘faust.web.drivers’,

‘index_url’: ‘https://pypi.org/simple’, ‘package_name’: ‘faust’, ‘package_version’: ‘1.9.0’} …

]

get_python_package_version_metadata(package_name: str, package_version: str, index_url: str) Dict[str, str][source]

Retrieve Python package metadata.

get_python_package_version_names_all(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, sort: bool = False, like: Optional[str] = None) List[str][source]

Retrieve names of Python Packages known by Thoth.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_packages_names_all() [‘regex’, ‘tensorflow’]

get_python_package_version_names_count_all(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, like: Optional[str] = None) int[source]

Retrieve names of Python Packages known by Thoth.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_packages_names_count_all() 156468

static get_python_package_version_platform_all() List[str][source]

Retrieve all platforms stored in the database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_version_platform_all() [‘linux-x86_64’]

get_python_package_version_records(package_name: str, package_version: str, index_url: Optional[str], *, os_name: Optional[str], os_version: Optional[str], python_version: Optional[str]) List[dict][source]

Get records for the given package regardless of index_url.

get_python_package_version_solver_rules_all(package_name: str, package_version: Optional[str] = None, index_url: Optional[str] = None) List[Tuple[int, Optional[str], Optional[str], str]][source]

Get rules assigned for the given Python package.

get_python_package_version_trove_classifiers_all(package_name: str, package_version: str, index_url: str, *, os_name: str, os_version: str, python_version: str) List[str][source]

Get Python trove classifiers.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_version_trove_classifiers_all( “cowsay”, “4.0”, “https://pypi.org/simple”, os_name=”rhel”, os_version=”9”, python_version=”3.9”) [“PROGRAMMING LANGUAGE :: PYTHON :: 3.9”, “OPERATING SYSTEM :: OS INDEPENDENT”]

get_python_package_versions_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, is_missing: Optional[bool] = None) List[Tuple[str, str, str]][source]

Retrieve Python package versions in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_versions_all() [(‘regex’, ‘2018.11.7’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘1.11.0’, ‘https://pypi.org/simple’)]

get_python_package_versions_all_count(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, sort_by: Optional[thoth.storages.graph.enums.QuerySortTypeEnum] = None) thoth.storages.graph.query_result_base.PythonQueryResult[source]

Retrieve number of versions per Python package name in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_versions_all_count() {‘setuptools’: 988, ‘pip’: 211, ‘termcolor’: 14, ‘six’: 42}

get_python_package_versions_count(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[Tuple[str, str, str], int][source]

Retrieve number of Python Package (package_name, package_version, index_url) in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_versions_count() {(‘absl-py’, ‘0.1.10’, ‘https://pypi.org/simple’): 1, (‘absl-py’, ‘0.2.1’, ‘https://pypi.org/simple’): 1}

get_python_package_versions_count_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, is_missing: Optional[bool] = None) int[source]

Retrieve Python package versions number in Thoth Database.

get_python_package_versions_count_per_index(index_url: str, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, Dict[Tuple[str, str], int]][source]

Retrieve number of Python package versions per index url in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_versions_count_per_index(index_url=’https://pypi.org/simple’) {’https://pypi.org/simple’: {(‘absl-py’, ‘0.1.10’): 1, (‘absl-py’, ‘0.2.1’): 1}}

get_python_package_versions_count_per_version(package_name: str, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, Dict[str, int]][source]

Retrieve number of Python package versions per index url in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_versions_count_per_version(package_name=’tensorflow’) {‘1.14.0rc0’: {’https://pypi.org/simple’: 1}, ‘1.13.0rc2’: {’https://pypi.org/simple’: 1}}

get_python_package_versions_per_index(index_url: str, *, distinct: bool = False) Dict[str, List[str]][source]

Retrieve listing of Python packages (solved) known to graph database instance for the given index.

get_python_packages_all(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) List[Tuple[str, str]][source]

Retrieve Python packages with index in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_packages_all() [(‘regex’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘https://pypi.org/simple’)]

get_python_packages_all_versions(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, List[Tuple[str, str]]][source]

Retrieve Python package versions per package in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_packages_all_versions() {‘absl-py’: [(‘0.1.10’, ‘https://pypi.org/simple’), (‘0.2.1’, ‘https://pypi.org/simple’)]}

get_python_packages_count_all(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) int[source]

Retrieve number of versions per Python package in Thoth Database.

get_python_rule(rule_id: int) Dict[str, Any][source]

Get the given Python rule.

get_python_rule_all(*, package_name: Optional[str] = None, index_url: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100) List[Dict[str, Any]][source]

Get all the Python rules matching the given query criteria.

get_python_software_stack_count_all(is_external: bool = False, software_stack_type: Optional[str] = None, distinct: bool = False) int[source]

Get number of Python software stacks available filtered by type.

get_relation_table_count() Dict[str, int][source]

Retrieve dictionary mapping relation tables to records count.

get_rpm_package_version_all(analysis_document_id: str) List[Dict[str, str]][source]

Retrieve RPM package information for the given container image analysis.

get_run_software_environment_all(start_offset: int = 0, count: Optional[int] = 100, is_external: bool = False) List[str][source]

Get all software environments available for run.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_run_software_environment_all() [‘quay.io/thoth-station/thoth-pylint:v0.7.0-ubi8’]

get_run_software_environment_analyses_all(run_software_environment_name: str, start_offset: int = 0, count: Optional[int] = 100, convert_datetime: bool = True, is_external: bool = False) List[dict][source]

Get listing of analyses available for the given software environment for run.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_run_software_environment_analyses_all() [{

‘analysis_datetime’: datetime(2019, 10, 7, 18, 57, 22, 658131), ‘analysis_document_id’: ‘package-extract-2ef02c9cea8b1ef7’, ‘package_extract_name’: ‘thoth-package-extract’, ‘package_extract_version’: ‘1.0.1’ }]

get_script_alembic_version_head() str[source]

Get alembic version head from alembic folder scripts.

get_si_aggregated_python_package_version(package_name: str, package_version: str, index_url: str) Dict[str, int][source]

Get Aggregate Security Indicators (SI) results per Python package version.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_si_aggregated_python_package_version(

package_name=’thoth-common’, package_version=’0.10.0’, index_url=’https://pypi.org/simple

)
{

‘severity_high_confidence_high’: 0, ‘severity_high_confidence_low’: 0, ‘severity_high_confidence_medium’: 0, ‘severity_high_confidence_undefined’: 0, ‘severity_low_confidence_high’: 0, ‘severity_low_confidence_low’: 0, ‘severity_low_confidence_medium’: 0, ‘severity_low_confidence_undefined’: 0, ‘severity_medium_confidence_high’: 0, ‘severity_medium_confidence_low’: 0, ‘severity_medium_confidence_medium’: 0, ‘severity_medium_confidence_undefined’: 0, ‘number_of_analyzed_files’: 0, ‘number_of_files_total’: 0, ‘number_of_files_with_severities’: 0, ‘number_of_filtered_files’: 0, ‘number_of_python_files’: 39, ‘number_of_lines_with_comments_in_python_files’: 922, ‘number_of_blank_lines_in_python_files’: 2760, ‘number_of_lines_with_code_in_python_files’: 9509, ‘total_number_of_files’: 75, ‘total_number_of_lines’: 36856, ‘total_number_of_lines_with_comments’: 2895, ‘total_number_of_blank_lines’: 6737, ‘total_number_of_lines_with_code’: 27224

}

get_si_analyzed_python_package_versions_all(*, distinct: bool = False) List[Tuple[str, str, str]][source]

Get SI analyzed Python package versions in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_si_analyzed_python_package_versions_all() [(‘fbprophet’, ‘0.4’, ‘https://pypi.org/simple’)]

get_si_analyzed_python_package_versions_count_all(*, distinct: bool = False) int[source]

Get SI analyzed Python package versions number in Thoth Database.

get_si_unanalyzed_python_package_versions_all(start_offset: int = 0, count: Optional[int] = 100, distinct: bool = True, randomize: bool = True, provides_source_distro: bool = True, si_error: bool = False) List[Tuple[str, str, str]][source]

Retrieve solved Python package versions in Thoth Database, that are not anaylyzed by SI.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_si_unanalyzed_python_package_versions_all() [(‘crossbar’, ‘0.10.0’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘1.11.0’, ‘https://pypi.org/simple’)]

get_si_unanalyzed_python_package_versions_count_all(index_url: Optional[str] = None, *, distinct: bool = False, provides_source_distro: bool = True, si_error: bool = False) int[source]

Get SI unanalyzed Python package versions number in Thoth Database.

get_software_environments_all(is_external: bool = False, convert_datetime: bool = True, *, start_offset: int = 0, count: Optional[int] = 100, env_image_name: Optional[str] = None, env_image_tag: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, cuda_version: Optional[str] = None, image_name: Optional[str] = None, library_name: Optional[str] = None, symbol: Optional[str] = None, package_name: Optional[str] = None, rpm_package_name: Optional[str] = None) List[Dict][source]

Get software environments (external or internal) registered in the graph database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_software_environments_all()

[
{

‘cuda_version’: None, ‘datetime’: datetime.datetime(2021, 12, 15, 19, 27, 52, 803266), ‘env_image_name’: None, ‘env_image_tag’: None, ‘environment_name’: ‘quay.io/thoth-station/s2i-thoth-ubi8-py39:v0.32.3’, ‘environment_type’: ‘RUNTIME’, ‘image_sha’: ‘bcf4fa447e5dc889015afb4d3c54ef4a3aaddc3260fce072311602df34ffac3c’, ‘os_name’: ‘rhel’, ‘os_version’: ‘8’, ‘package_extract_document_id’: ‘package-extract-211215162259-33c8d9c730b775eb’, ‘python_version’: ‘3.9’, ‘thoth_image_name’: ‘quay.io/thoth-station/s2i-thoth-ubi8-py39’, ‘thoth_image_version’: ‘0.32.3’ }

]

get_software_environments_count_all(is_external: bool = False, *, env_image_name: Optional[str] = None, env_image_tag: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, cuda_version: Optional[str] = None, image_name: Optional[str] = None, library_name: Optional[str] = None, symbol: Optional[str] = None, package_name: Optional[str] = None, rpm_package_name: Optional[str] = None) int[source]

Get number of software environments stored.

get_solved_python_package_version_environments_all(package_name: str, package_version: str, index_url: str, *, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) List[Dict[str, str]][source]

Retrieve all the environments that were used to solve the given package.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_package_version_environments_all( package_name=”flask”, package_version=”2.0.2”, index_url=”https://pypi.org/simple”) [

{“os_name”: “rhel”, “os_version”: “8”, “python_version”: “3.8”}, {“os_name”: “fedora”, “os_version”: “35”, “python_version”: “3.9”},

]

get_solved_python_package_versions_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, is_missing: Optional[bool] = None) List[Tuple[str, str, str]][source]

Retrieve solved Python package versions in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_package_versions_all() [(‘regex’, ‘2018.11.7’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘1.11.0’, ‘https://pypi.org/simple’)]

get_solved_python_package_versions_count(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[Tuple[str, str, str], int][source]

Retrieve number of Python Package (package_name, package_version, index_url) solved in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_package_versions_count() {(‘absl-py’, ‘0.1.10’, ‘https://pypi.org/simple’): 1, (‘absl-py’, ‘0.2.1’, ‘https://pypi.org/simple’): 1}

get_solved_python_package_versions_count_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, is_missing: Optional[bool] = None) int[source]

Retrieve solved Python package versions number in Thoth Database.

get_solved_python_package_versions_count_per_index(index_url: str, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, Dict[Tuple[str, str], int]][source]

Retrieve number of solved Python package versions per index url in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_package_versions_count_per_index(index_url=’https://pypi.org/simple’) {’https://pypi.org/simple’: {(‘absl-py’, ‘0.1.10’): 1, (‘absl-py’, ‘0.2.1’): 1}}

get_solved_python_package_versions_count_per_version(package_name: str, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, Dict[str, int]][source]

Retrieve number of solved Python package versions per package version in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_package_versions_count_per_version(package_name=’tensorflow’) {‘1.14.0rc0’: {’https://pypi.org/simple’: 1}, ‘1.13.0rc2’: {’https://pypi.org/simple’: 1}}

get_solved_python_package_versions_software_environment_all() List[Dict[str, str]][source]

Retrieve software environment configurations used to solve Python packages.

get_solved_python_packages_all(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) List[Tuple[str, str]][source]

Retrieve solved Python package with index in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_packages_all() [(‘regex’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘https://pypi.org/simple’)]

get_solved_python_packages_all_versions(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, List[Tuple[str, str]]][source]

Retrieve solved Python package versions per package in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_packages_all_versions() {‘absl-py’: [(‘0.1.10’, ‘https://pypi.org/simple’), (‘0.2.1’, ‘https://pypi.org/simple’)]}

get_solved_python_packages_count_all(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) int[source]

Retrieve number of solved Python package versions in Thoth Database.

get_solver_document_id_all(package_name: str, package_version: Optional[str] = None, index_url: Optional[str] = None, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, sort: bool = False) List[str][source]

Get the solver document specific to the given package that has been solved.

If sorted, the latest solver document is at index 0.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.graph.get_solver_document_id_all(“selinon”, “1.0.0”, “https://pypi.org/simple”, os_name=”rhel”, os_version=”8”, python_version=”3.8”, sort=True) [

“solver-rhel-8-py38-210713010253-a24759ebdaa1442c”, “solver-rhel-8-py38-210711003643-187580eee457bb3f”, “solver-rhel-8-py38-210707005412-4965667a05a39006”

]

get_solver_documents_count_all() int[source]

Get number of solver documents synced into graph.

get_solver_run_document_ids_all(initial_date: Optional[str] = None, final_date: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, has_error: bool = False, unsolvable: bool = False, unparseable: bool = False) List[str][source]

Retrieve solver run document ids.

@params initial_date: DD-MM-YY @params final_date: DD-MM-YY

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solver_run_document_ids_all() [‘solver-rhel-8-py38-343231d’]

get_table_alembic_version_head() str[source]

Get alembic version head from database table.

get_thoth_s2i_all(is_external: bool = False) List[Tuple[str, str]][source]

Get all the Thoth s2i container images available.

get_thoth_s2i_analyzed_image_symbols_all(thoth_image_name: str, thoth_image_version: str, is_external: bool = False) List[str][source]

Get symbols associated with a given Thoth s2i container image.

get_thoth_s2i_package_extract_analysis_document_id_all(thoth_image_name: str, thoth_image_version: str, is_external: bool = False) List[str][source]

Get package-extract analysis ids for the given Thoth s2i.

get_unsolved_python_package_versions_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, randomize: bool = True) List[Tuple[str, Optional[str], Optional[str]]][source]

Retrieve unsolved Python package versions in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_package_versions_all() [(‘regex’, ‘2018.11.7’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘1.11.0’, ‘https://pypi.org/simple’)]

get_unsolved_python_package_versions_count(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) Dict[Tuple[str, str, str], int][source]

Retrieve number of unsolved versions per Python package in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_package_versions_count() {(‘absl-py’, ‘0.1.10’, ‘https://pypi.org/simple’): 1, (‘absl-py’, ‘0.2.1’, ‘https://pypi.org/simple’): 1}

get_unsolved_python_package_versions_count_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) int[source]

Retrieve unsolved Python package versions number in Thoth Database.

get_unsolved_python_package_versions_count_per_index(index_url: str, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) Dict[str, Dict[Tuple[str, str], int]][source]

Retrieve number of unsolved Python package versions per index url in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_package_versions_count_per_index(index_url=’https://pypi.org/simple’) {’https://pypi.org/simple’: {(‘absl-py’, ‘0.1.10’): 1, (‘absl-py’, ‘0.2.1’): 1}}

get_unsolved_python_package_versions_count_per_version(package_name: str, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, Dict[str, int]][source]

Retrieve number of unsolved Python package versions per package version in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_package_versions_count_per_version(package_name=’tensorflow’) {‘1.14.0rc0’: {’https://pypi.org/simple’: 1}, ‘1.13.0rc2’: {’https://pypi.org/simple’: 1}}

get_unsolved_python_packages_all(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) List[Tuple[str, Optional[str]]][source]

Retrieve unsolved Python package with index in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_packages_all() [(‘regex’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘https://pypi.org/simple’)]

get_unsolved_python_packages_all_per_adviser_run(source_type: str) Dict[str, List[str]][source]

Retrieve all unsolved packages for a certain Adviser Run that need to be re run.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_packages_all_per_adviser_run() {‘adviser-04ab56d6’: [‘black’], ‘adviser-054ab56d6’: [‘black’, ‘numpy’]}

get_unsolved_python_packages_all_versions(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) Dict[str, List[Tuple[str, str]]][source]

Retrieve unsolved Python package versions per package in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_packages_all_versions() {‘absl-py’: [(‘0.1.10’, ‘https://pypi.org/simple’), (‘0.2.1’, ‘https://pypi.org/simple’)]}

has_python_solver_error(package_name: str, package_version: str, index_url: str, *, os_name: Optional[str], os_version: Optional[str], python_version: Optional[str]) bool[source]

Retrieve information whether the given package has any solver error.

initialize_schema()[source]

Initialize schema of database.

inspection_document_id_exist(inspection_document_id: str) bool[source]

Check if there is an inspection document record with the given id.

inspection_document_id_result_number_exists(inspection_document_id: str, inspection_result_number: int) bool[source]

Check if the given inspection id result number record exists in the graph database.

is_database_corrupted() bool[source]

Run the amcheck extension to check for DB corruption, false negatives are possible but false positives are not.

amcheck documenation: https://www.postgresql.org/docs/10/amcheck.html

bool

False: No DB corruption detected by amcheck (not definitive) True: Database is corrupted

is_python_package_index_enabled(url: str) bool[source]

Check if the given Python package index is enabled.

is_python_package_version_is_missing(package_name: str, package_version: str, index_url: str) bool[source]

Check whether is_missing flag is set for python package version.

is_schema_up2date() bool[source]

Check if the current schema is up2date with the one configured on database side.

static normalize_python_index_url(index_url: Optional[str]) Optional[str][source]

Map python index url.

static normalize_python_package_name(package_name: str) str[source]

Normalize Python package name based on PEP-0503.

static normalize_python_package_version(package_version: str) str[source]

Normalize Python package name based on PEP-440.

provenance_checker_document_id_exist(provenance_checker_document_id: str) bool[source]

Check if there is a provenance-checker document record with the given id.

purge_adviser_documents(*, end_datetime: Optional[datetime.datetime] = None, adviser_version: Optional[str] = None) int[source]

Store and purge to be deleted adviser documents to Ceph.

purge_package_extract_documents(*, end_datetime: Optional[datetime.datetime] = None, package_extract_version: Optional[str] = None) int[source]

Store and purge to be deleted package extract documents to Ceph.

purge_solver_documents(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None) int[source]

Store and purge to be deleted solver documents to Ceph.

python_package_exists(package_name: str) bool[source]

Check if the given Python package exists regardless of version.

static python_package_version_depends_on_platform_exists(platform: str) bool[source]

Check if the given platform has some records in the database.

python_package_version_exists(package_name: str, package_version: str, index_url: Optional[str] = None, solver_name: Optional[str] = None) bool[source]

Check if the given Python package version exists in the graph database.

If optional solver_name parameter is set, the call answers if the given package was solved by the given solver. Otherwise, any solver run is taken into account.

register_python_package_index(url: str, warehouse_api_url: Optional[str] = None, verify_ssl: bool = True, enabled: bool = False, only_if_package_seen: bool = True) bool[source]

Register the given Python package index in the graph database.

retrieve_dependent_packages(package_name: str, package_version: Optional[str] = None) Dict[str, List[str]][source]

Get mapping package name to package version of packages that depend on the given package.

retrieve_transitive_dependencies_python(package_name: str, package_version: str, index_url: str, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, extras: Optional[FrozenSet[Optional[str]]] = None, marker_evaluation_result: Optional[bool] = None) List[Tuple[Tuple[str, str, str], Tuple[str, str, str], Tuple[str, str, str], Tuple[str, str, str], Optional[Tuple[str, str, str]], Optional[Tuple[str, str, str]]]][source]

Get all transitive dependencies for the given package by traversing dependency graph.

It’s much faster to retrieve just dependency ids for the transitive dependencies as most of the time is otherwise spent in serialization and deserialization of query results. The ids are obtained later on (kept in ids map, see bellow).

The ids map represents a map to optimize number of retrievals - not to perform duplicate queries into graph instance.

Extras are taken into account only for direct dependencies. Any extras required in libraries used in transitive dependencies are not required as solver directly report dependencies regardless extras configuration - see get_depends_on docs for extras parameter values..

retrieve_transitive_dependencies_python_multi(*package_tuples, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None) Dict[Tuple[str, str, str], Set[Tuple[Tuple[str, str, str], Tuple[str, str, str], Tuple[str, str, str], Tuple[str, str, str], Optional[Tuple[str, str, str]], Optional[Tuple[str, str, str]]]]][source]

Get all transitive dependencies for a given set of packages by traversing the dependency graph.

set_cve_timestamp(timestamp: datetime.datetime) None[source]

Set CVE timestamp record.

set_python_package_index_state(url: str, *, enabled: bool) None[source]

Enable or disable Python package index.

si_aggregated_document_id_exists(si_aggregated_run_document_id: str) bool[source]

Check if the given security indicator aggregated report record exists in the graph database.

si_aggregated_python_package_version_exists(package_name: str, package_version: str, index_url: str) bool[source]

Check if Aggregate Security Indicators (SI) results exists for Python package version.

solved_software_environment_exists(os_name: str, os_version: str, python_version: str) bool[source]

Check if there are any solved packages for the given software environment.

solver_document_id_exists(solver_document_id: str) bool[source]

Check if there is a solver document record with the given id.

solver_records_exist(solver_document: dict) bool[source]

Check if the given solver document record exists.

stats() dict[source]

Get statistics for this adapter.

sync_adviser_result(document: dict) None[source]

Sync adviser result into graph database.

sync_analysis_result(document: dict) None[source]

Sync the given analysis result to the graph database.

sync_dependency_monkey_result(document: dict) None[source]

Sync reports of dependency monkey runs.

sync_inspection_result(document) None[source]

Sync the given inspection document into the graph database.

sync_provenance_checker_result(document: dict) None[source]

Sync provenance checker results into graph database.

sync_revsolver_result(document: Dict[str, Any]) None[source]

Sync results of the reverse solver.

This updates relations for DependsOn on a new package release.

sync_security_indicator_aggregated_result(document: dict) None[source]

Sync the given security-indicator aggregated result to the graph database.

sync_solver_result(document: dict, *, force: bool = False) None[source]

Sync the given solver result to the graph database.

update_kebechet_github_installations_on_is_active(slug: str) bool[source]

Deactivate the app on getting an uninstall event.

Passed a slug name to be deactivated. Example - slug:’thoth-station/advisor’ :rtype: True, False :returns True: if installation existed and was deactivated. :returns False: if installation was not found.

update_kebechet_installation_using_files(slug: str, installation_id: str, requirements: Optional[dict] = None, requirements_lock: Optional[dict] = None, thoth_config: Optional[dict] = None, runtime_environment_name: Optional[str] = None, private: bool = False)[source]

Update info about kebechet installation.

update_missing_flag_package_version(package_name: str, package_version: str, index_url: str, value: bool) None[source]

Update value of is_missing flag for PythonPackageVersion.

update_provides_source_distro_package_version(package_name: str, package_version: str, index_url: str, value: bool) None[source]

Update value of is_si_analyzable flag for PythonPackageVersion.

update_python_package_hash_present_flag(package_name: str, package_version: str, index_url: str, sha256_hash: str)[source]

Remove hash associated with python package in the graph.

thoth.storages.graph.postgres.lru_cache(*lru_args, **lru_kwargs)[source]

Implement a cache for methods.

Based on:

https://stackoverflow.com/questions/33672412/python-functools-lru-cache-with-class-methods-release-object

thoth.storages.graph.query_result_base module

Utilities for SQLAlchemy query results.

class thoth.storages.graph.query_result_base.PythonQueryResult(result: Union[List, Dict[str, Any]], count: Optional[int] = None)[source]

Bases: object

Class for managing queries’ results for Python Packages.

property count

Query count result.

property result

Query result.

thoth.storages.graph.sql_base module

A base class for implementing SQL based databases.

class thoth.storages.graph.sql_base.SQLBase(engine: Optional[sqlalchemy.engine.base.Engine] = None, sessionmaker=None)[source]

Bases: object

A base class for implementing SQL based databases using SQLAlchemy.

abstract connect() None[source]

Connect to the database.

disconnect() None[source]

Disconnect from the connected database.

drop_all() None[source]

Drop all content stored in the database.

abstract initialize_schema() None[source]

Initialize schema in the database.

is_connected() bool[source]

Check if the database is connected.

Module contents

A graph database adapter for communicating with dgraph via gRPC.

class thoth.storages.graph.GraphDatabase(engine: Optional[sqlalchemy.engine.base.Engine] = None, sessionmaker=None)[source]

Bases: thoth.storages.graph.sql_base.SQLBase

A SQL database adapter providing graph-like operations on top of SQL queries.

DEFAULT_COUNT = 100
adviser_document_id_exist(adviser_document_id: str) bool[source]

Check if there is a adviser document record with the given id.

analysis_document_id_exist(analysis_document_id: str) bool[source]

Check if there is an analysis document record with the given id.

analysis_records_exist(analysis_document: dict) bool[source]

Check whether the given analysis document records exist in the graph database.

cache_clear() None[source]

Drop cache of records.

connect() None[source]

Connect to the database.

static construct_connection_string() str[source]

Construct a connection string needed to connect to database.

create_github_app_installation(slug: str, repo_name: str, private: bool, installation_id: str) bool[source]

Create a record for new installation or reactivate uninstalled installation.

Example -

“installation_id”: “236796147”, “repo_name”: “advisor”, “slug”: “thoth-station/advisor”, “private”: False

Accepts installation details passed down by Github. :rtype: True, False :returns True: if installation existed and was updated :returns False: if installation was newly added.

create_hardware_information(hardware: Dict[str, Any], is_external: bool = True) int[source]

Create hardware information in the database.

create_python_cve_record(package_name: str, package_version: str, index_url: str, *, cve_id: str, details: str, link: Optional[str]) bool[source]

Store information about a CVE in the graph database for the given Python package.

create_python_package_version_entity(package_name: str, package_version: Optional[str] = None, index_url: Optional[str] = None, *, only_if_package_seen: bool = False) Optional[Tuple[thoth.storages.graph.models.PythonPackageVersionEntity, bool]][source]

Create a Python package version entity record in the system.

By creating this entity, the system will record and track the given package.

create_python_rule(package_name: str, *, version_specifier: Optional[str] = None, index_url: Optional[str] = None, description: Optional[str] = None) Dict[str, Any][source]

Create the given Python rule.

delete_adviser_result(adviser_document_id: str) int[source]

Delete the corresponding adviser result.

delete_adviser_run(*, end_datetime: Optional[datetime.datetime] = None, adviser_version: Optional[str] = None) int[source]

Delete corresponding adviser data.

delete_analysis_result(analysis_document_id: str) int[source]

Delete the given package-extract entry.

delete_hardware_information(hardware_information_id: int, is_external: bool = True) None[source]

Delete hardware information entry with the given id.

delete_kebechet_github_app_installations(*, id: Optional[int] = None, slug: Optional[str] = None, private: Optional[bool] = None, installation_id: Optional[str] = None, is_active: Optional[bool] = None, runtime_environment_name: Optional[str] = None, info_manager: Optional[bool] = None, pipfile_requirements_manager: Optional[bool] = None, update_manager: Optional[bool] = None, version_manager: Optional[bool] = None, thoth_advise_manager: Optional[bool] = None, thoth_provenance_manager: Optional[bool] = None, last_run_before: Optional[datetime.datetime] = None, last_run_after: Optional[datetime.datetime] = None, external_python_software_stack_id: Optional[int] = None, external_software_environment_id: Optional[int] = None, advised_python_software_stack_id: Optional[int] = None) int[source]

Delete github kebechet installations which match the given filters.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.delete_kebechet_github_app_installations(slug=”foo/bar”, runtime_environment_name=”baz”) [

{

“id”: 0, “slug”: “thoth-station/storages”, “repo_name”: “storages”, “private”: False, “is_active”: True, “info_manager”: True, “pipfile_requirements_manager”: True, …

] :rtype: int :returns: Number of entries which have been deleted

delete_package_extract_run(*, end_datetime: Optional[datetime.datetime] = None, package_extract_version: Optional[str] = None) int[source]

Delete corresponding container image analysis data.

delete_python_package_index(index_url: str) None[source]

Delete the given Python package index.

delete_python_rule(rule_id: int) int[source]

Delete the given Python rule.

delete_solved(*, os_name: str, os_version: str, python_version: str) int[source]

Delete corresponding solver data.

delete_solver_result(solver_document_id: str) int[source]

Delete the corresponding solver result.

dependency_monkey_document_id_exists(dependency_monkey_document_id: str) bool[source]

Check if the given dependency monkey report record exists in the graph database.

drop_all()[source]

Drop all content stored in the database.

get_active_kebechet_github_installations_repos() List[str][source]

Get all active repositories names with active Kebechet installation.

Examples:

>>> from thoth.storages import GraphDatabase
>>> graph = GraphDatabase()
>>> graph.get_active_kebechet_github_installations_repos()
['repository_foo_fullname', 'repository_bar_fullname', ...]
get_active_kebechet_github_installations_repos_count_all() int[source]

Return the count of active repos with Kebechet installation.

Example: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.connect() >>> graph.get_active_kebechet_github_installations_repos_count_all() 165

get_adviser_run_count_per_source_type() Dict[str, int][source]

Retrieve number of Adviser run per source type in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_adviser_run_count_per_source_type() {‘GITHUB_APP’: 154, ‘CLI’: 71}

get_adviser_run_document_ids_all(initial_date: Optional[str] = None, final_date: Optional[str] = None, source_type: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100) List[str][source]

Retrieve adviser run document ids.

@params initial_date: DD-MM-YY @params final_date: DD-MM-YY

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_adviser_run_document_ids_all() [‘adviser-343231d’]

get_adviser_run_origins_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) List[str][source]

Retrieve all origins (git repos URLs) in Adviser Run.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_adviser_run_origins_all() [’https://github.com/thoth-station/storages’,

get_alembic_version_count_all() int[source]

Get number of records in alembic version table (1 expected).

get_analysis_metadata(analysis_document_id: str) Dict[str, Any][source]

Get metadata stored for the given analysis document.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_analysis_metadata() {

‘analysis_datetime’: datetime(2019, 10, 7, 18, 57, 22, 658131), ‘analysis_document_id’: ‘package-extract-2ef02c9cea8b1ef7’, ‘package_extract_name’: ‘thoth-package-extract’, ‘package_extract_version’: ‘1.0.1’ }

get_analyzed_image_symbols_all(os_name: str, os_version: str, *, python_version: Optional[str] = None, cuda_version: Optional[str] = None) List[str][source]

Get symbols associated with a given image.

get_analyzer_documents_count_all() int[source]

Get number of image analysis documents synced into graph.

get_bloat_data() List[Dict[str, Any]][source]

Get table bloat data.

documenation: https://raw.githubusercontent.com/pgexperts/pgx_scripts/master/bloat/table_bloat_check.sql It returns data for each table present in the database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_bloat_data() [

{

‘databasename’: ‘postgres’, ‘schemaname’: ‘public’, ‘tablename’: ‘advised’, ‘can_estimate’: True, ‘table_bytes’: 49152.0, ‘table_mb’: 0.047, ‘expected_bytes’: 49152.0, ‘expected_mb’: 0.047, ‘pct_bloat’: 0.0, ‘mb_bloat’: 0.0, ‘est_rows’: 1158.0

}, {

‘databasename’: ‘postgres’, ‘schemaname’: ‘public’, ‘tablename’: ‘adviser_run’, ‘can_estimate’: True, ‘table_bytes’: 720896.0, ‘table_mb’: 0.688, ‘expected_bytes’: 712704.0, ‘expected_mb’: 0.68, ‘pct_bloat’: 1.0, ‘mb_bloat’: 0.01, ‘est_rows’: 3600.0

}, …

]

get_build_software_environment_all(start_offset: int = 0, count: Optional[int] = 100) List[str][source]

Get all software environments available for build.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_run_software_environment_all() [‘quay.io/thoth-station/thoth-pylint:v0.7.0-ubi8’]

get_build_software_environment_analyses_all(build_software_environment_name: str, start_offset: int = 0, count: Optional[int] = 100, convert_datetime: bool = True, is_external: bool = False) List[dict][source]

Get listing of analyses available for the given software environment for build.

get_cve_timestamp() Optional[datetime.datetime][source]

Get CVE timestamp record.

get_database_size() int[source]

Get size of the database in bytes.

get_depends_on(package_name: str, package_version: Optional[str] = None, index_url: Optional[str] = None, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, extras: FrozenSet[Optional[str]] = None, marker_evaluation_result: Optional[bool] = None, is_missing: Optional[bool] = None) Dict[str, List[Tuple[str, str]]][source]

Get dependencies for the given Python package respecting environment and extras.

If no environment is provided, dependencies are returned for all environments as stored in the database.

Extras (as described in PEP-0508) are respected. If no extras is provided (extras=None), all dependencies are returned with all extras specified. A special value of None in extras listing no extra:

  • extras=frozenset((None,)) - return only dependencies which do not have any extra assigned

  • extras=frozenset((None, “postgresql”)) - dependencies without extra and with extra “postgresql”

  • extras=None - return all dependencies (regardless extra)

Environment markers are not taken into account in this query.

get_ecosystem_solver_all() List[str][source]

Get all solvers.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_ecosystem_solver_all() [‘solver-fedora-31-py38’, ‘solver-fedora-32-py37’, ‘solver-fedora-32-py38’, ‘solver-ubi-8-py36’]

get_ecosystem_solver_count_all() int[source]

Get number of solvers.

get_entity_count(entity: Union[sqlalchemy.ext.declarative.api.Base, thoth.storages.graph.models_base.BaseExtension]) int[source]

Get count of a specific entity in the database.

get_error_solved_document_id_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, unsolvable: bool = False, unparseable: bool = False, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, limit_results: bool = True) List[str][source]

Retrieve solver document id with error Python package versions in Thoth Database.

if unsolvable=True -> get_unsolvable_python_package_versions if unparseable=True -> get_unparseable_python_package_versions

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_error_solved_document_id_all() [‘solver-fedora-32-py37-324232’]

get_error_solved_python_package_versions_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, unsolvable: bool = False, unparseable: bool = False, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) List[Tuple[str, str, str]][source]

Retrieve solved with error Python package versions in Thoth Database.

if unsolvable=True -> get_unsolvable_python_package_versions if unparseable=True -> get_unparseable_python_package_versions

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_error_solved_python_package_versions_all() [(‘regex’, ‘2018.11.7’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘1.11.0’, ‘https://pypi.org/simple’)]

get_error_solved_python_package_versions_count_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, unsolvable: bool = False, unparseable: bool = False, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) int[source]

Retrieve solved with error Python package versions number in Thoth Database.

if unsolvable=True -> get_unsolvable_python_package_versions_count_all if unparseable=True -> get_unparseable_python_package_versions_count_all

get_hardware_environments_all(is_external: bool = False, *, start_offset: int = 0, count: Optional[int] = 100, without_id: bool = True) List[Dict][source]

Get hardware environments (external or internal) registered in the graph database.

get_index_bloat_data() List[Dict[str, Any]][source]

Get index bloat data.

documenation: https://raw.githubusercontent.com/pgexperts/pgx_scripts/master/bloat/index_bloat_check.sql It returns data for each index/table present in the database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_index_bloat_data() [

{

‘database_name’: ‘postgres’, ‘schema_name’: ‘public’, ‘table_name’: ‘depends_on’, ‘index_name’: ‘depends_on_entity_id_idx’, ‘bloat_pct’: 11.0, ‘bloat_mb’: 623.0, ‘index_mb’: 5821.516, ‘table_mb’: 14053.625, ‘index_scans’: 2

}, {

‘database_name’: ‘postgres’, ‘schema_name’: ‘public’, ‘table_name’: ‘python_package_version’, ‘index_name’: ‘python_package_version_package_name_package_version_python__key’, ‘bloat_pct’: 43.0, ‘bloat_mb’: 35.0, ‘index_mb’: 35.0, ‘table_mb’: 111.344, ‘index_scans’: 0

}, …

]

get_index_url_from_id(package_index_id: int) str[source]

Return index URL from id.

get_kebechet_github_app_installations_all(*, id: Optional[int] = None, slug: Optional[str] = None, private: Optional[bool] = None, installation_id: Optional[str] = None, is_active: Optional[bool] = None, runtime_environment_name: Optional[str] = None, info_manager: Optional[bool] = None, pipfile_requirements_manager: Optional[bool] = None, update_manager: Optional[bool] = None, version_manager: Optional[bool] = None, thoth_advise_manager: Optional[bool] = None, thoth_provenance_manager: Optional[bool] = None, last_run_before: Optional[datetime.datetime] = None, last_run_after: Optional[datetime.datetime] = None, external_python_software_stack_id: Optional[int] = None, external_software_environment_id: Optional[int] = None, advised_python_software_stack_id: Optional[int] = None) List[Dict[str, Any]][source]

Get all github kebechet installations with optional filters on values.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_kebechet_github_installations_all() [

{

“id”: 0, “slug”: “thoth-station/storages”, “repo_name”: “storages”, “private”: False, “is_active”: True, “info_manager”: True, “pipfile_requirements_manager”: True, …

] :rtype: List[Dict[str, Any]] :returns: A list of kebechet installations which match the applied filters

get_kebechet_github_installation_info_with_software_environment_all(*, python_version: Optional[str] = None, image_name: Optional[str] = None, image_sha: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, thoth_image_name: Optional[str] = None, thoth_image_version: Optional[str] = None, env_image_name: Optional[str] = None, env_image_tag: Optional[str] = None, cuda_version: Optional[str] = None, environment_type: Optional[str] = None) List[Dict[str, Any]][source]

Get all github kebechet installations with optional filters on software environment.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_kebechet_github_installation_info_with_software_environment_all() [

{

“id”: 0, “slug”: “thoth-station/storages”, “repo_name”: “storages”, “private”: False, “is_active”: True, “info_manager”: True, “pipfile_requirements_manager”: True, …

] :rtype: List[Dict[str, Any]] :returns: A list of kebechet installations which match the applied filters

get_kebechet_github_installations_active_managers(slug: str, runtime_environment_name: Optional[str] = None) list[source]

Return the list of active managers for a particular repository.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_kebechet_github_installations_active_managers(

slug=”thoth-station/srcops-testing”

) [‘thoth_advise_manager’]

get_kebechet_github_installations_active_managers_count_all(kebechet_manager: str, distinct: bool = False) int[source]

Return the number of repos with specific manager active.

Return type

int

:returns Number of active records for registered Kebechet manager.

get_kebechet_github_installations_info_for_python_package_version(package_name: str, *, package_version: Optional[str] = None, index_url: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None) Dict[str, Dict[str, Any]][source]

Return info about repo containing Python Package in the software stack.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_kebechet_github_installations_info_for_python_package_version(

package_name=’click’ index_url=”https://pypi.org/simple”,

)

{
‘thoth-station/jupyter-nbrequirements’:
{

‘environment_name’: ‘ubi8’, ‘installation_id’: ‘193650988’, ‘private’: False, ‘package_name’: ‘click’, ‘package_version’: ‘7.1.2’, ‘index_url’: ‘https://pypi.org/simple’}

}

get_kebechet_github_installations_software_stack_count_all(*, is_active: Optional[bool] = None)[source]

Get number of Kebechet maintained software stacks.

get_last_analysis_datetime() datetime.datetime[source]

Get the datetime of the last container image analysis synced in the database.

get_last_analysis_document_id(thoth_image_name: str, thoth_image_version: str, *, is_external: bool = False) Optional[Dict[str, str]][source]

Get last image analysis (if any) for the given container image.

get_last_solver_datetime(os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None) datetime.datetime[source]

Get the datetime of the last solver run synced in the database.

get_main_table_count() Dict[str, int][source]

Retrieve dictionary mapping main tables to records count.

get_origin_count_per_source_type(distinct: bool = False) Dict[str, Dict[Tuple[str, str], int]][source]

Retrieve number of users of adviser per source type.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_origin_count_per_source_type() {‘KEBECHET’: 48, ‘JUPYTER_NOTEBOOK’: 18, ‘CLI’: 513} >>> graph.get_origin_count_per_source_type(distinct=True) {‘KEBECHET’: 5, ‘JUPYTER_NOTEBOOK’: 2, ‘CLI’: 78}

get_performance_table_count() Dict[str, int][source]

Get dictionary mapping performance tables to records count.

get_pi_component_all() List[str][source]

Retrieve pi components in Thoth database.

get_pi_count(component: str) Dict[str, int][source]

Get dictionary with number of Performance Indicators per type for the PI component selected.

get_python_cve_records_all(package_name: str, package_version: Optional[str] = None) List[dict][source]

Get known vulnerabilities for the given package-version.

get_python_cve_records_count() int[source]

Get number of CVE in Thoth database.

get_python_environment_marker(package_name: str, package_version: str, index_url: str, *, dependency_name: str, dependency_version: str, os_name: str, os_version: str, python_version: str, marker_evaluation_result: Optional[bool] = None) Optional[str][source]

Get Python evaluation marker as per PEP-0508.

@raises NotFoundError: if the given package has no entry in the database

get_python_environment_marker_evaluation_result(package_name: str, package_version: str, index_url: str, *, dependency_name: str, dependency_version: str, os_name: str, os_version: str, python_version: str) bool[source]

Get result of the Python evaluation marker.

The extra part of the environment marker (an exception in PEP-0508) is not taken into account and is substituted with a value which always defaults to True (as it would cause an error during context interpreting). See solver implementation for details.

@raises NotFoundError: if the given package has no entry in the database

get_python_package_hashes_sha256(package_name: str, package_version: str, index_url: str, *, distinct: bool = False) List[str][source]

Get all hashes for Python package in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_hashes_sha256() [

‘9d6863f6c70d034b8c34b3355cb7ba7d2ad799583947265efda41fe67127c23f’, ‘8e4a1f6d89cfaadb486237acbfa24700add01da022dfcf3536e5071d21e13ee0’

]

get_python_package_index_all(enabled: Optional[bool] = None) List[Dict[str, Any]][source]

Get listing of Python package indexes registered in the graph database.

get_python_package_index_urls_all(enabled: Optional[bool] = None) List[str][source]

Retrieve all the URLs of registered Python package indexes.

get_python_package_required_symbols(package_name: str, package_version: str, index_url: str) List[str][source]

Get required symbols for a Python package in a specified version.

get_python_package_version_all(analysis_document_id: str) List[Dict[str, str]][source]

Retrieve Python package information for the given container image analysis.

get_python_package_version_dependents_all(package_name: str, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: int = 100) List[Dict[str, Any]][source]

Get dependents for the given package.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_dependents(“selinon”, os_name=”rhel”, os_version=”8”, python_version=”3.6”) [

{

“index_url”: “https://pypi.org/simple”, “package_name”: “thoth-worker”, “package_version”: “0.0.2”, “version_range”: “>=1.0.0”, “marker_evaluation_result”: True, “marker”: None, “extra”: None,

}

]

get_python_package_version_entities_count_all(*, distinct: bool = False) int[source]

Retrieve number of all Python packages in Thoth Database.

get_python_package_version_entities_names_all() List[str][source]

Retrieve names of Python package entities in the Thoth’s knowledge base.

get_python_package_version_import_packages_all(import_name: str, distinct: bool = False) List[Dict[str, str]][source]

Retrieve Python package name for the given import package name.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_version_import_packages_all(“faust.*”) [

{‘import’: ‘faust.web.apps’,

‘index_url’: ‘https://pypi.org/simple’, ‘package_name’: ‘faust’, ‘package_version’: ‘1.9.0’},

{‘import’: ‘faust.web.cache’,

‘index_url’: ‘https://pypi.org/simple’, ‘package_name’: ‘faust’, ‘package_version’: ‘1.9.0’},

{‘import’: ‘faust.web.cache.backends’,

‘index_url’: ‘https://pypi.org/simple’, ‘package_name’: ‘faust’, ‘package_version’: ‘1.9.0’},

{‘import’: ‘faust.web.drivers’,

‘index_url’: ‘https://pypi.org/simple’, ‘package_name’: ‘faust’, ‘package_version’: ‘1.9.0’} …

]

get_python_package_version_metadata(package_name: str, package_version: str, index_url: str) Dict[str, str][source]

Retrieve Python package metadata.

get_python_package_version_names_all(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, sort: bool = False, like: Optional[str] = None) List[str][source]

Retrieve names of Python Packages known by Thoth.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_packages_names_all() [‘regex’, ‘tensorflow’]

get_python_package_version_names_count_all(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, like: Optional[str] = None) int[source]

Retrieve names of Python Packages known by Thoth.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_packages_names_count_all() 156468

static get_python_package_version_platform_all() List[str][source]

Retrieve all platforms stored in the database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_version_platform_all() [‘linux-x86_64’]

get_python_package_version_records(package_name: str, package_version: str, index_url: Optional[str], *, os_name: Optional[str], os_version: Optional[str], python_version: Optional[str]) List[dict][source]

Get records for the given package regardless of index_url.

get_python_package_version_solver_rules_all(package_name: str, package_version: Optional[str] = None, index_url: Optional[str] = None) List[Tuple[int, Optional[str], Optional[str], str]][source]

Get rules assigned for the given Python package.

get_python_package_version_trove_classifiers_all(package_name: str, package_version: str, index_url: str, *, os_name: str, os_version: str, python_version: str) List[str][source]

Get Python trove classifiers.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_version_trove_classifiers_all( “cowsay”, “4.0”, “https://pypi.org/simple”, os_name=”rhel”, os_version=”9”, python_version=”3.9”) [“PROGRAMMING LANGUAGE :: PYTHON :: 3.9”, “OPERATING SYSTEM :: OS INDEPENDENT”]

get_python_package_versions_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, is_missing: Optional[bool] = None) List[Tuple[str, str, str]][source]

Retrieve Python package versions in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_versions_all() [(‘regex’, ‘2018.11.7’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘1.11.0’, ‘https://pypi.org/simple’)]

get_python_package_versions_all_count(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, sort_by: Optional[thoth.storages.graph.enums.QuerySortTypeEnum] = None) thoth.storages.graph.query_result_base.PythonQueryResult[source]

Retrieve number of versions per Python package name in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_versions_all_count() {‘setuptools’: 988, ‘pip’: 211, ‘termcolor’: 14, ‘six’: 42}

get_python_package_versions_count(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[Tuple[str, str, str], int][source]

Retrieve number of Python Package (package_name, package_version, index_url) in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_versions_count() {(‘absl-py’, ‘0.1.10’, ‘https://pypi.org/simple’): 1, (‘absl-py’, ‘0.2.1’, ‘https://pypi.org/simple’): 1}

get_python_package_versions_count_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, is_missing: Optional[bool] = None) int[source]

Retrieve Python package versions number in Thoth Database.

get_python_package_versions_count_per_index(index_url: str, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, Dict[Tuple[str, str], int]][source]

Retrieve number of Python package versions per index url in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_versions_count_per_index(index_url=’https://pypi.org/simple’) {’https://pypi.org/simple’: {(‘absl-py’, ‘0.1.10’): 1, (‘absl-py’, ‘0.2.1’): 1}}

get_python_package_versions_count_per_version(package_name: str, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, Dict[str, int]][source]

Retrieve number of Python package versions per index url in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_package_versions_count_per_version(package_name=’tensorflow’) {‘1.14.0rc0’: {’https://pypi.org/simple’: 1}, ‘1.13.0rc2’: {’https://pypi.org/simple’: 1}}

get_python_package_versions_per_index(index_url: str, *, distinct: bool = False) Dict[str, List[str]][source]

Retrieve listing of Python packages (solved) known to graph database instance for the given index.

get_python_packages_all(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) List[Tuple[str, str]][source]

Retrieve Python packages with index in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_packages_all() [(‘regex’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘https://pypi.org/simple’)]

get_python_packages_all_versions(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, List[Tuple[str, str]]][source]

Retrieve Python package versions per package in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_python_packages_all_versions() {‘absl-py’: [(‘0.1.10’, ‘https://pypi.org/simple’), (‘0.2.1’, ‘https://pypi.org/simple’)]}

get_python_packages_count_all(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) int[source]

Retrieve number of versions per Python package in Thoth Database.

get_python_rule(rule_id: int) Dict[str, Any][source]

Get the given Python rule.

get_python_rule_all(*, package_name: Optional[str] = None, index_url: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100) List[Dict[str, Any]][source]

Get all the Python rules matching the given query criteria.

get_python_software_stack_count_all(is_external: bool = False, software_stack_type: Optional[str] = None, distinct: bool = False) int[source]

Get number of Python software stacks available filtered by type.

get_relation_table_count() Dict[str, int][source]

Retrieve dictionary mapping relation tables to records count.

get_rpm_package_version_all(analysis_document_id: str) List[Dict[str, str]][source]

Retrieve RPM package information for the given container image analysis.

get_run_software_environment_all(start_offset: int = 0, count: Optional[int] = 100, is_external: bool = False) List[str][source]

Get all software environments available for run.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_run_software_environment_all() [‘quay.io/thoth-station/thoth-pylint:v0.7.0-ubi8’]

get_run_software_environment_analyses_all(run_software_environment_name: str, start_offset: int = 0, count: Optional[int] = 100, convert_datetime: bool = True, is_external: bool = False) List[dict][source]

Get listing of analyses available for the given software environment for run.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_run_software_environment_analyses_all() [{

‘analysis_datetime’: datetime(2019, 10, 7, 18, 57, 22, 658131), ‘analysis_document_id’: ‘package-extract-2ef02c9cea8b1ef7’, ‘package_extract_name’: ‘thoth-package-extract’, ‘package_extract_version’: ‘1.0.1’ }]

get_script_alembic_version_head() str[source]

Get alembic version head from alembic folder scripts.

get_si_aggregated_python_package_version(package_name: str, package_version: str, index_url: str) Dict[str, int][source]

Get Aggregate Security Indicators (SI) results per Python package version.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_si_aggregated_python_package_version(

package_name=’thoth-common’, package_version=’0.10.0’, index_url=’https://pypi.org/simple

)
{

‘severity_high_confidence_high’: 0, ‘severity_high_confidence_low’: 0, ‘severity_high_confidence_medium’: 0, ‘severity_high_confidence_undefined’: 0, ‘severity_low_confidence_high’: 0, ‘severity_low_confidence_low’: 0, ‘severity_low_confidence_medium’: 0, ‘severity_low_confidence_undefined’: 0, ‘severity_medium_confidence_high’: 0, ‘severity_medium_confidence_low’: 0, ‘severity_medium_confidence_medium’: 0, ‘severity_medium_confidence_undefined’: 0, ‘number_of_analyzed_files’: 0, ‘number_of_files_total’: 0, ‘number_of_files_with_severities’: 0, ‘number_of_filtered_files’: 0, ‘number_of_python_files’: 39, ‘number_of_lines_with_comments_in_python_files’: 922, ‘number_of_blank_lines_in_python_files’: 2760, ‘number_of_lines_with_code_in_python_files’: 9509, ‘total_number_of_files’: 75, ‘total_number_of_lines’: 36856, ‘total_number_of_lines_with_comments’: 2895, ‘total_number_of_blank_lines’: 6737, ‘total_number_of_lines_with_code’: 27224

}

get_si_analyzed_python_package_versions_all(*, distinct: bool = False) List[Tuple[str, str, str]][source]

Get SI analyzed Python package versions in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_si_analyzed_python_package_versions_all() [(‘fbprophet’, ‘0.4’, ‘https://pypi.org/simple’)]

get_si_analyzed_python_package_versions_count_all(*, distinct: bool = False) int[source]

Get SI analyzed Python package versions number in Thoth Database.

get_si_unanalyzed_python_package_versions_all(start_offset: int = 0, count: Optional[int] = 100, distinct: bool = True, randomize: bool = True, provides_source_distro: bool = True, si_error: bool = False) List[Tuple[str, str, str]][source]

Retrieve solved Python package versions in Thoth Database, that are not anaylyzed by SI.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_si_unanalyzed_python_package_versions_all() [(‘crossbar’, ‘0.10.0’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘1.11.0’, ‘https://pypi.org/simple’)]

get_si_unanalyzed_python_package_versions_count_all(index_url: Optional[str] = None, *, distinct: bool = False, provides_source_distro: bool = True, si_error: bool = False) int[source]

Get SI unanalyzed Python package versions number in Thoth Database.

get_software_environments_all(is_external: bool = False, convert_datetime: bool = True, *, start_offset: int = 0, count: Optional[int] = 100, env_image_name: Optional[str] = None, env_image_tag: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, cuda_version: Optional[str] = None, image_name: Optional[str] = None, library_name: Optional[str] = None, symbol: Optional[str] = None, package_name: Optional[str] = None, rpm_package_name: Optional[str] = None) List[Dict][source]

Get software environments (external or internal) registered in the graph database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_software_environments_all()

[
{

‘cuda_version’: None, ‘datetime’: datetime.datetime(2021, 12, 15, 19, 27, 52, 803266), ‘env_image_name’: None, ‘env_image_tag’: None, ‘environment_name’: ‘quay.io/thoth-station/s2i-thoth-ubi8-py39:v0.32.3’, ‘environment_type’: ‘RUNTIME’, ‘image_sha’: ‘bcf4fa447e5dc889015afb4d3c54ef4a3aaddc3260fce072311602df34ffac3c’, ‘os_name’: ‘rhel’, ‘os_version’: ‘8’, ‘package_extract_document_id’: ‘package-extract-211215162259-33c8d9c730b775eb’, ‘python_version’: ‘3.9’, ‘thoth_image_name’: ‘quay.io/thoth-station/s2i-thoth-ubi8-py39’, ‘thoth_image_version’: ‘0.32.3’ }

]

get_software_environments_count_all(is_external: bool = False, *, env_image_name: Optional[str] = None, env_image_tag: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, cuda_version: Optional[str] = None, image_name: Optional[str] = None, library_name: Optional[str] = None, symbol: Optional[str] = None, package_name: Optional[str] = None, rpm_package_name: Optional[str] = None) int[source]

Get number of software environments stored.

get_solved_python_package_version_environments_all(package_name: str, package_version: str, index_url: str, *, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) List[Dict[str, str]][source]

Retrieve all the environments that were used to solve the given package.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_package_version_environments_all( package_name=”flask”, package_version=”2.0.2”, index_url=”https://pypi.org/simple”) [

{“os_name”: “rhel”, “os_version”: “8”, “python_version”: “3.8”}, {“os_name”: “fedora”, “os_version”: “35”, “python_version”: “3.9”},

]

get_solved_python_package_versions_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, is_missing: Optional[bool] = None) List[Tuple[str, str, str]][source]

Retrieve solved Python package versions in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_package_versions_all() [(‘regex’, ‘2018.11.7’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘1.11.0’, ‘https://pypi.org/simple’)]

get_solved_python_package_versions_count(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[Tuple[str, str, str], int][source]

Retrieve number of Python Package (package_name, package_version, index_url) solved in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_package_versions_count() {(‘absl-py’, ‘0.1.10’, ‘https://pypi.org/simple’): 1, (‘absl-py’, ‘0.2.1’, ‘https://pypi.org/simple’): 1}

get_solved_python_package_versions_count_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, is_missing: Optional[bool] = None) int[source]

Retrieve solved Python package versions number in Thoth Database.

get_solved_python_package_versions_count_per_index(index_url: str, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, Dict[Tuple[str, str], int]][source]

Retrieve number of solved Python package versions per index url in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_package_versions_count_per_index(index_url=’https://pypi.org/simple’) {’https://pypi.org/simple’: {(‘absl-py’, ‘0.1.10’): 1, (‘absl-py’, ‘0.2.1’): 1}}

get_solved_python_package_versions_count_per_version(package_name: str, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, Dict[str, int]][source]

Retrieve number of solved Python package versions per package version in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_package_versions_count_per_version(package_name=’tensorflow’) {‘1.14.0rc0’: {’https://pypi.org/simple’: 1}, ‘1.13.0rc2’: {’https://pypi.org/simple’: 1}}

get_solved_python_package_versions_software_environment_all() List[Dict[str, str]][source]

Retrieve software environment configurations used to solve Python packages.

get_solved_python_packages_all(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) List[Tuple[str, str]][source]

Retrieve solved Python package with index in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_packages_all() [(‘regex’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘https://pypi.org/simple’)]

get_solved_python_packages_all_versions(*, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, List[Tuple[str, str]]][source]

Retrieve solved Python package versions per package in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solved_python_packages_all_versions() {‘absl-py’: [(‘0.1.10’, ‘https://pypi.org/simple’), (‘0.2.1’, ‘https://pypi.org/simple’)]}

get_solved_python_packages_count_all(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) int[source]

Retrieve number of solved Python package versions in Thoth Database.

get_solver_document_id_all(package_name: str, package_version: Optional[str] = None, index_url: Optional[str] = None, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, sort: bool = False) List[str][source]

Get the solver document specific to the given package that has been solved.

If sorted, the latest solver document is at index 0.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.graph.get_solver_document_id_all(“selinon”, “1.0.0”, “https://pypi.org/simple”, os_name=”rhel”, os_version=”8”, python_version=”3.8”, sort=True) [

“solver-rhel-8-py38-210713010253-a24759ebdaa1442c”, “solver-rhel-8-py38-210711003643-187580eee457bb3f”, “solver-rhel-8-py38-210707005412-4965667a05a39006”

]

get_solver_documents_count_all() int[source]

Get number of solver documents synced into graph.

get_solver_run_document_ids_all(initial_date: Optional[str] = None, final_date: Optional[str] = None, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, has_error: bool = False, unsolvable: bool = False, unparseable: bool = False) List[str][source]

Retrieve solver run document ids.

@params initial_date: DD-MM-YY @params final_date: DD-MM-YY

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_solver_run_document_ids_all() [‘solver-rhel-8-py38-343231d’]

get_table_alembic_version_head() str[source]

Get alembic version head from database table.

get_thoth_s2i_all(is_external: bool = False) List[Tuple[str, str]][source]

Get all the Thoth s2i container images available.

get_thoth_s2i_analyzed_image_symbols_all(thoth_image_name: str, thoth_image_version: str, is_external: bool = False) List[str][source]

Get symbols associated with a given Thoth s2i container image.

get_thoth_s2i_package_extract_analysis_document_id_all(thoth_image_name: str, thoth_image_version: str, is_external: bool = False) List[str][source]

Get package-extract analysis ids for the given Thoth s2i.

get_unsolved_python_package_versions_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False, randomize: bool = True) List[Tuple[str, Optional[str], Optional[str]]][source]

Retrieve unsolved Python package versions in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_package_versions_all() [(‘regex’, ‘2018.11.7’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘1.11.0’, ‘https://pypi.org/simple’)]

get_unsolved_python_package_versions_count(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) Dict[Tuple[str, str, str], int][source]

Retrieve number of unsolved versions per Python package in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_package_versions_count() {(‘absl-py’, ‘0.1.10’, ‘https://pypi.org/simple’): 1, (‘absl-py’, ‘0.2.1’, ‘https://pypi.org/simple’): 1}

get_unsolved_python_package_versions_count_all(package_name: Optional[str] = None, package_version: Optional[str] = None, index_url: Optional[str] = None, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) int[source]

Retrieve unsolved Python package versions number in Thoth Database.

get_unsolved_python_package_versions_count_per_index(index_url: str, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) Dict[str, Dict[Tuple[str, str], int]][source]

Retrieve number of unsolved Python package versions per index url in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_package_versions_count_per_index(index_url=’https://pypi.org/simple’) {’https://pypi.org/simple’: {(‘absl-py’, ‘0.1.10’): 1, (‘absl-py’, ‘0.2.1’): 1}}

get_unsolved_python_package_versions_count_per_version(package_name: str, *, start_offset: int = 0, count: Optional[int] = 100, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, distinct: bool = False) Dict[str, Dict[str, int]][source]

Retrieve number of unsolved Python package versions per package version in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_package_versions_count_per_version(package_name=’tensorflow’) {‘1.14.0rc0’: {’https://pypi.org/simple’: 1}, ‘1.13.0rc2’: {’https://pypi.org/simple’: 1}}

get_unsolved_python_packages_all(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) List[Tuple[str, Optional[str]]][source]

Retrieve unsolved Python package with index in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_packages_all() [(‘regex’, ‘https://pypi.org/simple’), (‘tensorflow’, ‘https://pypi.org/simple’)]

get_unsolved_python_packages_all_per_adviser_run(source_type: str) Dict[str, List[str]][source]

Retrieve all unsolved packages for a certain Adviser Run that need to be re run.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_packages_all_per_adviser_run() {‘adviser-04ab56d6’: [‘black’], ‘adviser-054ab56d6’: [‘black’, ‘numpy’]}

get_unsolved_python_packages_all_versions(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, start_offset: int = 0, count: Optional[int] = 100, distinct: bool = False) Dict[str, List[Tuple[str, str]]][source]

Retrieve unsolved Python package versions per package in Thoth Database.

Examples: >>> from thoth.storages import GraphDatabase >>> graph = GraphDatabase() >>> graph.get_unsolved_python_packages_all_versions() {‘absl-py’: [(‘0.1.10’, ‘https://pypi.org/simple’), (‘0.2.1’, ‘https://pypi.org/simple’)]}

has_python_solver_error(package_name: str, package_version: str, index_url: str, *, os_name: Optional[str], os_version: Optional[str], python_version: Optional[str]) bool[source]

Retrieve information whether the given package has any solver error.

initialize_schema()[source]

Initialize schema of database.

inspection_document_id_exist(inspection_document_id: str) bool[source]

Check if there is an inspection document record with the given id.

inspection_document_id_result_number_exists(inspection_document_id: str, inspection_result_number: int) bool[source]

Check if the given inspection id result number record exists in the graph database.

is_database_corrupted() bool[source]

Run the amcheck extension to check for DB corruption, false negatives are possible but false positives are not.

amcheck documenation: https://www.postgresql.org/docs/10/amcheck.html

bool

False: No DB corruption detected by amcheck (not definitive) True: Database is corrupted

is_python_package_index_enabled(url: str) bool[source]

Check if the given Python package index is enabled.

is_python_package_version_is_missing(package_name: str, package_version: str, index_url: str) bool[source]

Check whether is_missing flag is set for python package version.

is_schema_up2date() bool[source]

Check if the current schema is up2date with the one configured on database side.

static normalize_python_index_url(index_url: Optional[str]) Optional[str][source]

Map python index url.

static normalize_python_package_name(package_name: str) str[source]

Normalize Python package name based on PEP-0503.

static normalize_python_package_version(package_version: str) str[source]

Normalize Python package name based on PEP-440.

provenance_checker_document_id_exist(provenance_checker_document_id: str) bool[source]

Check if there is a provenance-checker document record with the given id.

purge_adviser_documents(*, end_datetime: Optional[datetime.datetime] = None, adviser_version: Optional[str] = None) int[source]

Store and purge to be deleted adviser documents to Ceph.

purge_package_extract_documents(*, end_datetime: Optional[datetime.datetime] = None, package_extract_version: Optional[str] = None) int[source]

Store and purge to be deleted package extract documents to Ceph.

purge_solver_documents(*, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None) int[source]

Store and purge to be deleted solver documents to Ceph.

python_package_exists(package_name: str) bool[source]

Check if the given Python package exists regardless of version.

static python_package_version_depends_on_platform_exists(platform: str) bool[source]

Check if the given platform has some records in the database.

python_package_version_exists(package_name: str, package_version: str, index_url: Optional[str] = None, solver_name: Optional[str] = None) bool[source]

Check if the given Python package version exists in the graph database.

If optional solver_name parameter is set, the call answers if the given package was solved by the given solver. Otherwise, any solver run is taken into account.

register_python_package_index(url: str, warehouse_api_url: Optional[str] = None, verify_ssl: bool = True, enabled: bool = False, only_if_package_seen: bool = True) bool[source]

Register the given Python package index in the graph database.

retrieve_dependent_packages(package_name: str, package_version: Optional[str] = None) Dict[str, List[str]][source]

Get mapping package name to package version of packages that depend on the given package.

retrieve_transitive_dependencies_python(package_name: str, package_version: str, index_url: str, *, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None, extras: Optional[FrozenSet[Optional[str]]] = None, marker_evaluation_result: Optional[bool] = None) List[Tuple[Tuple[str, str, str], Tuple[str, str, str], Tuple[str, str, str], Tuple[str, str, str], Optional[Tuple[str, str, str]], Optional[Tuple[str, str, str]]]][source]

Get all transitive dependencies for the given package by traversing dependency graph.

It’s much faster to retrieve just dependency ids for the transitive dependencies as most of the time is otherwise spent in serialization and deserialization of query results. The ids are obtained later on (kept in ids map, see bellow).

The ids map represents a map to optimize number of retrievals - not to perform duplicate queries into graph instance.

Extras are taken into account only for direct dependencies. Any extras required in libraries used in transitive dependencies are not required as solver directly report dependencies regardless extras configuration - see get_depends_on docs for extras parameter values..

retrieve_transitive_dependencies_python_multi(*package_tuples, os_name: Optional[str] = None, os_version: Optional[str] = None, python_version: Optional[str] = None) Dict[Tuple[str, str, str], Set[Tuple[Tuple[str, str, str], Tuple[str, str, str], Tuple[str, str, str], Tuple[str, str, str], Optional[Tuple[str, str, str]], Optional[Tuple[str, str, str]]]]][source]

Get all transitive dependencies for a given set of packages by traversing the dependency graph.

set_cve_timestamp(timestamp: datetime.datetime) None[source]

Set CVE timestamp record.

set_python_package_index_state(url: str, *, enabled: bool) None[source]

Enable or disable Python package index.

si_aggregated_document_id_exists(si_aggregated_run_document_id: str) bool[source]

Check if the given security indicator aggregated report record exists in the graph database.

si_aggregated_python_package_version_exists(package_name: str, package_version: str, index_url: str) bool[source]

Check if Aggregate Security Indicators (SI) results exists for Python package version.

solved_software_environment_exists(os_name: str, os_version: str, python_version: str) bool[source]

Check if there are any solved packages for the given software environment.

solver_document_id_exists(solver_document_id: str) bool[source]

Check if there is a solver document record with the given id.

solver_records_exist(solver_document: dict) bool[source]

Check if the given solver document record exists.

stats() dict[source]

Get statistics for this adapter.

sync_adviser_result(document: dict) None[source]

Sync adviser result into graph database.

sync_analysis_result(document: dict) None[source]

Sync the given analysis result to the graph database.

sync_dependency_monkey_result(document: dict) None[source]

Sync reports of dependency monkey runs.

sync_inspection_result(document) None[source]

Sync the given inspection document into the graph database.

sync_provenance_checker_result(document: dict) None[source]

Sync provenance checker results into graph database.

sync_revsolver_result(document: Dict[str, Any]) None[source]

Sync results of the reverse solver.

This updates relations for DependsOn on a new package release.

sync_security_indicator_aggregated_result(document: dict) None[source]

Sync the given security-indicator aggregated result to the graph database.

sync_solver_result(document: dict, *, force: bool = False) None[source]

Sync the given solver result to the graph database.

update_kebechet_github_installations_on_is_active(slug: str) bool[source]

Deactivate the app on getting an uninstall event.

Passed a slug name to be deactivated. Example - slug:’thoth-station/advisor’ :rtype: True, False :returns True: if installation existed and was deactivated. :returns False: if installation was not found.

update_kebechet_installation_using_files(slug: str, installation_id: str, requirements: Optional[dict] = None, requirements_lock: Optional[dict] = None, thoth_config: Optional[dict] = None, runtime_environment_name: Optional[str] = None, private: bool = False)[source]

Update info about kebechet installation.

update_missing_flag_package_version(package_name: str, package_version: str, index_url: str, value: bool) None[source]

Update value of is_missing flag for PythonPackageVersion.

update_provides_source_distro_package_version(package_name: str, package_version: str, index_url: str, value: bool) None[source]

Update value of is_si_analyzable flag for PythonPackageVersion.

update_python_package_hash_present_flag(package_name: str, package_version: str, index_url: str, sha256_hash: str)[source]

Remove hash associated with python package in the graph.