thamos package

Subpackages

Submodules

thamos.cli module

Command line interface Thamos for interaction with Thoth.

class thamos.cli.AliasedGroup(name: Optional[str] = None, commands: Optional[Union[Dict[str, click.core.Command], Sequence[click.core.Command]]] = None, **attrs: Any)[source]

Bases: rich_click.rich_group.RichGroup

Provide clever command aliases.

get_command(ctx, cmd_name)[source]

Get command to be executed based on the prefix.

https://click.palletsprojects.com/en/7.x/advanced/#command-aliases

thamos.cli.handle_cli_exception(func: Callable) Callable[source]

Suppress exception in CLI if debug mode was not turned on.

thamos.cli_config module

Configuration for Thamos CLI using rich-click.

thamos.cli_config.init_rich_click() None[source]

Initialize rich-click.

thamos.config module

CLI and library configuration.

thamos.discover module

Implementation discovery methods to detect the current environment and its configuration.

thamos.discover.discover_all() Dict[str, Any][source]

Discover all the entries used in Thoth’s configuration file.

thamos.discover.discover_base_image() Optional[str][source]

Discover base image and its version.

thamos.discover.discover_cpu() Dict[str, Optional[Union[str, int]]][source]

Discover CPU model, model name and family.

thamos.discover.discover_cuda_version(interactive: bool = False) Optional[str][source]

Check for CUDA version, if no CUDA is installed, return None.

thamos.discover.discover_cudnn_version() Optional[str][source]

Discover CuDNN version and return None if not found.

thamos.discover.discover_distribution() tuple[source]

Get distribution identifier and distribution version.

thamos.discover.discover_gpu_model() Optional[str][source]

Check for GPU model and return None if not found.

thamos.discover.discover_mkl_version() Optional[str][source]

Discover MLK Python package version and return None if not found.

thamos.discover.discover_platform() str[source]

Discover platform used.

thamos.discover.discover_python_version() str[source]

Discover Python version in which we run in.

thamos.discover.discover_rpm_package(package_name: str) Optional[Dict[str, str]][source]

Check for version of a RPM package and return None if not found.

thamos.exceptions module

Exception hierarchy in Thamos.

exception thamos.exceptions.ApiError[source]

Bases: thamos.exceptions.ThamosException

An exception raised if the API doesn’t return expected status code.

exception thamos.exceptions.ConfigurationError[source]

Bases: thamos.exceptions.ThamosException

An exception raised if there are issues with configuration file.

exception thamos.exceptions.InternalError[source]

Bases: thamos.exceptions.ThamosException

An exception raised on internal programming errors.

exception thamos.exceptions.NoApiSupported[source]

Bases: thamos.exceptions.ThamosException

Raised if client and Thoth server does not support same API versions.

exception thamos.exceptions.NoDevRequirements[source]

Bases: thamos.exceptions.ThamosException

An exception raised if no development requirements are found during the installation process.

exception thamos.exceptions.NoMatchingPackage[source]

Bases: thamos.exceptions.ThamosException

An exception raised if no matching package can be found for a given import.

exception thamos.exceptions.NoProjectDirError[source]

Bases: thamos.exceptions.ThamosException

An exception raised if the project directory cannot be found.

exception thamos.exceptions.NoRequirementsFile[source]

Bases: thamos.exceptions.ThamosException

An exception raised when requirements file is not present.

exception thamos.exceptions.NoRequirementsFormatError[source]

Bases: thamos.exceptions.ThamosException

An exception raised if no requirements format could be found in configuration file.

exception thamos.exceptions.NoRuntimeEnvironmentError[source]

Bases: thamos.exceptions.ThamosException

An exception raised if no runtime environment could be found in configuration file.

exception thamos.exceptions.PedanticRunVerificationError[source]

Bases: thamos.exceptions.ThamosException

An exception raised if the runtime environment used does not match configuration.

exception thamos.exceptions.RequirementsFileError[source]

Bases: thamos.exceptions.ThamosException

An exception raised if there is an issue with requirements file or lock file.

exception thamos.exceptions.RuntimeEnvironmentExistsError[source]

Bases: thamos.exceptions.ThamosException

An exception raised the given runtime environment already exists.

exception thamos.exceptions.ServiceUnavailable[source]

Bases: thamos.exceptions.ThamosException

Raised if Thoth service is not available.

exception thamos.exceptions.ThamosException[source]

Bases: Exception

A base class for exceptions in Thamos.

exception thamos.exceptions.TimeoutError[source]

Bases: thamos.exceptions.ThamosException

An exception raised if the API takes longer than timeout limit.

exception thamos.exceptions.UnknownAnalysisType[source]

Bases: thamos.exceptions.ThamosException

Raised analysis type (adviser, package-extract, …) cannot be determined from analysis identifier.

thamos.lib module

Core parts of library for interacting with Thoth.

