"""
WSGI config for server project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')

application = get_wsgi_application()

import inspect
from apps.ml.registry import MLRegistry
from apps.ml.income_classifier.random_forest import RandomForestClassifier

try:
    registry = MLRegistry()

    rf = RandomForestClassifier()

    registry.add_algorithm(endpoint_name="income_classifier",algorithm_object=rf,algorithm_name="random forest", algorithm_status="production", algorithm_version="0.0.1",owner="Piotr",algorithm_description="Random forest with simple pre and post processing",algorithm_code=inspect.getsource(RandomForestClassifier))
except Exception as e:
    print ("Error while loading algorithm to the registry",str(e))

[(14, 'os.environ.setdefault', 'os.environ.setdefault', False, 'import os\n'), (16, 'django.core.wsgi.get_wsgi_application', 'get_wsgi_application', False, 'from django.core.wsgi import get_wsgi_application\n'), (23, 'apps.ml.registry.MLRegistry', 'MLRegistry', False, 'from apps.ml.registry import MLRegistry\n'), (25, 'apps.ml.income_classifier.random_forest.RandomForestClassifier', 'RandomForestClassifier', False, 'from apps.ml.income_classifier.random_forest import RandomForestClassifier\n'), (27, 'inspect.getsource', 'inspect.getsource', False, 'import inspect\n')]