Skip to content
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

Add deployment check that dummy provider is not configured #3340

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/grandchallenge/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,21 @@ def check_sagemaker_is_used(app_configs, **kwargs):
)

return errors


@register(deploy=True)
def check_dummy_provider_is_not_used(app_configs, **kwargs):
amickan marked this conversation as resolved.
Show resolved Hide resolved
from django.conf import settings

errors = []

if "dummy" in settings.SOCIALACCOUNT_PROVIDERS.keys():
errors.append(
Error(
"The dummy social account provider is configured. This provider should only be used for testing purposes and not in production.",
hint="Remove the dummy provider from SOCIALACCOUNT_PROVIDERS in your settings.",
id="grandchallenge.components.E002",
amickan marked this conversation as resolved.
Show resolved Hide resolved
)
)

return errors
18 changes: 17 additions & 1 deletion app/tests/components_tests/test_checks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from grandchallenge.components import check_sagemaker_is_used
from grandchallenge.components import (
check_dummy_provider_is_not_used,
check_sagemaker_is_used,
)
from grandchallenge.components.backends.amazon_sagemaker_training import (
AmazonSageMakerTrainingExecutor,
)
Expand All @@ -13,3 +16,16 @@ def test_check_sagemaker_is_used(settings):
assert len(errors) == 1
assert errors[0].id == "grandchallenge.components.E001"
assert errors[0].msg == f"{expected_backend} is not the default backend."


def test_check_dummy_provider_is_not_used(settings):
settings.SOCIALACCOUNT_PROVIDERS = {"dummy": {}}

errors = check_dummy_provider_is_not_used(None)

assert len(errors) == 1
assert errors[0].id == "grandchallenge.components.E002"
assert (
errors[0].msg
== "The dummy social account provider is configured. This provider should only be used for testing purposes and not in production."
)