leapp.repository package

Submodules

leapp.repository.actor_definition module

class leapp.repository.actor_definition.ActorCallContext(definition, logger, messaging, config_model, skip_dialogs)

Bases: object

Wraps the actor execution into child process.

Parameters:
run(*args, **kwargs)

Performs the actor execution in the child process.

class leapp.repository.actor_definition.ActorDefinition(directory, repo_dir, log=None)

Bases: object

Defines actor resources.

Parameters:
  • log (logging.Logger) – Logger

  • directory (str) – Actor directory

  • repo_dir (str) – Repository directory

add(kind, path)

Adds any kind of actor resource to the Definition

Parameters:
  • kind (str) – kind of resource added

  • path (str) – path to the added resource

property apis
Returns:

names of APIs used by this actor

property class_name
Returns:

Actor class name

property config_schemas
Returns:

Actor config_schemas

property configs
Returns:

Tuple with path to the configs folder of the actor, empty tuple if none

property consumes
Returns:

Tuple of consumed models

property description
Returns:

Actor description

property dialogs
Returns:

Tuple of defined dialogs

property directory
Returns:

The folder path of the actor

discover()

Performs introspection through a subprocess.

Returns:

Dictionary with discovered items.

property files
Returns:

Tuple with path to the files folder of the actor, empty tuple if none

property full_path
injected_context()

Prepares the actor environment for running the actor. This includes injecting actor private libraries into leapp.libraries.actor and setting environment variables for private tools and files.

Note:

Use with caution.

property libraries
Returns:

Tuple with path to the libraries folder of the actor, empty tuple if none

load()

Loads the actor module to be introspectable.

property name
Returns:

Actor internal name

property produces
Returns:

Tuple of produced models

serialize()
Returns:

dump of actor resources (path, name, tools, files, libraries, tests)

property tags
Returns:

Tuple of tags assigned to the actor

property tests
Returns:

Tuple with path to the tests folder of the actor, empty tuple if none

property tools
Returns:

Tuple with path to the tools folder of the actor, empty tuple if none

leapp.repository.actor_definition.inspect_actor(definition, result_queue)

Retrieves the actor information in a child process and returns the results back through result_queue.

Parameters:
  • definition (ActorDefinition) – the actor definition to load

  • result_queue (multiprocessing.Queue) – queue to pass results back to the calling process

leapp.repository.definition module

class leapp.repository.definition.DefinitionKind

Bases: object

Represents all known repository resources in Leapp.

ACTOR = <leapp.repository.definition.DefinitionKind._Kind object>
ACTOR_WHITELIST = (<leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>)
API = <leapp.repository.definition.DefinitionKind._Kind object>
CONFIGS = <leapp.repository.definition.DefinitionKind._Kind object>
FILES = <leapp.repository.definition.DefinitionKind._Kind object>
LIBRARIES = <leapp.repository.definition.DefinitionKind._Kind object>
MODEL = <leapp.repository.definition.DefinitionKind._Kind object>
REPO_WHITELIST = (<leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>, <leapp.repository.definition.DefinitionKind._Kind object>)
TAG = <leapp.repository.definition.DefinitionKind._Kind object>
TESTS = <leapp.repository.definition.DefinitionKind._Kind object>
TOOLS = <leapp.repository.definition.DefinitionKind._Kind object>
TOPIC = <leapp.repository.definition.DefinitionKind._Kind object>
WORKFLOW = <leapp.repository.definition.DefinitionKind._Kind object>

leapp.repository.manager module

class leapp.repository.manager.RepositoryManager

Bases: object

Handles multiple loaded repositories

property actors
Returns:

Tuple of leapp.repository.actor_definition.ActorDefinition instances representing actors from all repositories

add_repo(repo)

Add new repository to manager.

Parameters:

repo (leapp.repository.Repository) – Repository to be added (registered)

property files
Returns:

Tuple of paths to “files” folders from all repositories

Gather all missing repository ids linked by the added repositories.

Returns:

Set of missing repository ids.

property libraries
Returns:

Tuple of paths to “libraries” folders from all repositories

load(resolve=True, skip_actors_discovery=False)

Load all known repositories.

Parameters:
  • resolve (bool) – Whether or not to perform the resolving of model references

  • skip_actors_discovery (bool) – specifies whether to skip discovery process of the actors When we testing actors, we’re directly injecting the actor context, so we don’t need to inject it during the repo loading. This option helps to solve this problem.

lookup_actor(name)

Find actor in all loaded repositories

Parameters:

name (str) – Name of the actor

Returns:

None or Actor

lookup_workflow(name)

Find workflow in all loaded repositories

