thoth.common package

Submodules

thoth.common.exceptions module

Exceptions used within thoth-common package.

exception thoth.common.exceptions.ConfigurationError[source]

Bases: thoth.common.exceptions.ThothCommonException

Raised on miss-configuration issues.

exception thoth.common.exceptions.NotFoundException[source]

Bases: thoth.common.exceptions.ThothCommonException

Raised if the given resource cannot be found.

exception thoth.common.exceptions.ThothCommonException[source]

Bases: Exception

A base class for Thoth-common exception hierarchy.

thoth.common.helpers module

Various utilities to make your life easier.

thoth.common.helpers.cwd(target: str) → Generator[[str, None], None][source]

Manage cwd in a pushd/popd fashion.

thoth.common.helpers.datetime2datetime_str(dt: Optional[datetime.datetime] = None) → str[source]

Create a string representation of a datetime.

thoth.common.helpers.datetime_str2timestamp(datetime_string: str) → int[source]

Parse datetime string represented in ISO format and return timestamp.

thoth.common.helpers.datetime_str_from_timestamp(timestamp: int) → str[source]

Convert a timestamp to datetime string representation.

thoth.common.helpers.format_datetime(dt: datetime.datetime) → str[source]

Return datetime string in default format.

thoth.common.helpers.get_default_datetime_format() → str[source]

Return default datetime format string.

thoth.common.helpers.get_service_account_token() → str[source]

Get token from service account token file.

thoth.common.helpers.parse_datetime(datetime_string: str) → datetime.datetime[source]

Parse datetime string represented in ISO format.

thoth.common.helpers.timestamp2datetime(timestamp: int) → datetime.datetime[source]

Convert a timestamp to datetime respecting UTC.

thoth.common.json module

Manipulation with JSON format.

class thoth.common.json.SafeJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

Convert objects to JSON, safely.

default(o: Any) → Any[source]

Convert an object to JSON, safely.

thoth.common.logging module

Logging configuration for whole Thoth.

thoth.common.logging.init_logging(logging_configuration: Optional[Dict[str, str]] = None, logging_env_var_start: Optional[str] = None) → None[source]

Initialize Thoth’s logging - respects all namespaces.

This function allows you to control logging facilities in Thoth. Logging can be configured via env variables so that deployment can respect your configuration. The structure of environment variables is THOTH_LOG_(MODULE) and the value of env variable states verbosity level as in the logging module (DEBUG, INFO, WARNING, ERROR).

>>> import os
>>> os.environ['THOTH_LOG_SOLVER']
WARNING

You can also specify more closely which sub-module logging you are configuring - submodules are separated with double dash:

>>> os.environ['THOTH_LOG_SOLVER__PYTHON']
DEBUG

You can also use arguments explicitly that override configuration in env variables (a shorthand for standard logging functionality):

>>> init_logging({'thoth.solver': 'DEBUG'})

Optionally you can specify prefix of the logging environment variable determining logging configuration via env vars (defaults to THOTH_LOG_).

thoth.common.openshift module

Handling OpenShift and Kubernetes objects across project.

class thoth.common.openshift.OpenShift(*, frontend_namespace: Optional[str] = None, middletier_namespace: Optional[str] = None, backend_namespace: Optional[str] = None, infra_namespace: Optional[str] = None, amun_infra_namespace: Optional[str] = None, amun_inspection_namespace: Optional[str] = None, kubernetes_api_url: Optional[str] = None, kubernetes_verify_tls: bool = True, openshift_api_url: Optional[str] = None, token: Optional[str] = None, token_file: Optional[str] = None, cert_file: Optional[str] = None, environ: Optional[Dict[str, str]] = None)[source]

Bases: object

Interaction with OpenShift Master.

can_run_workload(template: Dict[str, Any], namespace: str) → bool[source]

Check if the given (job) can be run in the given namespace based on mem, cpu and pod restrictions.

create_config_map(configmap_name: str, namespace: str, labels: Dict[str, str], data: Dict[str, str]) → str[source]

Create a ConfigMap in the given namespace.

create_inspection_imagestream(inspection_id: str) → str[source]

Create imagestream for Amun.

get_adviser_template() → Dict[str, Any][source]

Get template for an adviser run.

get_build(build_id: str, namespace: str) → Dict[str, Any][source]

Get a build in the given namespace.

