-
Notifications
You must be signed in to change notification settings - Fork 3
Plugins Design Refactor #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cccs-mdr
wants to merge
13
commits into
develop
Choose a base branch
from
plugins-refactor
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8480be6
to
c5bb047
Compare
Howler API - Coverage ResultsDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
api/howler/api/v1/borealis.pyLines 9-17 9 from howler.common.exceptions import AuthenticationException
10 from howler.common.logging import get_logger
11 from howler.common.swagger import generate_swagger_docs
12 from howler.config import cache, config
! 13 from howler.plugins import get_plugins
14 from howler.security import api_login
15
16 SUB_API = "borealis"
17 borealis_api = make_subapi_blueprint(SUB_API, api_version=1) Lines 24-33 24 def get_token(access_token: str) -> str:
25 """Get a borealis token based on the current howler token"""
26 get_borealis_token: Optional[Callable[[str], str]] = None
27
! 28 for plugin in get_plugins():
! 29 if get_borealis_token := plugin.modules.token_functions.get("borealis", None):
30 break
31 else:
32 logger.info("Plugin %s does not modify the borealis access token.") api/howler/app.pyLines 144-160 144 logger.debug("Enabled Borealis Integration")
145 app.register_blueprint(borealis_api)
146
147 for plugin in get_plugins():
! 148 if not plugin.modules.routes:
! 149 continue
150
151 try:
! 152 for route in cast(list[Blueprint], plugin.modules.routes):
153 logger.info("Enabling additional endpoint: %s", route.url_prefix)
154 app.register_blueprint(route)
155 except ImportError:
! 156 logger.info("Plugin %s does not export additional endpoints.", plugin.name)
157
158
159 else:
160 logger.info("Disabled REST API") api/howler/datastore/howler_store.pyLines 36-47 36 def __init__(self, datastore_object: "ESStore"):
37 self.ds = datastore_object
38
39 for plugin in get_plugins():
! 40 for _index, _odm in INDEXES:
! 41 if _odm is not None:
! 42 if modify_odm := plugin.modules.odm.modify_odm.get(_index):
! 43 modify_odm(_odm)
44
45 for _index, _odm in INDEXES:
46 self.ds.register(_index, _odm) api/howler/odm/helper.pyLines 286-294 286
287 new_keys: list[str] = []
288 for plugin in get_plugins():
289 if generate := plugin.modules.odm.generation.get("hit", None):
! 290 _new_keys, hit = generate(hit)
291 new_keys += _new_keys
292
293 if len(new_keys) > 0:
294 logger.debug("%s new top-level fields configured") api/howler/plugins/__init__.pyLines 12-26 12
13 def get_plugins() -> list[BasePluginConfig]:
14 "Get a set of plugin configurations based on the howler settings."
15 for plugin in _config.core.plugins:
! 16 if plugin in PLUGINS:
! 17 continue
18
! 19 try:
! 20 PLUGINS[plugin] = importlib.import_module(f"{plugin}.config").config
! 21 except (ImportError, ModuleNotFoundError):
! 22 logger.exception("Exception when loading plugin")
! 23 PLUGINS[plugin] = None
24
25 return [plugin for plugin in PLUGINS.values() if plugin] api/howler/plugins/config.pyLines 64-96 64
65 data["modules"]["routes"] = new_routes
66
67 if "operations" in data["modules"] and isinstance(data["modules"]["operations"], list):
! 68 new_operations: list[str] = []
! 69 for operation in data["modules"]["operations"]:
! 70 new_operations.append(f"{plugin_name}.actions.{operation}" if "." not in operation else operation)
71
! 72 data["modules"]["operations"] = new_operations
73
74 if "token_functions" in data["modules"] and isinstance(data["modules"]["token_functions"], dict):
! 75 for application, value in data["modules"]["token_functions"].items():
! 76 if value == True: ## noqa: E712
! 77 data["modules"]["token_functions"][application] = f"{plugin_name}.token.{value}:get_token"
78
79 if "odm" not in data["modules"] or not isinstance(data["modules"]["odm"], dict):
80 return data
81
! 82 if "modify_odm" in data["modules"]["odm"] and isinstance(data["modules"]["odm"]["modify_odm"], dict):
! 83 for odm_name, value in data["modules"]["odm"]["modify_odm"].items():
! 84 if data["modules"]["odm"]["modify_odm"][odm_name] == True: ## noqa: E712
! 85 data["modules"]["odm"]["modify_odm"][odm_name] = f"{plugin_name}.odm.{odm_name}:modify_odm"
86
! 87 if "generation" in data["modules"]["odm"] and isinstance(data["modules"]["odm"]["generation"], dict):
! 88 for odm_name, value in data["modules"]["odm"]["generation"].items():
! 89 if data["modules"]["odm"]["generation"][odm_name] == True: ## noqa: E712
! 90 data["modules"]["odm"]["generation"][odm_name] = f"{plugin_name}.odm.{odm_name}:generate"
91
! 92 return data
93
94 @classmethod
95 def settings_customise_sources(
96 cls, ## noqa: ANN102 Full Coverage ReportExpand
|
Howler Evidence Plugin - Coverage ResultsDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
plugins/evidence/evidence/config.pyLines 1-17 1 ## mypy: ignore-errors
! 2 import os
! 3 from pathlib import Path
4
! 5 from howler.plugins.config import BasePluginConfig
! 6 from pydantic_settings import SettingsConfigDict
7
! 8 APP_NAME = os.environ.get("APP_NAME", "howler")
! 9 PLUGIN_NAME = "evidence"
10
! 11 root_path = Path("/etc") / APP_NAME.replace("-dev", "").replace("-stg", "")
12
! 13 config_locations = [
14 Path(__file__).parent / "manifest.yml",
15 root_path / "conf" / f"{PLUGIN_NAME}.yml",
16 Path(os.environ.get("HWL_CONF_FOLDER", root_path)) / f"{PLUGIN_NAME}.yml",
17 ] Lines 16-27 16 Path(os.environ.get("HWL_CONF_FOLDER", root_path)) / f"{PLUGIN_NAME}.yml",
17 ]
18
19
! 20 class EvidenceConfig(BasePluginConfig):
21 "Evidence Plugin Configuration Model"
22
! 23 model_config = SettingsConfigDict(
24 yaml_file=config_locations,
25 yaml_file_encoding="utf-8",
26 strict=True,
27 env_nested_delimiter="__", Lines 28-36 28 env_prefix=f"{PLUGIN_NAME}_",
29 )
30
31
! 32 config = EvidenceConfig()
33
34 if __name__ == "__main__":
35 ## When executed, the config model will print the default values of the configuration
36 import yaml Full Coverage ReportExpand
|
Howler Sentinel Plugin - Coverage ResultsDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
Full Coverage ReportExpand
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.