# coding: utf-8

"""
    Endpoints

    Endpoints API for different services in SKIL  # noqa: E501

    OpenAPI spec version: 1.1.0-beta
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import pprint
import unittest
import uuid

import numpy
import skil_client
from skil_client import *
from skil_client.rest import ApiException


class TestDefaultApi(unittest.TestCase):
    """DefaultApi unit test stubs"""

    @classmethod
    def setUpClass(cls):
        # Test variables -------------------------------------------------------------------------------------------
        cls.deployment_name = "new_deployment_12345"
        cls.model_file = "file:///var/skil/storage/models/ecba969f-46fc-4022-9808-d71706e83585-f3899006" \
                         "-b51b-4b77-9c10-2bc399814c3b.zip"
        cls.model_name = "new_model_12345"
        cls.reimport_model_file = "file:///var/skil/storage/models/e5b0640e-5fd0-11e8-b8bd-000d3a763fb3.pb"

        cls.model_history_id = "82ea36bd-8ccd-4df2-92a6-d188e85cb14f"
        cls.model_history_name = "new_workspace_12345"

        cls.model_instance_id = "8b80de8a-cbef-4269-89c6-1492ab66aa3c"

        cls.experiment_id = "7ab87838-56ec-430a-a147-d6fbbc83d223"

        cls.experiment_name = "new_experiment_12345"
        cls.experiment_notebook_json = '{"paragraphs":[{"title":"Documentation and Samples","text":"%md\n<a ' \
                                       'target=\"_blank\" rel=\"noopener\" href=\"//deeplearning4j.org/doc\">DL4J ' \
                                       'Documentation</a>\n<a target=\"_blank\" rel=\"noopener\" ' \
                                       'href=\"//nd4j.org/doc/\">ND4J Documentation</a>\n<a target=\"_blank\" ' \
                                       'rel=\"noopener\" href=\"//deeplearning4j.org/datavecdoc/\">DataVec (ETL) ' \
                                       'Documentation</a>\nSKIL also comes with support for <a target=\"_blank\" ' \
                                       'rel=\"noopener\" href=\"//keras.io\">Keras</a> and <a target=\"_blank\" ' \
                                       'rel=\"noopener\" href=\"//www.tensorflow.org/\">Tensorflow</a> with ' \
                                       '%pyspark\nFor examples please see <a target=\"_blank\" rel=\"noopener\" ' \
                                       'href=\"//github.com/SkymindIO/SKIL_Examples\">SKIL_Examples</a>",' \
                                       '"user":"admin","dateUpdated":"2018-05-23T13:22:01+0000","config":{' \
                                       '"colWidth":12,"enabled":true,"results":{},"editorSetting":{"language":"text",' \
                                       '"editOnDblClick":false},"editorMode":"ace/mode/text"},"settings":{"params":{' \
                                       '},"forms":{}},"results":{"code":"SUCCESS",' \
                                       '"msg":[{"type":"HTML","data":"<p><a ' \
                                       'target=\"_blank\" rel=\"noopener\" href=\" //deeplearning4j.org/doc\">DL4J ' \
                                       'Documentation</a>\n<br  /><a target=\"_blank\" rel=\"noopener\" href=\" ' \
                                       '//nd4j.org/doc/\">ND4J Documentation</a>\n<br  /><a target=\"_blank\" ' \
                                       'rel=\"noopener\" href=\" //deeplearning4j.org/datavecdoc/\">DataVec (ETL) ' \
                                       'Documentation</a>\n<br  />SKIL also comes with support for <a ' \
                                       'target=\"_blank\" rel=\"noopener\" href=\" //keras.io\">Keras</a> and <a ' \
                                       'target=\"_blank\" rel=\"noopener\" href=\" ' \
                                       '//www.tensorflow.org/\">Tensorflow</a> with %pyspark\n<br  />For examples ' \
                                       'please see <a target=\"_blank\" rel=\"noopener\" href=\" ' \
                                       '//github.com/SkymindIO/SKIL_Examples\">SKIL_Examples</a></p>\n"}]},"apps":[],' \
                                       '"jobName":"paragraph_1527074480510_-105008605",' \
                                       '"id":"20180523-112120_1144547931","dateCreated":"2018-05-23T11:21:20+0000",' \
                                       '"dateStarted":"2018-05-23T13:22:01+0000",' \
                                       '"dateFinished":"2018-05-23T13:22:01+0000","status":"FINISHED",' \
                                       '"progressUpdateIntervalMs":500,"focus":true,"$$hashKey":"object:110"},' \
                                       '{"title":"Imports","text":"import io.skymind.zeppelin.utils._\nimport ' \
                                       'io.skymind.modelproviders.history.client.ModelHistoryClient\nimport ' \
                                       'io.skymind.modelproviders.history.model._\nimport ' \
                                       'org.deeplearning4j.datasets.iterator._\nimport ' \
                                       'org.deeplearning4j.datasets.iterator.impl._\nimport ' \
                                       'org.deeplearning4j.nn.api._\nimport ' \
                                       'org.deeplearning4j.nn.multilayer._\nimport ' \
                                       'org.deeplearning4j.nn.graph._\nimport org.deeplearning4j.nn.conf._\nimport ' \
                                       'org.deeplearning4j.nn.conf.inputs._\nimport ' \
                                       'org.deeplearning4j.nn.conf.layers._\nimport ' \
                                       'org.deeplearning4j.nn.conf.layers._\nimport ' \
                                       'org.deeplearning4j.nn.weights._\nimport ' \
                                       'org.deeplearning4j.optimize.listeners._\nimport ' \
                                       'org.deeplearning4j.api.storage.impl.RemoteUIStatsStorageRouter\nimport ' \
                                       'org.deeplearning4j.ui.stats.StatsListener\nimport ' \
                                       'org.datavec.api.transform._\nimport ' \
                                       'org.nd4j.linalg.activations.Activation\nimport ' \
                                       'org.nd4j.linalg.learning.config._\nimport ' \
                                       'org.nd4j.linalg.lossfunctions.LossFunctions._\nimport ' \
                                       'org.nd4j.linalg.factory.Nd4j\n","user":"admin",' \
                                       '"dateUpdated":"2018-05-23T13:23:32+0000","config":{"colWidth":12,' \
                                       '"enabled":true,"results":{},"editorSetting":{"language":"text",' \
                                       '"editOnDblClick":false},"editorMode":"ace/mode/text"},"settings":{"params":{' \
                                       '},"forms":{}},"results":{"code":"SUCCESS","msg":[{"type":"TEXT",' \
                                       '"data":"import io.skymind.zeppelin.utils._\nimport ' \
                                       'io.skymind.modelproviders.history.client.ModelHistoryClient\nimport ' \
                                       'io.skymind.modelproviders.history.model._\nimport ' \
                                       'org.deeplearning4j.datasets.iterator._\nimport ' \
                                       'org.deeplearning4j.datasets.iterator.impl._\nimport ' \
                                       'org.deeplearning4j.nn.api._\nimport ' \
                                       'org.deeplearning4j.nn.multilayer._\nimport ' \
                                       'org.deeplearning4j.nn.graph._\nimport org.deeplearning4j.nn.conf._\nimport ' \
                                       'org.deeplearning4j.nn.conf.inputs._\nimport ' \
                                       'org.deeplearning4j.nn.conf.layers._\nimport ' \
                                       'org.deeplearning4j.nn.conf.layers._\nimport ' \
                                       'org.deeplearning4j.nn.weights._\nimport ' \
                                       'org.deeplearning4j.optimize.listeners._\nimport ' \
                                       'org.deeplearning4j.api.storage.impl.RemoteUIStatsStorageRouter\nimport ' \
                                       'org.deeplearning4j.ui.stats.StatsListener\nimport ' \
                                       'org.datavec.api.transform._\nimport ' \
                                       'org.nd4j.linalg.activations.Activation\nimport ' \
                                       'org.nd4j.linalg.learning.config._\nimport ' \
                                       'org.nd4j.linalg.lossfunctions.LossFunctions._\nimport ' \
                                       'org.nd4j.linalg.factory.Nd4j\n"}]},"apps":[],' \
                                       '"jobName":"paragraph_1527074480512_-21133345",' \
                                       '"id":"20180523-112120_692958623","dateCreated":"2018-05-23T11:21:20+0000",' \
                                       '"dateStarted":"2018-05-23T13:23:33+0000",' \
                                       '"dateFinished":"2018-05-23T13:23:47+0000","status":"FINISHED",' \
                                       '"progressUpdateIntervalMs":500,"$$hashKey":"object:111"},{"title":"Skil ' \
                                       'Context","text":"val skilContext = new SkilContext()\nval client = ' \
                                       'skilContext.client","user":"admin","dateUpdated":"2018-05-23T13:23:52+0000",' \
                                       '"config":{"colWidth":12,"enabled":true,"results":{},"editorSetting":{' \
                                       '"language":"text","editOnDblClick":false},"editorMode":"ace/mode/text"},' \
                                       '"settings":{"params":{},"forms":{}},"results":{"code":"SUCCESS",' \
                                       '"msg":[{"type":"TEXT","data":"skilContext: ' \
                                       'io.skymind.zeppelin.utils.SkilContext = ' \
                                       'io.skymind.zeppelin.utils.SkilContext@2816b6b3\nclient: ' \
                                       'io.skymind.modelproviders.history.client.ModelHistoryClient = ' \
                                       'io.skymind.modelproviders.history.client.ModelHistoryClient@70a5e002\n"}]},' \
                                       '"apps":[],"jobName":"paragraph_1527074480512_-21133345",' \
                                       '"id":"20180523-112120_289059647","dateCreated":"2018-05-23T11:21:20+0000",' \
                                       '"dateStarted":"2018-05-23T13:23:52+0000",' \
                                       '"dateFinished":"2018-05-23T13:23:53+0000","status":"FINISHED",' \
                                       '"progressUpdateIntervalMs":500,"$$hashKey":"object:112"},{"title":"How to ' \
                                       'interact with SKIL","text":"val numRows = 28\nval numColumns = 28\nval ' \
                                       'outputNum = 10 // number of output classes\nval batchSize = 32 // batch size ' \
                                       'for each epoch\nval rngSeed = 123 // random number seed for ' \
                                       'reproducibility\nval numEpochs = 2 // number of epochs to perform\n\nval ' \
                                       'trainData = ' \
                                       'new MnistDataSetIterator(batchSize, true, 42)\nval testData = new ' \
                                       'MnistDataSetIterator(batchSize, false, 42)\n\nval conf: ' \
                                       'MultiLayerConfiguration = new NeuralNetConfiguration.Builder()\n    .seed(' \
                                       'rngSeed) //include a random seed for reproducibility\n    .optimizationAlgo(' \
                                       'OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT)  // use stochastic ' \
                                       'gradient descent as an optimization algorithm\n    .updater(new Nesterovs(' \
                                       '0.006, 0.9)) //specify the rate of change of the learning rate.\n    .l2(' \
                                       '1e-4)\n    .list()\n    .layer(0, new DenseLayer.Builder() //create the ' \
                                       'first, input layer with xavier initialization\n            .nIn(numRows * ' \
                                       'numColumns)\n            .nOut(1000)\n            .activation(' \
                                       'Activation.RELU)\n            .weightInit(WeightInit.XAVIER)\n            ' \
                                       '.build())\n    .layer(1, new OutputLayer.Builder(' \
                                       'LossFunction.NEGATIVELOGLIKELIHOOD) //create hidden layer\n            .nIn(' \
                                       '1000)\n            .nOut(outputNum)\n            .activation(' \
                                       'Activation.SOFTMAX)\n            .weightInit(WeightInit.XAVIER)\n            ' \
                                       '.build())\n    .build()\n\nval model = new MultiLayerNetwork(' \
                                       'conf)\nmodel.init()\n\n// To see the UI start a UI server with \"%sh skil ' \
                                       'ui\", uncomment the following code and open a new browser \n// ' \
                                       'window to port ' \
                                       '9002.\n//val remoteUIRouter = new RemoteUIStatsStorageRouter(' \
                                       '\"http://localhost:9002\")\n//model.setListeners(new StatsListener(' \
                                       'remoteUIRouter))\n\nmodel.fit(new MultipleEpochsIterator(numEpochs, ' \
                                       'trainData))\n//for (i <- 1 to 10) {\n//  model.fit(trainData.next(' \
                                       '))\n//}\n\nval evaluation = model.evaluate(testData)\n\nval modelId = ' \
                                       'skilContext.addModelToExperiment(z, model, \"Sample MNIST model\")\nval ' \
                                       'evalId = skilContext.addEvaluationToModel(z, modelId, evaluation, \"mlp \" + ' \
                                       'numEpochs + \" epochs\")\n// To use your trained model in your Spark cluster ' \
                                       'add a KeyedDataProvider to a plugin jar and run:\n// import ' \
                                       'io.skymind.skil.daemon.model.SparkArgs\n// val args = SparkArgs.builder(' \
                                       ').master(\"yarn\").build() // All spark-submit options available.\n// ' \
                                       'skilContext.batchInference(z, args, modelId, ' \
                                       '\"io.skymind.skil.train.spark.MnistKeyedProvider\", \"hdfs:/tmp/out1\")",' \
                                       '"user":"admin","dateUpdated":"2018-05-23T13:23:54+0000","config":{' \
                                       '"colWidth":12,"enabled":true,"results":{},"editorSetting":{"language":"text",' \
                                       '"editOnDblClick":false},"editorMode":"ace/mode/text"},"settings":{"params":{' \
                                       '},"forms":{}},"results":{"code":"SUCCESS","msg":[{"type":"TEXT",' \
                                       '"data":"numRows: Int = 28\nnumColumns: Int = 28\noutputNum: Int = ' \
                                       '10\nbatchSize: Int = 32\nrngSeed: Int = 123\nnumEpochs: Int = 2\ntrainData: ' \
                                       'org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator = ' \
                                       'org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator@55ba1f0f' \
                                       '\ntestData: org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator = ' \
                                       'org.deeplearning4j.datasets.iterator.impl.MnistDataSetIterator@1bd40acf\nconf' \
                                       ': org.deeplearning4j.nn.conf.MultiLayerConfiguration = \n{\n  \"backprop\" : ' \
                                       'true,\n  \"backpropType\" : \"Standard\",\n  \"cacheMode\" : \"NONE\",' \
                                       '\n  \"confs\" : [ {\n    \"cacheMode\" : \"NONE\",\n    \"epochCount\" : 0,' \
                                       '\n    \"iterationCount\" : 0,\n    \"l1ByParam\" : { },\n    \"l2ByParam\" : ' \
                                       '{ },\n    \"layer\" : {\n      \"@class\" : ' \
                                       '\"org.deeplearning4j.nn.conf.layers.DenseLayer\",\n      \"activationFn\" : {' \
                                       '\n        \"@class\" : ' \
                                       '\"org.nd4j.linalg.activations.impl.ActivationReLU\"\n  ' \
                                       '    },\n      \"biasInit\" : 0.0,\n      \"biasUpdater\" : null,' \
                                       '\n      \"constraints\" : null,\n      \"dist\" : null,' \
                                       '\n      \"gradientNormalization\" : \"None\",' \
                                       '\n      \"gradientNormalizationThreshold\" : 1.0,\n      \"hasBias\" : true,' \
                                       '\n      \"idropout\" : null,\n      \"iupdater\" : {\n        \"@class\" : ' \
                                       '\"org.nd4j.linalg.learning.config.Nesterovs\",\n        \"learningR...model: ' \
                                       'org.deeplearning4j.nn.multilayer.MultiLayerNetwork = ' \
                                       'org.deeplearning4j.nn.multilayer.MultiLayerNetwork@2a294038\nwarning: there ' \
                                       'were 2 deprecation warning(s); re-run with -deprecation for ' \
                                       'details\nevaluation: org.deeplearning4j.eval.Evaluation = ' \
                                       '\n\n\n========================Evaluation Metrics========================\n # ' \
                                       'of classes:    10\n Accuracy:        0.9626\n Precision:       0.9628\n ' \
                                       'Recall:          0.9621\n F1 Score:        0.9623\nPrecision, recall & F1: ' \
                                       'macro-averaged (equally weighted avg. of 10 ' \
                                       'classes)\n\n\n=========================Confusion ' \
                                       'Matrix=========================\n ' \
                                       '   0    1    2    3    4    5    6    7    ' \
                                       '8    9\n---------------------------------------------------\n' \
                                       '  950    0    4  ' \
                                       '  2    1    5   13    1    2    2 | 0 = 0\n    0 1126    2    1    0    1    ' \
                                       '3    0    2    0 | 1 = 1\n    3    1 1003    4    5    0    3    7    6    0 ' \
                                       '| 2 = 2\n    ' \
                                       '0    1    8  979    0    6    1    7    4    4 | 3 = 3\n    1    ' \
                                       '0    8    0  938    0    7    2    2   24 | 4 = 4\n    4    2   ...modelId: ' \
                                       'String = 8b80de8a-cbef-4269-89c6-1492ab66aa3c\nevalId: String = ' \
                                       '894f58aa-7271-4cb1-ad77-8dccbe9bb64a\n"}]},"apps":[],' \
                                       '"jobName":"paragraph_1527074480512_-21133345",' \
                                       '"id":"20180523-112120_1941505826","dateCreated":"2018-05-23T11:21:20+0000",' \
                                       '"dateStarted":"2018-05-23T13:23:54+0000",' \
                                       '"dateFinished":"2018-05-23T13:31:18+0000","status":"FINISHED",' \
                                       '"progressUpdateIntervalMs":500,"$$hashKey":"object:113"},{"user":"admin",' \
                                       '"dateUpdated":"2018-05-23T13:22:01+0000","config":{"colWidth":12,' \
                                       '"enabled":true,"results":{},"editorSetting":{"language":"text",' \
                                       '"editOnDblClick":false},"editorMode":"ace/mode/text"},"settings":{"params":{' \
                                       '},"forms":{}},"apps":[],"jobName":"paragraph_1527074480512_-21133345",' \
                                       '"id":"20180523-112120_2028902527","dateCreated":"2018-05-23T11:21:20+0000",' \
                                       '"status":"READY","progressUpdateIntervalMs":500,"$$hashKey":"object:114"}],' \
                                       '"name":"/tests/new_experiment_notebook1","id":"2DH623MMT","angularObjects":{' \
                                       '"2DF46NRTZ:existing_process":[],"2DF36G3R9:existing_process":[],' \
                                       '"2DFYYU12F:existing_process":[],"2DEYW4UWG:existing_process":[],' \
                                       '"2DFQEX7SA:existing_process":[],"2DFSHTZJP:existing_process":[],' \
                                       '"2DFBEJ7AM:existing_process":[],"2DGG7Z6Q4:existing_process":[]},' \
                                       '"config":{"looknfeel":"default","personalizedMode":"false"},"info":{}} '
        # ----------------------------------------------------------------------------------------------------------

        debug = False

        cls.host = "localhost"

        cls.config = Configuration()
        cls.config.host = "{}:9008".format(cls.host)  # change this!
        cls.config.debug = debug
        cls.api_client = ApiClient(configuration=cls.config)
        cls.unique_id = str(uuid.uuid4())[:8]
        # create an instance of the API class
        cls.api_instance = skil_client.DefaultApi(api_client=cls.api_client)

        cls.config_mh = Configuration()
        cls.config_mh.host = "{}:9100".format(cls.host)  # change this!
        cls.config_mh.debug = debug
        cls.api_client_mh = ApiClient(configuration=cls.config_mh)
        # create an instance of the Model History API class
        cls.api_instance_mh = skil_client.DefaultApi(api_client=cls.api_client_mh)

        # authenticate
        cls.pp = pprint.PrettyPrinter(indent=4)
        try:
            print("Authenticating with SKIL API...")
            credentials = skil_client.Credentials(user_id="admin", password="admin")
            token = cls.api_instance.login(credentials)
            cls.pp.pprint(token)
            # add credentials to config
            cls.config.api_key['authorization'] = token.token
            cls.config.api_key_prefix['authorization'] = "Bearer"
            # for model history
            cls.config_mh.api_key['authorization'] = token.token
            cls.config_mh.api_key_prefix['authorization'] = "Bearer"
        except ApiException as e:
            print("Exception when calling DefaultApi->login: %s\n" % e)

    @classmethod
    def tearDownClass(cls):
        pass

    def test_get_model_history(self):
        """Test case for get_model_history

        Gets a model history, given its ID  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.get_model_history(self.model_history_id)
        )

    def test_add_model_history(self):
        """Test case for add_model_history

        Add a model history / workspace  # noqa: E501
        """
        model_history_request = AddModelHistoryRequest(self.model_history_name, "Label 1, Label 2")
        self.pp.pprint(
            self.api_instance_mh.add_model_history(model_history_request)
        )

    def test_list_all_experiments(self):
        """Test case for list_all_experiments

        List all of the experiments in every model history / workspace  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.list_all_experiments()
        )

    def test_add_experiment(self):
        """Test case for add_experiment

        Add an experiment, given an experiment entity  # noqa: E501
        """
        self.api_instance_mh.add_experiment(
            ExperimentEntity(
                experiment_id="12345",
                best_model_id=self.model_instance_id,
                experiment_name=self.experiment_name,
                experiment_description="My First experiment",
                model_history_id="d74826ce-3c95-4348-aea3-c730b18a1893"
            )
        )

    def test_add_model_instance(self):
        """Test case for add_model_instance

        Adds a model  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.add_model_instance(
                ModelInstanceEntity(
                    uri="test_uri.zip",
                    model_id="12345",
                    eval_id="12345",
                    model_name="testModel",
                    model_version=1,
                    experiment_id="12345"
                )
            )
        )

    def test_delete_model_history(self):
        """Test case for delete_model_history

        Deletes a model history / workspace, given its ID  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.delete_model_history("d74826ce-3c95-4348-aea3-c730b18a1893")
        )

    def test_add_evaluation_result(self):
        """Test case for add_evaluation_result

        Adds an evaluation result  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.add_evaluation_result(
                EvaluationResultsEntity(
                    evaluation="",
                    eval_name="evaluation",
                    model_instance_id="12345",
                    f1=0.5,
                    precision=0.5,
                    recall=0.5,
                    accuracy=0.5,
                    rmse=0.5,
                    auc=1,
                    mean_absolute_error=0.5,
                    mean_relative_error=0.5,
                    r2=0.5,
                    eval_id="12345",
                    eval_version=1,
                    binary_threshold=0.5
                )
            )
        )
        pass

    def test_add_example_for_batch(self):
        """Test case for add_example_for_batch

        Adds a number of examples to a minibatch ID given an AddExampleRequest.  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.add_example_for_batch(
                AddExampleRequest(
                    minibatch=MinibatchEntity("12345", "12345", 1, 1),
                    batch_size=10
                )
            )
        )

    def test_add_example_to_minibatch(self):
        """Test case for add_example_to_minibatch

        Adds an example to a minibatch  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.add_example_to_minibatch(
                ExampleEntity(
                    example_id="12345",
                    example_version=1,
                    int_row_number=10,
                    mini_batch_id="12345",
                    mini_batch_version=1
                )
            )
        )

    def test_add_minibatch(self):
        """Test case for add_minibatch

        Adds a minibatch  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.add_minibatch(
                MinibatchEntity(mini_batch_id="12345",
                                eval_id="12345",
                                eval_version=1,
                                batch_version=1)
            )
        )

    def test_aggregate_model_results(self):
        """Test case for aggregate_model_results

        Aggregates the evaluaition results of a model instance, based on the evaluation type  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.aggregate_model_results(
                AggregatePrediction(
                    model_id="12345",
                    eval_type="REGRESSON_EVALUATION"
                )
            )
        )

    def test_classify(self):
        """Test case for classify

        Use the deployed model to classify the input  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance.classify(
                deployment_name="deployment_name12345",
                model_name="model_name12345",
                body=Prediction(
                    id="12345",
                    needs_pre_processing=False,
                    prediction=INDArray(
                        shape=[2, 3],
                        data=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6],
                        ordering="c",
                        data_type="FLOAT16"
                    )
                )
            )
        )

    def test_classifyarray(self):
        """Test case for classifyarray

        Same as /classify but returns the output as Base64NDArrayBody  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance.classifyarray(
                deployment_name="deployment_name12345",
                model_name="model_name12345",
                body=Prediction(
                    id="12345",
                    needs_pre_processing=False,
                    prediction=INDArray(
                        shape=[2, 3],
                        data=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6],
                        ordering="c",
                        data_type="FLOAT16"
                    )
                )
            )
        )

    def test_classifyimage(self):
        """Test case for classifyimage

        Use the deployed model to classify the input, using input image file from multipart form data.  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance.classifyimage(
                deployment_name="deployment_name12345",
                model_name="model_name12345"
                # Todo: add a file here
            )
        )

    def test_create_model_history(self):
        """Test case for create_model_history

        Creates model History  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.create_model_history(
                AddModelHistoryRequest("workspace_12345", "label1, label2")
            )
        )

    def test_delete_experiment(self):
        """Test case for delete_experiment

        Deletes an experiment, given an experiment entity  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.delete_experiment("12345")
        )

    def test_delete_model_instance(self):
        """Test case for delete_model_instance

        Deletes a model instance, given its ID  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.delete_model_instance("12345")
        )

    def test_deployment_create(self):
        """Test case for deployment_create

        Create a new deployment group.  # noqa: E501
        """
        create_deployment_request = CreateDeploymentRequest(self.deployment_name)
        deployment_response = self.api_instance.deployment_create(create_deployment_request)

        self.deployment_created_id = deployment_response.id
        self.pp.pprint(deployment_response)

    def test_deployments(self):
        """Test case for deployments

        Get a list of deployments  # noqa: E501
        """
        self.pp.pprint(self.api_instance.deployments())

    def test_deployment_get(self):
        """Test case for deployment_get

        Get a deployment details by id  # noqa: E501
        """
        id_to_get = self.get_deployment_id()
        self.pp.pprint(self.api_instance.deployment_get(id_to_get))

    def test_deploy_model(self):
        """Test case for deploy_model

        Deploy a model in a deployment group.  # noqa: E501
        """
        deployment_id = self.get_deployment_id()
        deploy_model_request = ImportModelRequest(self.model_name, 1, file_location=self.model_file,
                                                  model_type="model",
                                                  uri=["{}/model/{}/default".format(self.deployment_name,
                                                                                    self.model_name),
                                                       "{}/model/{}/v1".format(self.deployment_name,
                                                                               self.model_name)])
        self.pp.pprint(self.api_instance.deploy_model(deployment_id, deploy_model_request))

    def test_reimport_model(self):
        """Test case for reimport_model

        Reimport a model to a previous deployed model in a deployment  # noqa: E501
        """
        deployment_id = self.get_deployment_id()
        model_id = self.get_model_id()
        reimport_model_request = ImportModelRequest(self.model_name, 1, file_location=self.reimport_model_file,
                                                    model_type="model",
                                                    uri=["{}/model/{}/default".format(self.deployment_name,
                                                                                      self.model_name),
                                                         "{}/model/{}/v1".format(self.deployment_name,
                                                                                 self.model_name)],
                                                    jvm_args="-Xmx4g",
                                                    input_names=["x_in"],
                                                    output_names=["vs3model/prediction"])
        self.api_instance.reimport_model(deployment_id, model_id, reimport_model_request)

    def test_model_state_change(self):
        """Test case for model_state_change

        Modify the state (start/stop) of a deployed model  # noqa: E501
        """
        deployment_id = self.get_deployment_id()
        model_id = self.get_model_id()
        self.pp.pprint(self.api_instance.model_state_change(deployment_id, model_id, SetState("start")))
        self.pp.pprint(self.api_instance.model_state_change(deployment_id, model_id, SetState("stop")))

    def test_delete_model(self):
        """Test case for delete_model

        Delete a model by deployment and model id  # noqa: E501
        """
        deployment_id = self.get_deployment_id()
        model_id_to_delete = self.get_model_id()
        self.pp.pprint(self.api_instance.delete_model(deployment_id, model_id_to_delete))

    def test_deployment_delete(self):
        """Test case for deployment_delete

        Delete a deployment by id  # noqa: E501
        """
        id_to_delete = self.get_deployment_id()
        self.pp.pprint(self.api_instance.deployment_delete(id_to_delete))

    def test_detectobjects(self):
        """Test case for detectobjects

        Detect the objects, given a (input) prediction request  # noqa: E501
        """
        pass

    def test_get_best_model_among_model_ids(self):
        """Test case for get_best_model_among_model_ids

        Gets the best model among the given model instance IDs, based on the evaluation type and column metric  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.get_best_model_among_model_ids(
                BestModel(
                    ids=["12345",
                         "23456",
                         "34567",
                         "45678",
                         "56789"],
                    column_name_metric="f1",
                    eval_type="REGRESSON_EVALUATION",
                )
            )
        )

    def test_get_evaluation_for_model_id(self):
        """Test case for get_evaluation_for_model_id

        Gets the list of evaluation results entity, given a model instance ID  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.get_evaluation_for_model_id("12345")
        )

    def test_get_examples_for_minibatch(self):
        """Test case for get_examples_for_minibatch

        Gets all the examples for a minibatch ID  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.get_examples_for_minibatch("12345")
        )

    def test_get_experiment(self):
        """Test case for get_experiment

        Obtain an experiment's details, given its ID  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.get_experiment(self.experiment_id)
        )
        pass

    def test_get_experiments_for_model_history(self):
        """Test case for get_experiments_for_model_history

        Obtain all experiments for a model history / workspace  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.get_experiments_for_model_history(self.model_history_id)
        )
        pass

    def test_get_minibatch(self):
        """Test case for get_minibatch

        Gets a minibatch for the model  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.get_minibatch("12345")
        )

    def test_get_model_instance(self):
        """Test case for get_model_instance

        Gets a model instance, given its ID  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.get_model_instance(self.model_instance_id)
        )

    def test_get_models_for_experiment(self):
        """Test case for get_models_for_experiment

        Obtain a list of all the models for an experiment  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.get_models_for_experiment(self.experiment_id)
        )

    def test_imagetransformprocess_get(self):
        """Test case for imagetransformprocess_get

        Retrieves the image transform process JSON string  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance.imagetransformprocess_get(
                "deployment_name12345",
                "image_transform_name12345"
            )
        )

    def test_imagetransformprocess_post(self):
        """Test case for imagetransformprocess_post

        Sets the image transform process through the provided JSON string  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance.imagetransformprocess_post(
                "deployment_name12345",
                "image_transform_name12345",
                ImageTransformProcess()
            )
        )

    def test_jsonarray(self):
        """Test case for jsonarray

        Run inference on the input and returns it as a JsonArrayResponse  # noqa: E501
        """
        pass

    def test_knn(self):
        """Test case for knn

        Runs knn on the given index with the given k  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance.knn(
                deployment_name="test",
                knn_name="knn",
                body=NearestNeighborRequest(
                    2, 2
                )
            )
        )

    def test_knnnew(self):
        """Test case for knnnew

        Run a k nearest neighbors search on a NEW data point  # noqa: E501
        """
        self.pp.pprint(numpy.array([0.0, 0.0, 0.0]).tostring())
        self.pp.pprint(
            self.api_instance.knnnew(
                "test",
                "knn",
                Base64NDArrayBodyKNN(
                    ndarray="AAdKQVZBQ1BQAAAACAADSU5UAAAAAgAAAAEAAAADAAAAAQAAAAEAAAAAAAAAAQAAAGMAB0pBVkFD\r"
                            "\nUFAAAAADAAVGTE9BVAAAAAAAAAAAAAAAAA==\r\n",  # Array: [0.0, 0.0, 0.0] in base64 encoding
                    k=2,
                    force_fill_k=False
                )
            )
        )

    def test_logfilepath(self):
        """Test case for logfilepath

        Get logs file path  # noqa: E501
        """
        pass

    def test_login(self):
        """Test case for login

        Post JSON credentials and obtain a JWT authorization token.  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance.login(
                Credentials(
                    user_id="admin",
                    password="admin"
                )
            )
        )

    def test_logs(self):
        """Test case for logs

        Get logs  # noqa: E501
        """
        pass

    def test_meta_get(self):
        """Test case for meta_get

        this method can be used to get the meta data for the current model which set to the server  # noqa: E501
        """
        pass

    def test_meta_post(self):
        """Test case for meta_post

        This method can be used to set meta data for the current model which is set to the server  # noqa: E501
        """
        pass

    def test_models(self):
        """Test case for models

        Retrieve a list of all the deployed models given a deployment id  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance.models("12345")
        )

    def test_modelset(self):
        """Test case for modelset

        Set the model to be served  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance.modelset(
                "deployment_name12345",
                "model_name12345"
                # Todo: add a file here
            )
        )

    def test_modelupdate(self):
        """Test case for modelupdate

        Update the model to be served  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance.modelupdate(
                "deployment_name12345",
                "model_name12345"
                # Todo: add a file here
            )
        )

    def test_multiclassify(self):
        """Test case for multiclassify

        Represents all of the labels for a given classification  # noqa: E501
        """
        pass

    def test_multipredict(self):
        """Test case for multipredict

        Get the output from the network, based on the given INDArray[] input  # noqa: E501
        """
        pass

    def test_predict(self):
        """Test case for predict

        Run inference on the input array.  # noqa: E501
        """
        pass

    def test_predictimage(self):
        """Test case for predictimage

        Run inference on the input array, using input image file from multipart form data.  # noqa: E501
        """
        pass

    def test_predictwithpreprocess(self):
        """Test case for predictwithpreprocess

        Preprocesses the input and run inference on it  # noqa: E501
        """
        pass

    def test_predictwithpreprocessjson(self):
        """Test case for predictwithpreprocessjson

        Preprocesses the input and run inference on it and returns it as a JsonArrayResponse  # noqa: E501
        """
        pass

    def test_transform_csv(self):
        """Test case for transform_csv

        Takes a BatchCSVRecord and returns the transformed array as BatchCSVRecord  # noqa: E501
        """
        pass

    def test_transformarray_csv(self):
        """Test case for transformarray_csv

        Takes a batch input arrays and transforms it  # noqa: E501
        """
        pass

    def test_transformarray_image(self):
        """Test case for transformarray_image

        Takes a batch of images uri and transforms it and returns Base64NDArrayBody  # noqa: E501
        """
        pass

    def test_transformimage(self):
        """Test case for transformimage

        Takes multiple multipart image file to transform and returns Base64NDArrayBody  # noqa: E501
        """
        pass

    def test_transformincremental_csv(self):
        """Test case for transformincremental_csv

        Takes SingleCSVRecord as input and returns the transformed array as SingleCSVRecord  # noqa: E501
        """
        pass

    def test_transformincrementalarray_csv(self):
        """Test case for transformincrementalarray_csv

        Same as /transformincremental but returns Base64NDArrayBody  # noqa: E501
        """
        pass

    def test_transformincrementalarray_image(self):
        """Test case for transformincrementalarray_image

        Takes SingleImageRecord to transform and returns Base64NDArrayBody  # noqa: E501
        """
        pass

    def test_transformincrementalimage(self):
        """Test case for transformincrementalimage

        Takes a single multipart image file to transform and returns Base64NDArrayBody  # noqa: E501
        """
        pass

    def test_transformprocess_get(self):
        """Test case for transformprocess_get

        Gets the JSON string of the deployed transform process  # noqa: E501
        """
        pass

    def test_transformprocess_post(self):
        """Test case for transformprocess_post

        Sets the deployed transform process through the provided JSON string  # noqa: E501
        """
        pass

    def test_update_best_model_for_experiment(self):
        """Test case for update_best_model_for_experiment

        Updates the best model for an experiment  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.update_best_model_for_experiment(
                UpdateBestModel(
                    "12345",
                    "12345"
                )
            )
        )

    def test_update_experiment(self):
        """Test case for update_experiment

        Updates an experiment, given an experiment entity  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.update_experiment(
                experiment_id="12345",
                experiment_entity=ExperimentEntity(
                    experiment_name="experiment_name23456",
                    experiment_description="Updated experiment"
                )
            )
        )

    def test_update_model_history(self):
        """Test case for update_model_history

        Update a model history / workspace  # noqa: E501
        """
        self.pp.pprint(
            self.api_instance_mh.update_model_history(
                model_history_id="12345",
                update_model_history_request=AddModelHistoryRequest(
                    model_name="model_history23456",
                    model_labels="label3, label4"
                )
            )
        )

    def test_upload(self):
        """Test case for upload

        Upload a model file to SKIL for import.  # noqa: E501
        """
        pass

    def get_deployment_id(self):
        for deployment in self.api_instance.deployments():
            if deployment.name == self.deployment_name:
                return str(deployment.id)
        return str(-1)

    def get_model_id(self):
        deployment_id = self.get_deployment_id()

        for model in self.api_instance.models(deployment_id):
            if model.name == self.model_name:
                return str(model.id)
        return str(-1)


if __name__ == '__main__':
    unittest.main()
