Skip to content

Commit

Permalink
FIX all Docker bugs, change to py38, and remove all React.js references
Browse files Browse the repository at this point in the history
  • Loading branch information
joseverav committed Feb 9, 2023
1 parent 807fdee commit 840607c
Show file tree
Hide file tree
Showing 30 changed files with 50 additions and 29,693 deletions.
13 changes: 1 addition & 12 deletions backend/server/apps/endpoints/admin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
from django.contrib import admin


# Import models
from apps.endpoints.models import Endpoint #, MLAlgorithm, MLRequest

# Create a class for the admin-model integration
class MLAdmin(admin.ModelAdmin):

# add the fields of the model here
list_display = ("name", "owner" , "created_at")

# Register model class and admin model class
admin.site.register(Endpoint, MLAdmin)
# Register your models here.
1 change: 0 additions & 1 deletion backend/server/apps/endpoints/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@


class EndpointsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.endpoints'
14 changes: 5 additions & 9 deletions backend/server/apps/endpoints/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# backend/server/apps/endpoints/urls.py file
from django.contrib import admin
from django.urls import re_path, include
from django.conf.urls import url, include
from rest_framework.routers import DefaultRouter

from apps.endpoints.views import EndpointViewSet
Expand All @@ -19,13 +17,11 @@
router.register(r"abtests", ABTestViewSet, basename="abtests")

urlpatterns = [
re_path('admin/', admin.site.urls),
re_path(r"^api/v1/", include(router.urls)),
# add predict url
re_path(
url(r"^api/v1/", include(router.urls)),
url(
r"^api/v1/(?P<endpoint_name>.+)/predict$", PredictView.as_view(), name="predict"
),
re_path(
url(
r"^api/v1/stop_ab_test/(?P<ab_test_id>.+)", StopABTestView.as_view(), name="stop_ab"
),
]
]
26 changes: 12 additions & 14 deletions backend/server/apps/endpoints/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
import json
from numpy.random import rand
from rest_framework import views, status
from rest_framework.exceptions import APIException
from rest_framework.response import Response
from apps.ml.registry import MLRegistry
from server.wsgi import registry

from django.shortcuts import render
from rest_framework import viewsets
from rest_framework import mixins

Expand All @@ -26,10 +17,12 @@
from apps.endpoints.models import ABTest
from apps.endpoints.serializers import ABTestSerializer

from django.db.models import F
import datetime

# Create your views here
import json
from numpy.random import rand
from rest_framework import views, status
from rest_framework.response import Response
from apps.ml.registry import MLRegistry
from server.wsgi import registry

class EndpointViewSet(
mixins.RetrieveModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet
Expand Down Expand Up @@ -121,6 +114,8 @@ def post(self, request, endpoint_name, format=None):

return Response(prediction)



class ABTestViewSet(
mixins.RetrieveModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet,
mixins.CreateModelMixin, mixins.UpdateModelMixin
Expand Down Expand Up @@ -151,6 +146,9 @@ def perform_create(self, serializer):
except Exception as e:
raise APIException(str(e))

from django.db.models import F
import datetime

class StopABTestView(views.APIView):
def post(self, request, ab_test_id, format=None):

Expand Down Expand Up @@ -203,4 +201,4 @@ def post(self, request, ab_test_id, format=None):
return Response({"status": "Error", "message": str(e)},
status=status.HTTP_400_BAD_REQUEST
)
return Response({"message": "AB Test finished.", "summary": summary})
return Response({"message": "AB Test finished.", "summary": summary})
46 changes: 17 additions & 29 deletions backend/server/server/settings.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,44 @@
"""
Django settings for server project.
Generated by 'django-admin startproject' using Django 4.0.6.
Generated by 'django-admin startproject' using Django 2.2.4.
For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-26mllr9@*^xnmr-5$j6434bmv39@@t!+c50%sc-!&*(g@p-1)o'
SECRET_KEY = '^lw0)9982b8nt^^-t34967jnl(n7iojl!q+!5xojw9mr6u0h9f'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1']

# White listing the localhost:3000 port
# for React
CORS_ORIGIN_WHITELIST = (
'http://localhost:3000',
)

# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Django rest and corsheaders
'rest_framework',
'corsheaders',
# Apps
'rest_framework', # add django rest framework
# apps
'apps.endpoints',
'apps.ml'
]
Expand All @@ -58,8 +51,6 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
# add corsheaders
'corsheaders.middleware.CorsMiddleware',
]

ROOT_URLCONF = 'server.urls'
Expand All @@ -84,18 +75,18 @@


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
Expand All @@ -114,24 +105,21 @@


# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
2 changes: 1 addition & 1 deletion backend/server/server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
# backend/server/server/urls.py file
from django.urls import re_path, include
from django.conf.urls import url, include
from django.contrib import admin
from django.urls import path

Expand Down
23 changes: 0 additions & 23 deletions frontend/frontend/.gitignore

This file was deleted.

70 changes: 0 additions & 70 deletions frontend/frontend/README.md

This file was deleted.

Loading

0 comments on commit 840607c

Please sign in to comment.