get_build_analyze_template() → Dict[str, Any][source]

Get template for build analyze run.

get_build_dependencies_template() → Dict[str, Any][source]

Get template for build dependencies run.

get_build_log(build_id: str, namespace: str) → str[source]

Get log of a build in the given namespace.

get_build_report_template() → Dict[str, Any][source]

Get template for build report run.

get_buildconfig(buildconfig_id: str, namespace: str) → Dict[str, Any][source]

Get a buildconfig in the given namespace.

get_configmap(configmap_id: str, namespace: str) → Dict[str, Any][source]

Get the given configmap in a namespace, return object representing config map.

get_configmaps(namespace: str, label_selector: str) → Dict[str, Any][source]

Get all configmaps in a namespace and select them by label.

get_dependency_monkey_template() → Dict[str, Any][source]

Get template for a dependency monkey.

get_graph_sync_template() → Dict[str, Any][source]

Get graph sync template.

get_inspection_build_template(use_hw_template: bool, parameters: Dict[str, str]) → Dict[str, Any][source]

Get inspection buildconfig that should be run.

get_inspection_job_template(*, use_hw_template: bool, cpu_requests: Optional[str] = None, memory_requests: Optional[str] = None) → Dict[str, Any][source]

Get template for an inspection job.

get_job_log(job_id: str, namespace: str) → Optional[str][source]

Get log of a pod running inside a job.

get_job_status_count(label_selector: str, namespace: str) → Dict[str, int][source]

Count the number of Jobs per status in a specific namespace.

get_job_status_report(job_id: str, namespace: str) → Dict[str, Optional[str]][source]

Get status of a pod running inside a job.

get_jobs(label_selector: str, namespace: Optional[str] = None) → Dict[str, Any][source]

Get all Jobs, select them by the provided label.

get_kebechet_template() → Dict[str, Any][source]

Get template for a Kebechet job.

get_package_analyzer_template() → Dict[str, Any][source]

Get template for package-analyzer.

get_package_extract_template() → Dict[str, Any][source]

Get template for package-extract.

get_pod_log(pod_id: str, namespace: Optional[str] = None) → Optional[str][source]

Get log of a pod based on assigned pod ID.

get_pod_status(pod_id: str, namespace: str) → Dict[str, Any][source]

Get status entry for a pod - low level routine.

get_pod_status_report(pod_id: str, namespace: str) → Dict[str, Optional[str]][source]

Get pod state and convert it to a user-friendly response.

get_provenance_checker_template() → Dict[str, Any][source]

Get template for a provenance checker.

get_quota_status(namespace: str) → Dict[str, Dict[str, Any]][source]

Get quota status.

For now, there is retrieved a very first quota specification and its status from resource quota list, we gather information about memory, CPU usage and number of pods.

get_solver_names() → List[str][source]

Retrieve name of solvers available in installation.

get_solver_template(solver: str) → Dict[str, Any][source]

Retrieve a solver template.

oc_process(namespace: str, template: Dict[str, Any]) → Dict[str, Any][source]

Process the given template in OpenShift.

static parse_cpu_spec(cpu_spec: Optional[str]) → Optional[float][source]

Parse the given CPU requirement as used by OpenShift/Kubernetes.

static parse_memory_spec(memory_spec: Optional[str]) → Optional[float][source]

Parse the given CPU requirement as used by OpenShift/Kubernetes.

