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: - definition (
leapp.repository.actor_definition.ActorDefinition
) – Actor definition - logger (
logging.Logger
) – Logger - messaging (
leapp.messaging.BaseMessaging
) – Leapp Messaging - config_model (
leapp.models.Model
derived class) – Workflow provided configuration model
-
run
(*args, **kwargs)¶ Performs the actor execution in the child process.
- definition (
-
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
-
apis
¶ Returns: names of APIs used by this actor
-
class_name
¶ Returns: Actor class name
-
consumes
¶ Returns: Tuple of consumed models
-
description
¶ Returns: Actor description
-
dialogs
¶ Returns: Tuple of defined dialogs
-
directory
¶ Returns: The folder path of the actor
-
discover
()¶ Performs introspection through a subprocess.
Returns: Dictionary with discovered items.
-
files
¶ Returns: Tuple with path to the files folder of the actor, empty tuple if none
-
full_path
¶
-
injected_context
(*args, **kwds)¶ 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.
-
libraries
¶ Returns: Tuple with path to the libraries folder of the actor, empty tuple if none
-
load
()¶ Loads the actor module to be introspectable.
-
name
¶ Returns: Actor internal name
-
produces
¶ Returns: Tuple of produced models
-
serialize
()¶ Returns: dump of actor resources (path, name, tools, files, libraries, tests)
Returns: Tuple of tags assigned to the actor
-
tests
¶ Returns: Tuple with path to the tests folder of the actor, empty tuple if none
-
tools
¶ Returns: Tuple with path to the tools folder of the actor, empty tuple if none
- log (
-
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
- definition (
leapp.repository.definition module¶
-
class
leapp.repository.definition.
DefinitionKind
¶ Bases:
object
Represents all known repository resources in Leapp.
-
ACTOR
= <leapp.repository.definition._Kind object>¶
-
ACTOR_WHITELIST
= (<leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>)¶
-
API
= <leapp.repository.definition._Kind object>¶
-
FILES
= <leapp.repository.definition._Kind object>¶
-
LIBRARIES
= <leapp.repository.definition._Kind object>¶
-
MODEL
= <leapp.repository.definition._Kind object>¶
-
REPO_WHITELIST
= (<leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>, <leapp.repository.definition._Kind object>)¶
-
TAG
= <leapp.repository.definition._Kind object>¶
-
TESTS
= <leapp.repository.definition._Kind object>¶
-
TOOLS
= <leapp.repository.definition._Kind object>¶
-
TOPIC
= <leapp.repository.definition._Kind object>¶
-
WORKFLOW
= <leapp.repository.definition._Kind object>¶
-
leapp.repository.manager module¶
-
class
leapp.repository.manager.
RepositoryManager
¶ Bases:
object
Handles multiple loaded repositories
-
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)
-
files
¶ Returns: Tuple of paths to “files” folders from all repositories
-
get_missing_repo_links
()¶ Gather all missing repository ids linked by the added repositories.
Returns: Set of missing repository ids.
-
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
-
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
-
repos
¶ Returns: A tuple of all repository instances
-
serialize
()¶ Returns: List of resources in all known repositories
Returns: Tuple of paths to tag-defining python modules from all repositories
-
tools
¶ Returns: Tuple of paths to “tools” folders from all repositories
-
topics
¶ Returns: Tuple of paths to topic-defining python modules from all repositories
-
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: - repository (
leapp.repository.Repository
) – - path (str) – path to the repository
Returns: instance of
leapp.repository.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
- repo (
-
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
- repo (
-
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
- repo (
-
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
- repo (
-
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
- repo (
-
leapp.repository.scan.
scan_repo
(path)¶ Scans all related repository resources
Parameters: path (str) – Returns: repository
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
- repo (
-
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
- repo (
-
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
- repo (
-
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
- repo (
-
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
- repo (
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 -
actors
¶ Returns: Tuple of actors in the repository
-
add
(kind, item)¶ Adds any supported kind of a resource to the repository
Parameters: - kind (
leapp.repository.definition.DefinitionKind
) – specific kind of the repository resource - item (
leapp.repository.actor_definition.ActorDefiniton
or str) – Item that will be added
- kind (
-
apis
¶ Returns: Tuple of apis in the repository
-
files
¶ Returns: Tuple of files in the repository
-
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
-
models
¶ Returns: Tuple of models in the repository
-
relative_paths
(paths)¶ Returns: Tuple of repository relative paths
-
repo_dir
¶
-
repo_id
¶
-
repo_links
¶
-
serialize
()¶ Returns: Dictionary of all repository resources
Returns: Tuple of tags in the repository
-
tools
¶ Returns: Tuple of tools in the repository
-
topics
¶ Returns: Tuple of topics in the repository
-
workflows
¶ Returns: Tuple of workflows in the repository
-