Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
43 changes: 43 additions & 0 deletions gateway/sds_gateway/api_methods/utils/profilers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Profiler wrappers to check resource usage.
To use, import the decorator as such:
from sds_gateway.api_methods.utils.profilers import profile_memory
Then annotate functions to profile with @profile_memory"""

import functools
import threading
import tracemalloc

from loguru import logger

_tracemalloc_lock = threading.Lock()


def profile_memory(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
with _tracemalloc_lock:
owns_tracing = not tracemalloc.is_tracing()

if owns_tracing:
tracemalloc.start()

try:
return func(*args, **kwargs)
Comment thread
mjcurran marked this conversation as resolved.
finally:
current, peak = tracemalloc.get_traced_memory()

if owns_tracing and tracemalloc.is_tracing():
tracemalloc.stop()

logger.info(
"[Memory Profiler] {} Current: {:.2f} MB",
func.__name__,
current / 10**6,
)
logger.info(
"[Memory Profiler] {} Peak: {:.2f} MB",
func.__name__,
peak / 10**6,
)

return wrapper
28 changes: 28 additions & 0 deletions gateway/sds_gateway/static/css/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,34 @@ textarea.form-control-plaintext {
margin-bottom: 1rem;
}

.provider-list {
display: grid;
gap: 0.75rem;
width: min(100%, 22rem);
margin: 0;
padding: 0;
list-style: none;
}

.hero-content .provider-list .social-provider-button {
display: flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
width: 100%;
min-height: 44px;
color: var(--bs-white);
font-weight: 500;
text-decoration: none;
}

.hero-content .provider-list .social-provider-button:hover,
.hero-content .provider-list .social-provider-button:focus,
.hero-content .provider-list .social-provider-button:active {
color: var(--bs-white);
text-decoration: none;
}

/* Custom Table */
.custom-table {
width: 100%;
Expand Down
8 changes: 4 additions & 4 deletions gateway/sds_gateway/templates/allauth/elements/provider.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<li>
<a href="{{ attrs.href }}"
title="{{ attrs.name }}"
class="btn btn-primary">
<i class="fa fa-{{ attrs.name }}"></i>
{{ attrs.name }}
title="Sign in with {{ attrs.name }}"
class="btn btn-primary social-provider-button">
<i class="fa-solid fa-right-to-bracket" aria-hidden="true"></i>
<span>Continue with {{ attrs.name }}</span>
</a>
</li>
8 changes: 7 additions & 1 deletion gateway/sds_gateway/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@
{% else %}
<li class="nav-item">
{% comment %} URL provided by django-allauth/account/urls.py {% endcomment %}
<a id="log-in-nav-link" class="nav-link" href="{% url 'auth0_login' %}">{% translate "Sign In" %}</a>
{% if SOCIALACCOUNT_ONLY %}
<a id="log-in-nav-link" class="nav-link" href="{% url 'auth0_login' %}">{% translate "Sign In" %}</a>
{% else %}
<a id="log-in-nav-link"
class="nav-link"
href="{% url 'account_login' %}">{% translate "Sign In" %}</a>
{% endif %}
</li>
{% endif %}
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% if socialaccount_providers %}
{% if not SOCIALACCOUNT_ONLY %}
{% element h2 %}
{% translate "Or use a third-party" %}
{% translate "Or use a third-party ID provider" %}
{% endelement %}
{% endif %}
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
Expand Down