thamos.lib.add_requirements_to_project(requirement: List[str], runtime_environment: Optional[str], index_url: str, dev: bool)[source]

Add requirements to project.

thamos.lib.advise(api_client: thamos.swagger_client.api_client.ApiClient, pipfile: str, pipfile_lock: str, *, constraints: Optional[str] = None, recommendation_type: Optional[str] = None, runtime_environment: Optional[dict] = None, src_path: str = '.', runtime_environment_name: Optional[str] = None, dev: bool = False, no_static_analysis: bool = False, no_user_stack: bool = False, nowait: bool = False, force: bool = False, debug: bool = False, origin: Optional[str] = None, timeout: Optional[int] = None, github_event_type: Optional[str] = None, github_check_run_id: Optional[int] = None, github_installation_id: Optional[int] = None, github_base_repo_url: Optional[str] = None, source_type: Optional[thoth.common.enums.ThothAdviserIntegrationEnum] = None, justification: Optional[Dict] = None, stack_info: Optional[Dict] = None, kebechet_metadata: Optional[Dict] = None, verify_tls: bool = True, labels: Optional[Dict[str, str]] = None) Optional[tuple][source]

Submit a stack for adviser checks and wait for results.

thamos.lib.advise_here(recommendation_type: Optional[str] = None, *, runtime_environment: Optional[dict] = None, src_path: str = '.', runtime_environment_name: Optional[str] = None, dev: bool = False, no_static_analysis: bool = False, no_user_stack: bool = False, nowait: bool = False, force: bool = False, debug: bool = False, timeout: Optional[int] = None, origin: Optional[str] = None, github_event_type: Optional[str] = None, github_check_run_id: Optional[int] = None, github_installation_id: Optional[int] = None, github_base_repo_url: Optional[str] = None, source_type: Optional[thoth.common.enums.ThothAdviserIntegrationEnum] = None, justification: Optional[Dict] = None, stack_info: Optional[Dict] = None, kebechet_metadata: Optional[Dict] = None, verify_tls: bool = True, labels: Optional[Dict[str, str]] = None) Optional[tuple][source]

Run advise in current directory, requires no arguments.

thamos.lib.advise_using_config(pipfile: str, pipfile_lock: str, config: str, *, runtime_environment_name: Optional[str] = None, constraints: Optional[str] = None, src_path: str = '.', recommendation_type: Optional[str] = None, dev: bool = False, no_static_analysis: bool = False, no_user_stack: bool = False, nowait: bool = False, force: bool = False, debug: bool = False, origin: Optional[str] = None, timeout: Optional[int] = None, github_event_type: Optional[str] = None, github_check_run_id: Optional[int] = None, github_installation_id: Optional[int] = None, github_base_repo_url: Optional[str] = None, source_type: Optional[thoth.common.enums.ThothAdviserIntegrationEnum] = None, labels: Optional[Dict[str, str]] = None) Optional[Tuple[Dict[str, Any], bool]][source]

Trigger advise, respecting the configuration file supplied directly as a string or as a file path.

thamos.lib.build_analysis(api_client: thamos.swagger_client.api_client.ApiClient, build_log: dict, base_image: str, output_image: str, *, environment_type: str, base_registry_user: Optional[str] = None, base_registry_password: Optional[str] = None, base_registry_verify_tls: bool = True, output_registry_user: Optional[str] = None, output_registry_password: Optional[str] = None, output_registry_verify_tls: bool = True, origin: Optional[str] = None, nowait: bool = False, force: bool = False, debug: bool = False) Union[Dict, str][source]

Submit a build image and logs for analysis to Thoth.

thamos.lib.check_runtime_environment_run(runtime_environment: Dict[str, Any]) None[source]

Check the runtime environment matches runtime environment declared in the config file.

thamos.lib.collect_support_information_dict() Dict[str, Any][source]

Collect environment information suitable to report bugs or issues in a dictionary form.

thamos.lib.get_analysis_results(api_client: thamos.swagger_client.api_client.ApiClient, analysis_id: Optional[str] = None)[source]

Get the analysis result from a given id.

thamos.lib.get_diff(api_client: thamos.swagger_client.api_client.ApiClient, new_analysis_id: str, old_analysis_id: str = None)[source]

Get the difference of two analyses justification stack - the analysis type must be of type ‘adviser-‘.

If old_analysis_id is not provided, its get from the last thamos call which stores it in a temporary file.

thamos.lib.get_last_analysis_id() str[source]

Retrieve last analysis id from a temporary file.

thamos.lib.get_log(api_client: thamos.swagger_client.api_client.ApiClient, analysis_id: str = None)[source]

Get log of an analysis - the analysis type and endpoint are automatically derived from analysis id.

If analysis_id is not provided, its get from the last thamos call which stores it in a temporary file.

thamos.lib.get_package_from_imported_packages(api_client: thamos.swagger_client.api_client.ApiClient, import_name: str, raise_on_error: bool = True) List[Dict[str, Any]][source]

