Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • kj2-drupisz/desd
1 result
Select Git revision
Show changes
{% extends "_base.html" %}
{% block content %}
<div class="container mx-auto px-4">
<h1 class="text-2xl font-bold mb-4">Model Performance</h1>
{% if metrics %}
<div class="bg-white shadow-md rounded p-6">
<p><strong>Request Count:</strong> {{ metrics.request_count }}</p>
<p><strong>Average Request Latency:</strong> {{ metrics.avg_request_latency|floatformat:6 }} seconds</p>
<p><strong>Average Runtime Latency:</strong> {{ metrics.avg_runtime_latency|floatformat:6 }} seconds</p>
<p><strong>Model Load Latency:</strong> {{ metrics.model_load_latency|floatformat:6 }} seconds</p>
</div>
{% else %}
<p>Failed to retrieve model performance metrics.</p>
{% endif %}
</div>
{% endblock content %}
\ No newline at end of file
......@@ -7,11 +7,23 @@
User settings
</h1>
<h3 class="mb-4 text-xl font-semibold dark:text-white">
User type: {{ user_profile.user_type }}
{% if user_profile.is_superuser %}
User type: Superuser
{% elif user_profile.user_type == 0 %}
User type: User
{% elif user_profile.user_type == 1 %}
User type: Admin
{% elif user_profile.user_type == 2 %}
User type: ML Engineer
{% elif user_profile.user_type == 3 %}
User type: Accountant
{% else %}
User type: Unknown
{% endif %}
</h3>
</div>
<!-- Right Content -->
<div class="col-span-full xl:col-auto">
<div class="p-4 mb-4 bg-white border boder-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<h3 class="mb-4 text-xl font-semibold dark:text-white">Tokens:</h3>
......@@ -21,13 +33,13 @@
<h3 class="mb-4 text-xl font-semibold dark:text-white">Change your password</h3>
<a href="{% url 'password_change' %}" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Change Password</a>
</div>
{% if user_profile.user_type == 3 %}
{% if user_profile.user_type == 3 or user.is_superuser or user_profile.user_type == 1%}
<div
class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"
>
<h3 class="mb-4 text-xl font-semibold dark:text-white">
Generate Financial Statement
</h3>
......@@ -76,7 +88,7 @@
{% comment %} REPLACE WITH LOGIC TO CHECK PROPER USER {% endcomment %}
</div>
{% endif %}
{% if 1 %}
{% if user_profile.user_type == 2 or user.is_superuser or user_profile.user_type == 1%}
<div
class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"
......@@ -115,8 +127,13 @@
</div>
{% comment %} AI content {% endcomment %} {% endif%}
</div>
<div class="col-span-2">
{% if user_profile.user_type == 2 or user.is_superuser %}
<div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<h3 class="mb-4 text-xl font-semibold dark:text-white">Model Performance</h3>
<a href="{% url 'model_performance' %}" class="text-blue-500 hover:underline">View Model Performance</a>
</div>
{% endif %}
<div
class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"
>
......@@ -137,8 +154,12 @@
class="shadow-sm bg-gray-50 border border-gray-300 text-grey-300 sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="example@gmail.com"
required
>{{ user.email }}</span
>
{% if user.email %}
<span>{{ user.email }}</span>
{% else %}
<span>No email address on record.</span>
{% endif %}
</div>
<div class="col-span-6 sm:col-span-3">
<label
......@@ -158,6 +179,17 @@
</div>
</div>
</div>
<!-- Modal -->
<div id="myModal" class="hidden fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50">
<!-- Modal content with scrolling enabled -->
<div class="modal-body bg-white dark:bg-gray-800 rounded-lg p-4 md:p-6 w-full max-w-2xl">
<h3 class="text-2xl font-bold mb-4">Predictions:</h3>
<ul id="predictionList" class="space-y-2"></ul>
<button onclick="closeModal()" class="mt-4 px-4 py-2 bg-red-500 text-white rounded-md hover:bg-red-600">Close</button>
</div>
</div>
<div
class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"
>
......@@ -192,61 +224,147 @@
class="font-medium text-blue-600 dark:text-blue-500 hover:underline"
>{{entry.file}}</a
>
{% if entry.description %}
<button type="button" class="ml-4 px-2 py-1 bg-blue-500 text-white rounded-md hover:bg-blue-600" onclick="showModal('{{entry.description|join:'\n'}}')">
Show Results
</button>
{% endif %}
</td>
</tr>
{%endfor%}
</tbody>
</table>
</div>
{% if 1 %} {% comment %} REPLACE WITH LOGIC TO CHECK PROPER USER
{%endcomment %}
{% if user_profile.user_type == 2 %}
<div
class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800"
>
<h3 class="mb-4 text-xl font-semibold dark:text-white">
Application Logs
</h3>
<table
class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400"
>
<thead
class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400"
>
<tr>
<th scope="col" class="px-6 py-3">Date</th>
<th scope="col" class="px-6 py-3">Action</th>
<th scope="col" class="px-6 py-3">User ID</th>
<th scope="col" class="px-6 py-3">status</th>
</tr>
</thead>
<tbody>
{% for entry in admin_data %}
<tr
class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700"
>
<td
scope="row"
class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white"
>
{{entry.date}} </td>
<td class="px-6 py-4">
<a
href="#"
class="font-medium text-blue-600 dark:text-blue-500 hover:underline"
>{{entry.action}}</a
>
</td>
<td class="px-6 py-4">{{entry.user}}</td>
<td class="px-6 py-4">
{{entry.status}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% if 1 %} {% comment %} REPLACE WITH LOGIC TO CHECK PROPER USER {% endcomment %}
{% if user_profile.user_type == 2 or user.is_superuser %}
<div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<h3 class="mb-4 text-xl font-semibold dark:text-white">Application Logs</h3>
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr>
<th scope="col" class="px-6 py-3">Date</th>
<th scope="col" class="px-6 py-3">Action</th>
<th scope="col" class="px-6 py-3">User ID</th>
<th scope="col" class="px-6 py-3">Status</th>
<th scope="col" class="px-6 py-3">Feedback</th>
</tr>
</thead>
<tbody>
{% for entry in admin_data %}
<tr class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700">
<td scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
{{entry.date}}
</td>
<td class="px-6 py-4">
<a href="#" class="font-medium text-blue-600 dark:text-blue-500 hover:underline">{{entry.action}}</a>
{% if entry.description %}
<button type="button" class="ml-4 px-2 py-1 bg-blue-500 text-white rounded-md hover:bg-blue-600" onclick="showModal('{{entry.description|join:'\n'}}')">
Show Results
</button>
{% endif %}
</td>
<td class="px-6 py-4">{{entry.user}}</td>
<td class="px-6 py-4">{{entry.status}}</td>
<td class="px-6 py-4">
{% if entry.feedback is not None %}
{% if entry.feedback %}
<span class="text-green-500">Liked</span>
{% else %}
<span class="text-red-500">Disliked</span>
{% endif %}
{% else %}
N/A
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% if user.is_superuser or user_profile.user_type == 1 %}
<div class="p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
<h3 class="mb-4 text-xl font-semibold dark:text-white">
User Management
</h3>
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr>
<th scope="col" class="px-6 py-3">Username</th>
<th scope="col" class="px-6 py-3">User Type</th>
<th scope="col" class="px-6 py-3">Actions</th>
</tr>
</thead>
<tbody>
{% for user_profile in all_user_profiles %}
<tr class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700">
<td class="px-6 py-4">{{ user_profile.user.username }}</td>
<td class="px-6 py-4">
{% if user_profile.is_superuser %}
Superuser
{% elif user_profile.user_type == 1 %}
Admin
{% elif user_profile.user_type == 2 %}
ML Engineer
{% elif user_profile.user_type == 3 %}
Accountant
{% else %}
User
{% endif %}
</td>
<td class="px-6 py-4">
<form action="{% url 'change_user_type' user_profile.user.id %}" method="post">
{% csrf_token %}
<select name="user_type">
<option value="0">User</option>
<option value="1">Admin</option>
<option value="2">ML Engineer</option>
<option value="3">Accountant</option>
</select>
<button type="submit" class="p-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">
Change User Type
</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% endif %} {% comment %} Admin page functionality end {% endcomment %}
</div>
</div>
{% endblock content %}
{% block scripts %}
<script>
function showModal(predictions, action) {
var predictionList = document.getElementById('predictionList');
predictionList.innerHTML = '';
// Split the predictions string into an array
var predictionsArray = predictions.split(', ');
// Iterate over the predictionsArray and create list items
predictionsArray.forEach(function(prediction) {
var li = document.createElement('li');
li.innerHTML = prediction;
li.className = 'bg-gray-100 dark:bg-gray-700 px-4 py-2 rounded-md';
predictionList.appendChild(li);
});
document.getElementById('myModal').classList.remove('hidden');
}
function closeModal() {
document.getElementById('myModal').classList.add('hidden');
}
</script>
{% endblock scripts %}
from django.urls import path
from .views import InstrumentDetectionView, index, users, maintenance, handler404, handler500, terms_conditions, privacy_policy, handling_music_file, pricing, generate_pdf, admin_table
from .views import InstrumentDetectionView, ModelPerformanceView, index, log_fileupload, users, maintenance, \
handler404, handler500, terms_conditions, privacy_policy, pricing, generate_pdf, admin_table,\
change_user_type, submit_feedback
from .payments import create_payment, execute_payment, payment_cancelled, payment_success
from django.contrib.auth import views as auth_views
......@@ -18,19 +20,21 @@ urlpatterns = [
path('terms_conditions/', terms_conditions, name='terms_conditions'),
path('pricay_policy/', privacy_policy, name='privacy_policy'),
path('pricing/', pricing, name='pricing'),
path('uploading_file/', handling_music_file, name='uploading_file'),
path('submit_feedback/', submit_feedback, name='submit_feedback'),
path('generate_pdf/', generate_pdf, name='generate_pdf'),
path('pricing/', pricing, name='pricing'),
path('generate_pdf/', generate_pdf, name='generate_pdf'),
path('admin_table/', admin_table, name='admin_table'),
path('instrument_detection/', InstrumentDetectionView.as_view(), name='instrument_detection'),
path('model_performance/', ModelPerformanceView.as_view(), name='model_performance'),
path('password_change/', auth_views.PasswordChangeView.as_view(template_name='password_change_form.html'), name='password_change'),
path('password_change/done/', auth_views.PasswordChangeDoneView.as_view(template_name='password_change_done.html'), name='password_change_done'),
# path('user_logout/', auth_views.LogoutView.as_view(next_page='index'), name='user_logout'),
path('payment/create/', create_payment, name='create_payment'),
path('payment/execute/', execute_payment, name='execute_payment'),
path('payment/cancel/', payment_cancelled, name='payment_cancelled'),
path('payment_success/', payment_success, name='success'),
# Logging
path('log_fileupload', log_fileupload, name='log_fileupload'),
# Admin
path('change_user_type/<int:user_id>/', change_user_type, name='change_user_type'),
path('admin_table/', admin_table, name='admin_table'),
# Authentication
path('login/', CustomLoginView.as_view(), name='login'),
......@@ -42,4 +46,5 @@ urlpatterns = [
path('payment/execute/', execute_payment, name='execute_payment'),
path('payment/cancel/', payment_cancelled, name='payment_cancelled'),
path('payment_success/', payment_success, name='success')
]
This diff is collapsed.
No preview for this file type
No preview for this file type
......@@ -26,7 +26,7 @@ SECRET_KEY = 'django-insecure-t%k1f1!c4_9f#x@r_z_k69oz21@0eadh2qb_k3pm3=gknej9f@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ["*"]
ALLOWED_HOSTS = ['*']
# Application definition
......@@ -173,10 +173,10 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
IMAGE_URL = 'static/src/images/'
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'
#PayPal API settings
PAYPAL_MODE = 'sandbox'
PAYPAL_CLIENT_ID = 'AYpHxonrFMrgnqmjii46SeNsQidn2PjJtEoIgVK0Nrda1iQFUbX28zyuMvUiJk67o_cHII3c8vCMWY-y'
PAYPAL_CLIENT_SECRET = 'EPXXK3Z7xDr4Gy_kt4OkPLbJRXd9tP62q1Dpbmj5QiwaFh7twcSUalHDRBbFRwxdX_rmHk_F6YStXa95'
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'tensorflow_serving'
scrape_interval: 5s
metrics_path: /monitoring/prometheus/metrics
static_configs:
- targets: ['tensorflow_serving:8501']
\ No newline at end of file
#!/usr/bin/env bash
# Use this script to test if a given TCP host/port are available
WAITFORIT_cmdname=${0##*/}
echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
usage()
{
cat << USAGE >&2
Usage:
$WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
-h HOST | --host=HOST Host or IP under test
-p PORT | --port=PORT TCP port under test
Alternatively, you specify the host and port as host:port
-s | --strict Only execute subcommand if the test succeeds
-q | --quiet Don't output any status messages
-t TIMEOUT | --timeout=TIMEOUT
Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit 1
}
wait_for()
{
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
else
echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
fi
WAITFORIT_start_ts=$(date +%s)
while :
do
if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
nc -z $WAITFORIT_HOST $WAITFORIT_PORT
WAITFORIT_result=$?
else
(echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
WAITFORIT_result=$?
fi
if [[ $WAITFORIT_result -eq 0 ]]; then
WAITFORIT_end_ts=$(date +%s)
echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
break
fi
sleep 1
done
return $WAITFORIT_result
}
wait_for_wrapper()
{
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
if [[ $WAITFORIT_QUIET -eq 1 ]]; then
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
else
timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
fi
WAITFORIT_PID=$!
trap "kill -INT -$WAITFORIT_PID" INT
wait $WAITFORIT_PID
WAITFORIT_RESULT=$?
if [[ $WAITFORIT_RESULT -ne 0 ]]; then
echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
fi
return $WAITFORIT_RESULT
}
# process arguments
while [[ $# -gt 0 ]]
do
case "$1" in
*:* )
WAITFORIT_hostport=(${1//:/ })
WAITFORIT_HOST=${WAITFORIT_hostport[0]}
WAITFORIT_PORT=${WAITFORIT_hostport[1]}
shift 1
;;
--child)
WAITFORIT_CHILD=1
shift 1
;;
-q | --quiet)
WAITFORIT_QUIET=1
shift 1
;;
-s | --strict)
WAITFORIT_STRICT=1
shift 1
;;
-h)
WAITFORIT_HOST="$2"
if [[ $WAITFORIT_HOST == "" ]]; then break; fi
shift 2
;;
--host=*)
WAITFORIT_HOST="${1#*=}"
shift 1
;;
-p)
WAITFORIT_PORT="$2"
if [[ $WAITFORIT_PORT == "" ]]; then break; fi
shift 2
;;
--port=*)
WAITFORIT_PORT="${1#*=}"
shift 1
;;
-t)
WAITFORIT_TIMEOUT="$2"
if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
shift 2
;;
--timeout=*)
WAITFORIT_TIMEOUT="${1#*=}"
shift 1
;;
--)
shift
WAITFORIT_CLI=("$@")
break
;;
--help)
usage
;;
*)
echoerr "Unknown argument: $1"
usage
;;
esac
done
if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
echoerr "Error: you need to provide a host and port to test."
usage
fi
WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-30}
WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
# Check to see if timeout is from busybox?
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
WAITFORIT_BUSYTIMEFLAG=""
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
WAITFORIT_ISBUSY=1
# Check if busybox timeout uses -t flag
# (recent Alpine versions don't support -t anymore)
if timeout &>/dev/stdout | grep -q -e '-t '; then
WAITFORIT_BUSYTIMEFLAG="-t"
fi
else
WAITFORIT_ISBUSY=0
fi
if [[ $WAITFORIT_CHILD -gt 0 ]]; then
wait_for
WAITFORIT_RESULT=$?
exit $WAITFORIT_RESULT
else
if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
wait_for_wrapper
WAITFORIT_RESULT=$?
else
wait_for
WAITFORIT_RESULT=$?
fi
fi
if [[ $WAITFORIT_CLI != "" ]]; then
if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
exit $WAITFORIT_RESULT
fi
exec "${WAITFORIT_CLI[@]}"
else
exit $WAITFORIT_RESULT
fi
\ No newline at end of file