magpie.cli.register_providers¶
Magpie helpers for service providers registration.
Attributes¶
Functions¶
|
Defines argument parser options for logging operations. |
|
Uses argument parser options to setup logging level from specified flags. |
|
Search in order for matched value of |
|
|
Registers Magpie services from one or many providers.cfg file. |
|
|
Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when |
|
|
|
Module Contents¶
- magpie.cli.register_providers.make_logging_options(parser: argparse.ArgumentParser) None[source]¶
Defines argument parser options for logging operations.
- magpie.cli.register_providers.setup_logger_from_options(logger: logging.Logger, args: argparse.Namespace) None[source]¶
Uses argument parser options to setup logging level from specified flags.
Setup both the specific CLI logger that is provided and the generic magpie logger.
- magpie.cli.register_providers.get_constant(constant_name: magpie.typedefs.Str, settings_container: magpie.typedefs.AnySettingsContainer | None = None, settings_name: magpie.typedefs.Str | None = None, default_value: magpie.typedefs.SettingValue | None = None, raise_not_set: bool = True, raise_missing: bool = True, print_missing: bool = False, empty_missing: bool = False) magpie.typedefs.SettingValue[source]¶
- Search in order for matched value of
constant_name: search in
MAGPIE_CONSTANTSsearch in settings if specified
search alternative setting names (see below)
search in
magpie.constantsdefinitionssearch in environment variables
Parameter
constant_nameis expected to have the formatMAGPIE_[VARIABLE_NAME]although any value can be passed to retrieve generic settings from all above-mentioned search locations.If
settings_nameis provided as alternative name, it is used as is to search for results ifconstant_namewas not found. Otherwise,magpie.[variable_name]is used for additional search when the formatMAGPIE_[VARIABLE_NAME]was used forconstant_name(i.e.:MAGPIE_ADMIN_USERwill also search formagpie.admin_userand so on for corresponding constants).- Parameters:
constant_name – key to search for a value
settings_container – WSGI application settings container (if not provided, uses found one in current thread)
settings_name – alternative name for settings if specified
default_value – default value to be returned if not found anywhere, and exception raises are disabled.
raise_not_set – raise an exception if the found key is
None, search until last case if others areNoneraise_missing – raise exception if key is not found anywhere
print_missing – print message if key is not found anywhere, return
Noneempty_missing – consider an empty value for an existing key as if it was missing (i.e.: as if not set).
- Returns:
found value or default_value
- Raises:
ValueError – if resulting value is invalid based on options (by default raise missing/empty/
Nonevalue)LookupError – if no appropriate value could be found from all search locations (according to options)
- Search in order for matched value of
- magpie.cli.register_providers.get_db_session_from_config_ini(config_ini_path, ini_main_section_name='app:magpie_app', settings_override=None)[source]¶
- magpie.cli.register_providers.magpie_register_services_from_config(service_config_path: magpie.typedefs.Str, push_to_phoenix: bool = False, skip_registration: bool = False, force_update: bool = False, disable_getcapabilities: bool = False, db_session: sqlalchemy.orm.session.Session | None = None) magpie.typedefs.ServicesSettings[source]¶
Registers Magpie services from one or many providers.cfg file.
Uses the provided DB session to directly update service definitions, or uses API request routes as admin. Optionally pushes updates to Phoenix.
- Parameters:
service_config_path – where to look for providers configuration(s). Directory or file path.
push_to_phoenix – whether to push loaded service definitions to remote Phoenix service.
skip_registration – Load, validate and combine Service configurations, but don’t register them.
force_update – override service definitions that conflict by name with registered ones.
disable_getcapabilities – Skip GetCapabilities request validation and permission update. By default, any service with type that allows GetCapabilities permissions will be tested to ensure it can be reached on the provided url. Once validated, this permission is applied to anonymous group to make its entrypoint accessible by anyone. Services that cannot have GetCapabilities permission are ignored regardless.
db_session – Use a pre-established database connection for registration. Otherwise, API requests are employed.
- Returns:
loaded service configurations.
- magpie.cli.register_providers.get_logger(name: magpie.typedefs.Str, level: int | None = None, force_stdout: bool = None, message_format: magpie.typedefs.Str | None = None, datetime_format: magpie.typedefs.Str | None = None) logging.Logger[source]¶
Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when level is
logging.NOTSET.