Get all (package_name, package_version, index_url) triplets for given import package name.

thamos.lib.get_static_analysis(src_path: str = '.', *, without_standard_imports: bool = False, without_builtin_imports: bool = False, without_builtins: bool = False) Optional[dict][source]

Get static analysis of files used in project.

thamos.lib.get_status(api_client: thamos.swagger_client.api_client.ApiClient, analysis_id: Optional[str] = None)[source]

Get status of an analysis - the analysis type and endpoint are automatically derived from analysis id.

If analysis_id is not provided, its get from the last thamos call which stores it in a temporary file.

thamos.lib.get_verified_packages_from_static_analysis(src_path: str = '.', *, without_standard_imports: bool = False, without_builtin_imports: bool = False, without_builtins: bool = False, raise_on_error: bool = True) List[Dict[str, str]][source]

Get verified packages from invectio static analysis result.

thamos.lib.image_analysis(api_client: thamos.swagger_client.api_client.ApiClient, image: str, *, environment_type: str, registry_user: str = None, registry_password: str = None, verify_tls: bool = True, nowait: bool = False, force: bool = False, timeout: Optional[int] = None, debug: bool = False) Optional[Union[Dict, str]][source]

Submit an image for analysis to Thoth.

thamos.lib.install(runtime_environment_name: Optional[str] = None, dev: bool = False, pip_args: Optional[Tuple[str]] = None) None[source]

Perform installation of packages for the given runtime environment.

If the runtime environment is not specified, the first environment stated in the configuration is used.

thamos.lib.install_using_config(config: str, runtime_environment_name: Optional[str] = None, dev: bool = False) None[source]

Perform installation given the configuration supplied.

thamos.lib.is_analysis_ready(analysis_id: str, *, verify_tls: bool = True) bool[source]

Handle the multiple response types available while asking for result of an analysis.

thamos.lib.list_python_environments(api_client: thamos.swagger_client.api_client.ApiClient) Dict[str, Any][source]

Get available Python environments.

thamos.lib.list_python_package_indexes(api_client: thamos.swagger_client.api_client.ApiClient) Dict[str, Any][source]

Get information about hardware for which Thoth can give recommendations.

thamos.lib.list_thoth_container_images(api_client: thamos.swagger_client.api_client.ApiClient, *, 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[str, Any]][source]

Get available Thoth container images.

thamos.lib.load_dot_env(dot_env_path: str) Dict[str, str][source]

Load .env file and parse its content.

thamos.lib.load_files(requirements_format: str) Tuple[str, Optional[str]][source]

Load Pipfile/Pipfile.lock or requirements.in/txt from the current directory.

thamos.lib.print_advise_results(analysis_id: Optional[str] = None)[source]

Print dependency graph to stdout produced by the given adviser.

thamos.lib.print_dependency_graph(analysis_id: Optional[str] = None, *, fold: bool = True) bool[source]

Print dependency graph to stdout produced by the given adviser.

thamos.lib.print_dependency_graph_from_adviser_document(adviser_document: Dict[str, Any], *, fold: bool = True) bool[source]

Print dependency graph to stdout from the given document.

thamos.lib.provenance_check(api_client: thamos.swagger_client.api_client.ApiClient, pipfile: str, pipfile_lock: str, *, nowait: bool = False, force: bool = False, debug: bool = False, origin: Optional[str] = None, timeout: Optional[int] = None, justification: Optional[Dict[str, Any]] = None, stack_info: Optional[Dict[str, Any]] = None, kebechet_metadata: Optional[Dict[str, Any]] = None, verify_tls: bool = False) Optional[tuple][source]

Submit a stack for provenance checks and wait for results.

thamos.lib.provenance_check_here(*, nowait: bool = False, force: bool = False, debug: bool = False, origin: Optional[str] = None, timeout: Optional[int] = None, justification: Optional[Dict[str, Any]] = None, stack_info: Optional[Dict[str, Any]] = None, kebechet_metadata: Optional[Dict[str, Any]] = None, verify_tls: bool = True) Optional[tuple][source]

Submit a provenance check in current directory.

thamos.lib.with_api_client(func: Callable)[source]

Load configuration entries from Thoth configuration file.

thamos.lib.write_configuration(advised_configuration: dict, recommendation_type: Optional[str] = None, dev: bool = False) None[source]

Create thoth configuration file.

thamos.lib.write_files(requirements: Dict[str, Any], requirements_lock: Dict[str, Any], requirements_format: str) None[source]

Write content of Pipfile/Pipfile.lock or requirements.in/txt to the current directory.

thamos.utils module

Utility and helper functions for Thamos.

thamos.utils.workdir(file_lookup: Optional[str] = None, warn_on_dir_change: bool = True) None[source]

Find project directory and cd into it.

Module contents

A CLI tool and library for interacting with Thoth.