mtap.deployment
Deploying Processors
Module for deploying a set of processing services and the events server all at once.
See python/mtap/examples/exampleDeploymentConfiguration.yml for an example
of the yaml deployment configuration
which can be loaded using
from_yaml_file()
- class mtap.deployment.Deployment(global_settings: GlobalSettings | None = None, events_deployment: EventsDeployment | None = None, shared_processor_config: SharedProcessorConfig | None = None, processors: List[ProcessorDeployment] | None = None)[source]
An automatic deployment configuration which launches a configurable set of MTAP services.
- global_settings: GlobalSettings | None = None
Settings shared among all services.
- events_deployment: EventsDeployment | None = None
Deployment settings for the events service.
Shared configuration settings for all processors.
- processors: List[ProcessorDeployment] = None
Configurations for individual processors.
- static from_dict(conf: Dict) Deployment [source]
Creates a deployment object from a configuration dictionary.
- Parameters:
conf – The configuration dictionary.
- Returns:
Deployment object created.
- static from_yaml_file(conf_path: str | bytes | PathLike) Deployment [source]
Loads a deployment configuration from a yaml file.
- Parameters:
conf_path – The path to the yaml configuration file.
- Returns:
Deployment object created from the configuration.
- run_servers() Tuple[List[str], List[List[str]]] [source]
A context manager that starts all the configured services in subprocesses and returns.
- Raises:
ServiceDeploymentException – If one or more of the services fails to launch.
Examples
>>> deploy = Deployment.from_yaml_file('deploy_config.yml') >>> with deploy.run_servers(): >>> # do something that requires the servers. >>> # servers are automatically shutdown / terminated
- class mtap.deployment.GlobalSettings(host: str | None = None, mtap_config: str | None = None, log_level: str | None = None, register: bool | None = None)[source]
Settings shared by event service and all processors.
- class mtap.deployment.EventsDeployment(enabled: bool = False, address: str | None = None, addresses: Sequence[str] | None = None, workers: int | None = None, register: bool | None = None, mtap_config: str | None = None, log_level: str | None = None, startup_timeout: int = 10)[source]
Deployment configuration for the events service.
- static from_dict(conf: Dict | None) EventsDeployment [source]
Creates the EventsDeployment configuration option from a configuration dictionary.
- Parameters:
conf – The configuration dictionary
- Returns:
EventsDeployment or None from the configuration dictionary.
Configuration that is shared between multiple processor services.
An optional GRPC-compatible target for the events service to be used by all processors.
The default number of worker threads which will perform processing.
A list of additional arguments that should be appended to every processor.
A list of JVM arguments for all Java processors.
A classpath string that will be passed to all Java processors.
A list of additional arguments that is added to only Java processors.
The default startup timeout for processors.
A
multiprocessing.get_context()
argument to create the multiprocessing context.
Builds a configuration from a dictionary representation.
- Parameters:
conf – The configuration dictionary.
- Returns:
A shared processor config object.
- class mtap.deployment.ProcessorDeployment(implementation: str, entry_point: str, enabled: bool = True, instances: int = 1, host: str | None = None, port: int | None = None, workers: int | None = None, register: bool | None = None, mtap_config: str | None = None, log_level: str | None = None, name: str | None = None, sid: str | List[str] | None = None, pre_args: List[str] | None = None, additional_args: List[str] | None = None, startup_timeout: float | None = None, mp: bool | None = None, mp_processes: int | None = None, mp_start_method: str | None = None)[source]
Deployment configuration for an MTAP processor.
Used to construct the command for launching the processor. The processor should be a Java Class with a main method or a Python module with a main block. It should accept the standard MTAP processor deployment arguments and launch an MTAP processor using
mtap.run_processor()
or the equivalent Java method.- register: bool | None = None
Whether the processor should register with the discovery service specified in the MTAP config file.
- sid: str | List[str] | None = None
An optional service instance unique identifier. If instances is 1 this should be a string, if instances is more than 1 this should be a list of strings, one for each instance.
- pre_args: List[str] | None = None
Arguments that occur prior to the MTAP service arguments (like host, port, etc).
- static from_dict(conf: Dict) ProcessorDeployment [source]
Creates an MTAP processor deployment configuration from a configuration dictionary.
- Parameters:
conf – The configuration dictionary.
- Returns:
ProcessorDeployment object that can be used to construct the call for the processor.