run_adviser(application_stack: Dict[Any, Any], output: str, recommendation_type: str, *, count: Optional[int] = None, limit: Optional[int] = None, runtime_environment: Optional[Dict[Any, Any]] = None, library_usage: Optional[Dict[Any, Any]] = None, origin: Optional[str] = None, debug: bool = False, job_id: Optional[str] = None, limit_latest_versions: Optional[int] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run adviser on the provided user input.

run_build_analyze(document_id: str, output: str, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run build analyze on the provided user input.

run_build_dependencies(document_id: str, output: str, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run build dependencies on the provided user input.

run_build_report(document_id: str, output: str, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run build report on the provided user input.

run_dependency_monkey(requirements: Union[str, Dict[str, Any]], context: Dict[str, Any], *, stack_output: Optional[str] = None, report_output: Optional[str] = None, seed: Optional[int] = None, dry_run: bool = False, decision: Optional[str] = None, count: Optional[int] = None, debug: bool = False, job_id: Optional[str] = None, limit_latest_versions: Optional[int] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run Dependency Monkey on the provided user input.

run_graph_sync(document_id: str, namespace: str, graph_sync_type: str, force_sync: str, *, template: Optional[Dict[str, Any]] = None, job_id: Optional[str] = None) → str[source]

Run the given graph sync.

run_inspection_build(template: Dict[str, Any]) → str[source]

Run the inspection build.

run_inspection_job(parameters: Dict[str, str], template: Optional[Dict[str, Any]] = None, *, use_hw_template: bool = False, cpu_requests: Optional[str] = None, memory_requests: Optional[str] = None, infra_namespace: Optional[str] = None, registry: Optional[str] = None) → str[source]

Create the actual inspection job.

run_kebechet_run_results(url: str, service: str, analysis_id: str, *, verbose: bool = False, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Create a kebechet run-results job.

run_kebechet_run_url(url: str, service: str, *, verbose: bool = False, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Create a kebechet run-url job.

run_package_analyzer(package_name: str, package_version: str, index_url: str, *, output: str, debug: bool = False, dry_run: bool = False, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run package-analyzer to gather digests of packages and files present inside packages.

run_package_extract(image: str, output: str, *, environment_type: str, is_external: bool = True, origin: Optional[str] = None, registry_user: Optional[str] = None, registry_password: Optional[str] = None, verify_tls: bool = True, debug: bool = False, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run package-extract analyzer to extract information from the provided image.

run_provenance_checker(application_stack: Dict[Any, Any], output: str, *, origin: Optional[str] = None, whitelisted_sources: Optional[List[str]] = None, debug: bool = False, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run provenance checks on the provided user input.

run_solver(packages: str, output: str, solver: str, *, indexes: Optional[List[str]] = None, debug: bool = False, transitive: bool = True, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run solver or all solver to solve the given requirements.

schedule_adviser(application_stack: Dict[Any, Any], output: str, recommendation_type: str, *, count: Optional[int] = None, limit: Optional[int] = None, runtime_environment: Optional[Dict[Any, Any]] = None, library_usage: Optional[Dict[Any, Any]] = None, origin: Optional[str] = None, debug: bool = False, job_id: Optional[str] = None, limit_latest_versions: Optional[int] = None) → str[source]

Schedule an adviser run.

schedule_all_solvers(packages: str, output: str, *, indexes: Optional[List[str]] = None, debug: bool = False, transitive: bool = False) → List[str][source]

Schedule all solvers for the given packages.

schedule_build_analyze(document_id: str, output: str, job_id: Optional[str] = None) → str[source]

Schedule an build analyze run.

schedule_build_dependencies(document_id: str, output: str, job_id: Optional[str] = None) → str[source]

Schedule an build analyze run.

schedule_build_report(document_id: str, output: str, job_id: Optional[str] = None) → str[source]

Schedule an build report run.

schedule_dependency_monkey(requirements: Union[str, Dict[str, Any]], context: Dict[str, Any], *, stack_output: Optional[str] = None, report_output: Optional[str] = None, seed: Optional[int] = None, dry_run: bool = False, decision: Optional[str] = None, count: Optional[int] = None, debug: bool = False, job_id: Optional[str] = None, limit_latest_versions: Optional[int] = None) → str[source]

Schedule a dependency monkey run.

schedule_graph_refresh(namespace: Optional[str] = None) → str[source]

Schedule graph refresh job in frontend namespace by default.

schedule_graph_sync_adviser(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of an adviser document.

schedule_graph_sync_dependency_monkey(document_id: str, *, force_sync: bool = False, namespace: str) → str[source]

Schedule a sync of a dependency monkey result.

schedule_graph_sync_inspection(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of inspection.

schedule_graph_sync_package_analyzer(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of an package-analysis document.

schedule_graph_sync_package_extract(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of package-extract.

schedule_graph_sync_provenance_checker(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of a provenance checker result.

schedule_graph_sync_solver(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of solver result.

schedule_inspection_build(parameters: Dict[str, Any], inspection_id: str, use_hw_template: bool) → str[source]

Schedule inspection build.

schedule_inspection_job(inspection_id: str, parameters: Dict[str, str], use_hw_template: bool, cpu_requests: str, memory_requests: str, infra_namespace: Optional[str] = None, registry: Optional[str] = None) → str[source]

Schedule the given job run, the scheduled job is handled by workload operator based resources available.

schedule_kebechet_run_results(url: str, service: str, analysis_id: str, *, verbose: bool = False, job_id: Optional[str] = None) → str[source]

Schedule a kebechet run.

schedule_kebechet_run_url(url: str, service: str, *, verbose: bool = False, job_id: Optional[str] = None) → str[source]

Schedule a kebechet run.

schedule_package_analyzer(package_name: str, package_version: str, index_url: str, *, output: str, debug: bool = False, dry_run: bool = False, job_id: Optional[str] = None) → str[source]

Schedule the given job run, the scheduled job is handled by workload operator based resources available.

schedule_package_extract(image: str, output: str, *, environment_type: str, is_external: bool = True, origin: Optional[str] = None, registry_user: Optional[str] = None, registry_password: Optional[str] = None, verify_tls: bool = True, debug: bool = False, job_id: Optional[str] = None) → str[source]

Schedule the given job run, the scheduled job is handled by workload operator based resources available.

schedule_provenance_checker(application_stack: Dict[Any, Any], output: str, *, origin: Optional[str] = None, whitelisted_sources: Optional[List[str]] = None, debug: bool = False, job_id: Optional[str] = None) → str[source]

Schedule a provenance checker run.

schedule_solver(packages: str, output: str, solver: str, *, indexes: Optional[List[str]] = None, debug: bool = False, transitive: bool = True, job_id: Optional[str] = None) → str[source]

Schedule the given solver.

static set_template_parameters(template: Dict[str, Any], **parameters: Any) → None[source]

Set parameters in the template - replace existing ones or append to parameter list if not exist.

>>> set_template_parameters(template, THOTH_LOG_ADVISER='DEBUG')
property token

Access service account token mounted to the pod.

Module contents

Shared code across Thoth analyzers.

thoth.common.cwd(target: str) → Generator[[str, None], None][source]

Manage cwd in a pushd/popd fashion.

thoth.common.datetime2datetime_str(dt: Optional[datetime.datetime] = None) → str[source]

Create a string representation of a datetime.

thoth.common.datetime_str2timestamp(datetime_string: str) → int[source]

Parse datetime string represented in ISO format and return timestamp.

thoth.common.datetime_str_from_timestamp(timestamp: int) → str[source]

Convert a timestamp to datetime string representation.

thoth.common.get_service_account_token() → str[source]

Get token from service account token file.

class thoth.common.HardwareInformation(cpu_family: int = None, cpu_model: int = None)[source]

Bases: thoth.common.config.base.ConfigEntryBase

Representation for hardware related information.

cpu_family
cpu_model
thoth.common.init_logging(logging_configuration: Optional[Dict[str, str]] = None, logging_env_var_start: Optional[str] = None) → None[source]

Initialize Thoth’s logging - respects all namespaces.

This function allows you to control logging facilities in Thoth. Logging can be configured via env variables so that deployment can respect your configuration. The structure of environment variables is THOTH_LOG_(MODULE) and the value of env variable states verbosity level as in the logging module (DEBUG, INFO, WARNING, ERROR).

>>> import os
>>> os.environ['THOTH_LOG_SOLVER']
WARNING

You can also specify more closely which sub-module logging you are configuring - submodules are separated with double dash:

>>> os.environ['THOTH_LOG_SOLVER__PYTHON']
DEBUG

You can also use arguments explicitly that override configuration in env variables (a shorthand for standard logging functionality):

>>> init_logging({'thoth.solver': 'DEBUG'})

Optionally you can specify prefix of the logging environment variable determining logging configuration via env vars (defaults to THOTH_LOG_).

class thoth.common.OpenShift(*, frontend_namespace: Optional[str] = None, middletier_namespace: Optional[str] = None, backend_namespace: Optional[str] = None, infra_namespace: Optional[str] = None, amun_infra_namespace: Optional[str] = None, amun_inspection_namespace: Optional[str] = None, kubernetes_api_url: Optional[str] = None, kubernetes_verify_tls: bool = True, openshift_api_url: Optional[str] = None, token: Optional[str] = None, token_file: Optional[str] = None, cert_file: Optional[str] = None, environ: Optional[Dict[str, str]] = None)[source]

Bases: object

Interaction with OpenShift Master.

can_run_workload(template: Dict[str, Any], namespace: str) → bool[source]

Check if the given (job) can be run in the given namespace based on mem, cpu and pod restrictions.

create_config_map(configmap_name: str, namespace: str, labels: Dict[str, str], data: Dict[str, str]) → str[source]

Create a ConfigMap in the given namespace.

create_inspection_imagestream(inspection_id: str) → str[source]

Create imagestream for Amun.

get_adviser_template() → Dict[str, Any][source]

Get template for an adviser run.

get_build(build_id: str, namespace: str) → Dict[str, Any][source]

Get a build in the given namespace.

get_build_analyze_template() → Dict[str, Any][source]

Get template for build analyze run.

get_build_dependencies_template() → Dict[str, Any][source]

Get template for build dependencies run.

get_build_log(build_id: str, namespace: str) → str[source]

Get log of a build in the given namespace.

get_build_report_template() → Dict[str, Any][source]

Get template for build report run.

get_buildconfig(buildconfig_id: str, namespace: str) → Dict[str, Any][source]

Get a buildconfig in the given namespace.

get_configmap(configmap_id: str, namespace: str) → Dict[str, Any][source]

Get the given configmap in a namespace, return object representing config map.

get_configmaps(namespace: str, label_selector: str) → Dict[str, Any][source]

Get all configmaps in a namespace and select them by label.

get_dependency_monkey_template() → Dict[str, Any][source]

Get template for a dependency monkey.

get_graph_sync_template() → Dict[str, Any][source]

Get graph sync template.

get_inspection_build_template(use_hw_template: bool, parameters: Dict[str, str]) → Dict[str, Any][source]

Get inspection buildconfig that should be run.

get_inspection_job_template(*, use_hw_template: bool, cpu_requests: Optional[str] = None, memory_requests: Optional[str] = None) → Dict[str, Any][source]

Get template for an inspection job.

get_job_log(job_id: str, namespace: str) → Optional[str][source]

Get log of a pod running inside a job.

get_job_status_count(label_selector: str, namespace: str) → Dict[str, int][source]

Count the number of Jobs per status in a specific namespace.

get_job_status_report(job_id: str, namespace: str) → Dict[str, Optional[str]][source]

Get status of a pod running inside a job.

get_jobs(label_selector: str, namespace: Optional[str] = None) → Dict[str, Any][source]

Get all Jobs, select them by the provided label.

get_kebechet_template() → Dict[str, Any][source]

Get template for a Kebechet job.

get_package_analyzer_template() → Dict[str, Any][source]

Get template for package-analyzer.

get_package_extract_template() → Dict[str, Any][source]

Get template for package-extract.

get_pod_log(pod_id: str, namespace: Optional[str] = None) → Optional[str][source]

Get log of a pod based on assigned pod ID.

get_pod_status(pod_id: str, namespace: str) → Dict[str, Any][source]

Get status entry for a pod - low level routine.

get_pod_status_report(pod_id: str, namespace: str) → Dict[str, Optional[str]][source]

Get pod state and convert it to a user-friendly response.

get_provenance_checker_template() → Dict[str, Any][source]

Get template for a provenance checker.

get_quota_status(namespace: str) → Dict[str, Dict[str, Any]][source]

Get quota status.

For now, there is retrieved a very first quota specification and its status from resource quota list, we gather information about memory, CPU usage and number of pods.

get_solver_names() → List[str][source]

Retrieve name of solvers available in installation.

get_solver_template(solver: str) → Dict[str, Any][source]

Retrieve a solver template.

oc_process(namespace: str, template: Dict[str, Any]) → Dict[str, Any][source]

Process the given template in OpenShift.

static parse_cpu_spec(cpu_spec: Optional[str]) → Optional[float][source]

Parse the given CPU requirement as used by OpenShift/Kubernetes.

static parse_memory_spec(memory_spec: Optional[str]) → Optional[float][source]

Parse the given CPU requirement as used by OpenShift/Kubernetes.

run_adviser(application_stack: Dict[Any, Any], output: str, recommendation_type: str, *, count: Optional[int] = None, limit: Optional[int] = None, runtime_environment: Optional[Dict[Any, Any]] = None, library_usage: Optional[Dict[Any, Any]] = None, origin: Optional[str] = None, debug: bool = False, job_id: Optional[str] = None, limit_latest_versions: Optional[int] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run adviser on the provided user input.

run_build_analyze(document_id: str, output: str, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run build analyze on the provided user input.

run_build_dependencies(document_id: str, output: str, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run build dependencies on the provided user input.

run_build_report(document_id: str, output: str, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run build report on the provided user input.

run_dependency_monkey(requirements: Union[str, Dict[str, Any]], context: Dict[str, Any], *, stack_output: Optional[str] = None, report_output: Optional[str] = None, seed: Optional[int] = None, dry_run: bool = False, decision: Optional[str] = None, count: Optional[int] = None, debug: bool = False, job_id: Optional[str] = None, limit_latest_versions: Optional[int] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run Dependency Monkey on the provided user input.

run_graph_sync(document_id: str, namespace: str, graph_sync_type: str, force_sync: str, *, template: Optional[Dict[str, Any]] = None, job_id: Optional[str] = None) → str[source]

Run the given graph sync.

run_inspection_build(template: Dict[str, Any]) → str[source]

Run the inspection build.

run_inspection_job(parameters: Dict[str, str], template: Optional[Dict[str, Any]] = None, *, use_hw_template: bool = False, cpu_requests: Optional[str] = None, memory_requests: Optional[str] = None, infra_namespace: Optional[str] = None, registry: Optional[str] = None) → str[source]

Create the actual inspection job.

run_kebechet_run_results(url: str, service: str, analysis_id: str, *, verbose: bool = False, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Create a kebechet run-results job.

run_kebechet_run_url(url: str, service: str, *, verbose: bool = False, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Create a kebechet run-url job.

run_package_analyzer(package_name: str, package_version: str, index_url: str, *, output: str, debug: bool = False, dry_run: bool = False, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run package-analyzer to gather digests of packages and files present inside packages.

run_package_extract(image: str, output: str, *, environment_type: str, is_external: bool = True, origin: Optional[str] = None, registry_user: Optional[str] = None, registry_password: Optional[str] = None, verify_tls: bool = True, debug: bool = False, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run package-extract analyzer to extract information from the provided image.

run_provenance_checker(application_stack: Dict[Any, Any], output: str, *, origin: Optional[str] = None, whitelisted_sources: Optional[List[str]] = None, debug: bool = False, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run provenance checks on the provided user input.

run_solver(packages: str, output: str, solver: str, *, indexes: Optional[List[str]] = None, debug: bool = False, transitive: bool = True, job_id: Optional[str] = None, template: Optional[Dict[str, Any]] = None) → str[source]

Run solver or all solver to solve the given requirements.

schedule_adviser(application_stack: Dict[Any, Any], output: str, recommendation_type: str, *, count: Optional[int] = None, limit: Optional[int] = None, runtime_environment: Optional[Dict[Any, Any]] = None, library_usage: Optional[Dict[Any, Any]] = None, origin: Optional[str] = None, debug: bool = False, job_id: Optional[str] = None, limit_latest_versions: Optional[int] = None) → str[source]

Schedule an adviser run.

schedule_all_solvers(packages: str, output: str, *, indexes: Optional[List[str]] = None, debug: bool = False, transitive: bool = False) → List[str][source]

Schedule all solvers for the given packages.

schedule_build_analyze(document_id: str, output: str, job_id: Optional[str] = None) → str[source]

Schedule an build analyze run.

schedule_build_dependencies(document_id: str, output: str, job_id: Optional[str] = None) → str[source]

Schedule an build analyze run.

schedule_build_report(document_id: str, output: str, job_id: Optional[str] = None) → str[source]

Schedule an build report run.

schedule_dependency_monkey(requirements: Union[str, Dict[str, Any]], context: Dict[str, Any], *, stack_output: Optional[str] = None, report_output: Optional[str] = None, seed: Optional[int] = None, dry_run: bool = False, decision: Optional[str] = None, count: Optional[int] = None, debug: bool = False, job_id: Optional[str] = None, limit_latest_versions: Optional[int] = None) → str[source]

Schedule a dependency monkey run.

schedule_graph_refresh(namespace: Optional[str] = None) → str[source]

Schedule graph refresh job in frontend namespace by default.

schedule_graph_sync_adviser(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of an adviser document.

schedule_graph_sync_dependency_monkey(document_id: str, *, force_sync: bool = False, namespace: str) → str[source]

Schedule a sync of a dependency monkey result.

schedule_graph_sync_inspection(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of inspection.

schedule_graph_sync_package_analyzer(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of an package-analysis document.

schedule_graph_sync_package_extract(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of package-extract.

schedule_graph_sync_provenance_checker(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of a provenance checker result.

schedule_graph_sync_solver(document_id: str, *, force_sync: bool = False, namespace: Optional[str] = None) → str[source]

Schedule a sync of solver result.

schedule_inspection_build(parameters: Dict[str, Any], inspection_id: str, use_hw_template: bool) → str[source]

Schedule inspection build.

schedule_inspection_job(inspection_id: str, parameters: Dict[str, str], use_hw_template: bool, cpu_requests: str, memory_requests: str, infra_namespace: Optional[str] = None, registry: Optional[str] = None) → str[source]

Schedule the given job run, the scheduled job is handled by workload operator based resources available.

schedule_kebechet_run_results(url: str, service: str, analysis_id: str, *, verbose: bool = False, job_id: Optional[str] = None) → str[source]

Schedule a kebechet run.

schedule_kebechet_run_url(url: str, service: str, *, verbose: bool = False, job_id: Optional[str] = None) → str[source]

Schedule a kebechet run.

schedule_package_analyzer(package_name: str, package_version: str, index_url: str, *, output: str, debug: bool = False, dry_run: bool = False, job_id: Optional[str] = None) → str[source]

Schedule the given job run, the scheduled job is handled by workload operator based resources available.

schedule_package_extract(image: str, output: str, *, environment_type: str, is_external: bool = True, origin: Optional[str] = None, registry_user: Optional[str] = None, registry_password: Optional[str] = None, verify_tls: bool = True, debug: bool = False, job_id: Optional[str] = None) → str[source]

Schedule the given job run, the scheduled job is handled by workload operator based resources available.

schedule_provenance_checker(application_stack: Dict[Any, Any], output: str, *, origin: Optional[str] = None, whitelisted_sources: Optional[List[str]] = None, debug: bool = False, job_id: Optional[str] = None) → str[source]

Schedule a provenance checker run.

schedule_solver(packages: str, output: str, solver: str, *, indexes: Optional[List[str]] = None, debug: bool = False, transitive: bool = True, job_id: Optional[str] = None) → str[source]

Schedule the given solver.

static set_template_parameters(template: Dict[str, Any], **parameters: Any) → None[source]

Set parameters in the template - replace existing ones or append to parameter list if not exist.

>>> set_template_parameters(template, THOTH_LOG_ADVISER='DEBUG')
property token

Access service account token mounted to the pod.

class thoth.common.OperatingSystem(name: str = None, version: str = None)[source]

Bases: thoth.common.config.base.ConfigEntryBase

Representation for hardware related information.

name
version
thoth.common.parse_datetime(datetime_string: str) → datetime.datetime[source]

Parse datetime string represented in ISO format.

class thoth.common.RuntimeEnvironment(hardware: thoth.common.config.hardware_information.HardwareInformation, operating_system: thoth.common.config.operating_system.OperatingSystem, python_version: str = None, cuda_version: str = None, name: str = None, fully_specified: Optional[bool] = None)[source]

Bases: object

An entry collapsing configuration options in the user configuration file.

cuda_version
classmethod from_dict(dict_: Optional[Dict[Any, Any]] = None) → thoth.common.config.runtime_environment.RuntimeEnvironment[source]

Parse one configuration entry from a dictionary.

hardware
is_fully_specified() → bool[source]

Pre-cache check if the given runtime environment is fully specified.

classmethod load(content: Optional[str] = None) → thoth.common.config.runtime_environment.RuntimeEnvironment[source]

Load runtime environment information from file or from a JSON representation, transparently.

name
operating_system
python_version
to_dict(without_none: bool = False) → Dict[str, Any][source]

Convert runtime environment configuration to a dict representation.

to_string() → str[source]

Convert runtime environment configuration to a string representation.

class thoth.common.SafeJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

Convert objects to JSON, safely.

default(o: Any) → Any[source]

Convert an object to JSON, safely.

thoth.common.timestamp2datetime(timestamp: int) → datetime.datetime[source]

Convert a timestamp to datetime respecting UTC.