# Path: studio/model.py
# def reset_storage_providers():
# def get_config(config_file=None):
# def get_db_provider(config=None, blocking_auth=True):
# def get_queue(
#         queue_name=None,
#         cloud=None,
#         config=None,
#         logger=None,
#         close_after=None,
#         verbose=10):
# def shutdown_queue(queue, logger=None, delete_queue=True):
# def get_worker_manager(config, cloud=None, verbose=10):


import unittest
import subprocess
import time
import os
import uuid
import requests
from random import randint
from studio import model
from env_detect import on_gcp

    def _test_serving(self, data_in, expected_data_out, wrapper=None):

        self.port = randint(5000, 9000)
        server_experimentid = 'test_serving_' + str(uuid.uuid4())

        args = [
            'studio', 'run',
            '--force-git',
            '--verbose=debug',
            '--experiment=' + server_experimentid,
            '--config=' + self.get_config_path(),
            'studio::serve_main',
            '--port=' + str(self.port),
            '--host=localhost'
        ]

        if wrapper:
            args.append('--wrapper=' + wrapper)

        subprocess.Popen(args, cwd=os.path.dirname(__file__))
        time.sleep(60)

        try:
            retval = requests.post(
                url='http://localhost:' + str(self.port), json=data_in)
            data_out = retval.json()
            assert data_out == expected_data_out

        finally:

# Path: studio/model.py
# def reset_storage_providers():
# def get_config(config_file=None):
# def get_db_provider(config=None, blocking_auth=True):
# def get_queue(
#         queue_name=None,
#         cloud=None,
#         config=None,
#         logger=None,
#         close_after=None,
#         verbose=10):
# def shutdown_queue(queue, logger=None, delete_queue=True):
# def get_worker_manager(config, cloud=None, verbose=10):


# Path: tests/serving_test.py
import unittest
import subprocess
import time
import os
import uuid
import requests
from random import randint
from studio import model
from env_detect import on_gcp


    def _test_serving(self, data_in, expected_data_out, wrapper=None):

        self.port = randint(5000, 9000)
        server_experimentid = 'test_serving_' + str(uuid.uuid4())

        args = [
            'studio', 'run',
            '--force-git',
            '--verbose=debug',
            '--experiment=' + server_experimentid,
            '--config=' + self.get_config_path(),
            'studio::serve_main',
            '--port=' + str(self.port),
            '--host=localhost'
        ]

        if wrapper:
            args.append('--wrapper=' + wrapper)

        subprocess.Popen(args, cwd=os.path.dirname(__file__))
        time.sleep(60)

        try:
            retval = requests.post(
                url='http://localhost:' + str(self.port), json=data_in)
            data_out = retval.json()
            assert data_out == expected_data_out

        finally:

            with model.get_db_provider(model.get_config(