Skip to content

Commit

Permalink
checks
Browse files Browse the repository at this point in the history
  • Loading branch information
domdinicola committed Sep 13, 2024
1 parent b6e672f commit 7b48dda
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 7 deletions.
64 changes: 63 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ dev = [
"isort",
"mypy",
"openpyxl-stubs",
"pdbpp",
"pre-commit",
"pytest",
"pytest-celery>=1.0.0",
Expand Down
12 changes: 9 additions & 3 deletions src/hope_dedup_engine/apps/core/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def example_check(app_configs, **kwargs: Any):
return errors


@register()
@register(deploy=True)
def storages_check(app_configs: Any, **kwargs: Any) -> list[Error]: # pragma: no cover
"""
Checks if the necessary environment variables for Azure storage are configured
Expand All @@ -66,7 +66,12 @@ def storages_check(app_configs: Any, **kwargs: Any) -> list[Error]: # pragma: n
list[Error]: A list of Django Error objects, reporting missing environment variables,
missing files, or errors while accessing Azure storage containers.
"""
storages = ("FILE_STORAGE_DNN", "FILE_STORAGE_HOPE")
storages = (
"FILE_STORAGE_DNN",
"FILE_STORAGE_HOPE",
"FILE_STORAGE_STATIC",
"FILE_STORAGE_MEDIA",
)

errors = [
Error(
Expand All @@ -88,8 +93,9 @@ def storages_check(app_configs: Any, **kwargs: Any) -> list[Error]: # pragma: n
if options:
try:
storage = AzureStorage(**options)
_, files = storage.listdir()
storage.client.exists()
if storage_name == "FILE_STORAGE_DNN":
_, files = storage.listdir()
for _, info in settings.DNN_FILES.items():
filename = info.get("filename")
if filename not in files:
Expand Down
6 changes: 4 additions & 2 deletions src/hope_dedup_engine/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ def storage(self, value: str) -> dict[str, str | dict[str, Any]] | None:
return None
options = {}
if "?" in raw_value:
value, options = raw_value.split("?", 1)
options = dict(parse.parse_qsl(options))
value, args = raw_value.split("?", 1)
for entry in args.split("&"):
k, v = entry.split("=", 1)
options[k] = v
else:
value = raw_value

Expand Down
2 changes: 1 addition & 1 deletion src/hope_dedup_engine/config/fragments/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DNN_FILES: Final[dict[str, dict[str, str]]] = {
"prototxt": {
"filename": "deploy.prototxt",
"filename": "deploy.prototxt.txt",
"sources": {
"github": "https://raw.githubusercontent.com/sr6033/face-detection-with-OpenCV-and-DNN/master/deploy.prototxt.txt", # noqa: E501
"azure": "deploy.prototxt",
Expand Down

0 comments on commit 7b48dda

Please sign in to comment.