Parameters:

name (str) – Name of the workflow

Returns:

None or Workflow

property models
Returns:

Tuple of paths to model-defining python modules from all repositories

repo_by_id(repo_id)

Look up a repository by id

Parameters:

repo_id – Repository id

Returns:

Repository or None

property repos
Returns:

A tuple of all repository instances

serialize()
Returns:

List of resources in all known repositories

property tags
Returns:

Tuple of paths to tag-defining python modules from all repositories

property tools
Returns:

Tuple of paths to “tools” folders from all repositories

property topics
Returns:

Tuple of paths to topic-defining python modules from all repositories

property workflows
Returns:

Tuple of paths to workflow-defining python modules from all repositories

leapp.repository.scan module

leapp.repository.scan.find_and_scan_repositories(path, manager=None, include_locals=False)

Finds and scans all repositories found in the path and it will also resolve linked repositories. Using include_locals=True will additionally include user local repositories to be considered for resolving linked repositories.

Parameters:
  • path – Path to scan for repositories

  • manager – Optional repository manager to add found repos too

  • include_locals – Should repositories linked be searched from the user local registry

Returns:

repository manager instance (either passed through or a new instance if none was passed)

leapp.repository.scan.scan(repository, path)

Scans all repository resources

Parameters:
Returns:

instance of leapp.repository.Repository

leapp.repository.scan.scan_actors(repo, path, repo_path)

Scans actors and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the actors

  • repo_path (str) – path to the repository

leapp.repository.scan.scan_apis(repo, path, repo_path)

Scans apis and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the apis

  • repo_path (str) – path to the repository

leapp.repository.scan.scan_configs(repo, path, repo_path)

Scans configs and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the configs

  • repo_path (str) – path to the repository

leapp.repository.scan.scan_files(repo, path, repo_path)

Scans files and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the files

  • repo_path (str) – path to the repository

leapp.repository.scan.scan_libraries(repo, path, repo_path)

Scans libraries and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the libraries

  • repo_path (str) – path to the repository

leapp.repository.scan.scan_models(repo, path, repo_path)

Scans models and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the models

  • repo_path (str) – path to the repository

leapp.repository.scan.scan_repo(path)

Scans all related repository resources

Parameters:

path (str) –

Returns:

repository

leapp.repository.scan.scan_tags(repo, path, repo_path)

Scans tags and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the tags

  • repo_path (str) – path to the repository

leapp.repository.scan.scan_tests(repo, path, repo_path)

Scans tests and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the tests

  • repo_path (str) – path to the repository

leapp.repository.scan.scan_tools(repo, path, repo_path)

Scans tools and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the tools

  • repo_path (str) – path to the repository

leapp.repository.scan.scan_topics(repo, path, repo_path)

Scans topics and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the topics

  • repo_path (str) – path to the repository

leapp.repository.scan.scan_workflows(repo, path, repo_path)

Scans workflows and adds them to the repository.

Parameters:
  • repo (leapp.repository.Repository) – Instance of the repository

  • path (str) – path to the workflows

  • repo_path (str) – path to the repository

Module contents

class leapp.repository.Repository(directory)

Bases: object

The Repository class represents a place where all resources (actors, models, tags, etc.) are defined. See the Repository Directory Layout.

Parameters:

directory (str) – Path to the repository folder

property actors
Returns:

Tuple of actors in the repository

add(kind, item)

Adds any supported kind of a resource to the repository

Parameters:
property apis
Returns:

Tuple of apis in the repository

property configs
Returns:

Tuple of configs in the repository

property files
Returns:

Tuple of files in the repository

property libraries
Returns:

Tuple of libraries in the repository

load(resolve=True, stage=None, skip_actors_discovery=False)

Loads the repository resources

Parameters:
  • resolve (bool) – Decides whether or not to perform the resolving of model references

  • stage (_LoadStage value) – Stage to load - Required for repository managers

lookup_actor(name)

Finds an actor in the repository

Parameters:

name (str) – Name of the actor

Returns:

None or Actor

static lookup_workflow(name)

Finds a workflow in the repository

Parameters:

name (str) – Name of the workflow class name, Workflow.name, or Workflow.short_name

Returns:

None or Workflow

property models
Returns:

Tuple of models in the repository

relative_paths(paths)
Returns:

Tuple of repository relative paths

property repo_dir
property repo_id
serialize()
Returns:

Dictionary of all repository resources

property tags
Returns:

Tuple of tags in the repository

property tools
Returns:

Tuple of tools in the repository

property topics
Returns:

Tuple of topics in the repository

property workflows
Returns:

Tuple of workflows in the repository