thamos package

Subpackages

Submodules

thamos.cli module

Command line interface Thamos for interaction with Thoth.

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

Bases: click.core.Group

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.config module

CLI and library configuration.

thamos.discover module

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

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

Discover base image and its version.

thamos.discover.discover_cpu() → Dict[str, Union[str, int, None]][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_distribution() → tuple[source]

Get distribution identifier and distribution version.

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.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.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.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.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, limit: Optional[int] = None, count: int = 1, 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, limit: Optional[int] = None, count: int = 1, 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: Optional[str] = None, recommendation_type: str = None, dev: bool = False, no_static_analysis: bool = False, no_user_stack: bool = False, nowait: bool = False, force: bool = False, limit: Optional[int] = None, count: int = 1, 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.get_analysis_results(api_client: thamos.swagger_client.api_client.ApiClient, analysis_id: str)[source]

Get the analysis result from a given id.

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_status(api_client: thamos.swagger_client.api_client.ApiClient, analysis_id: 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.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) → Union[Dict, str, None][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 the multiple response types available while asking for result of a anaylsis result.

thamos.lib.list_hardware_environments(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_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_s2i(api_client: thamos.swagger_client.api_client.ApiClient) → Dict[str, Any][source]

Get information about hardware for which Thoth can give recommendations.

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.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: 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.cwd(target)[source]

Manage cwd in a pushd/popd fashion.

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.