def setUp(self):
        # set configuration
        config = Configuration()
        config.host = "http://localhost:9008"
        config.api_key_prefix['authorization'] = 'Bearer'

        # initialize instance
        api_instance = skil_client.DefaultApi(api_client=ApiClient(
            configuration=config))

        creds = skil_client.Credentials(user_id="admin", password="******")
        res = api_instance.login(creds)
        config.api_key['authorization'] = res.to_dict()['token']

        return api_instance
Exemple #2
0
    def __init__(self,
                 workspace_server_id=None,
                 host='localhost',
                 port=9008,
                 debug=False,
                 user_id='admin',
                 password='******'):

        self.printer = pprint.PrettyPrinter(indent=4)

        config = skil_client.Configuration()
        config.host = "{}:{}".format(host, port)
        config.debug = debug
        self.config = config
        self.uploads = []
        self.uploaded_model_names = []
        self.auth_headers = None

        self.api_client = skil_client.ApiClient(configuration=config)
        self.api = skil_client.DefaultApi(api_client=self.api_client)

        try:
            self.printer.pprint('>>> Authenticating SKIL...')
            credentials = skil_client.Credentials(user_id=user_id,
                                                  password=password)
            token = self.api.login(credentials)
            self.token = token.token
            config.api_key['authorization'] = self.token
            config.api_key_prefix['authorization'] = "Bearer"
            self.printer.pprint('>>> Done!')
        except skil_client.rest.ApiException as e:
            raise Exception(
                "Exception when calling DefaultApi->login: {}\n".format(e))

        if workspace_server_id:
            self.server_id = workspace_server_id
        else:
            self.server_id = self.get_default_server_id()
Exemple #3
0
 def testLogRequest(self):
     api_instance = self.setUp()
     creds = skil_client.Credentials(user_id="admin", password="******")
     res = api_instance.login(creds)
     pprint(res)
     self.tearDown()
config_mh = Configuration()
config_mh.host = "{}:9100".format(
    host
)  # change this if you're using a different port number for the model server!
config_mh.debug = debug
api_client_mh = ApiClient(configuration=config_mh)
# create an instance of the Model History API class
api_instance_mh = skil_client.DefaultApi(api_client=api_client_mh)

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

print("Uploading model, please wait...")
modelFile = "/model.pb"
uploads = api_instance.upload(file=modelFile)