コード例 #1
0
    def get_run(self, category, user, name, fields='*'):
        api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))
        response = api.jobs_get_collection_one(user, category, name)

        if fields == '*':
            return response.to_dict()
        elif fields == 'status':
            return response.to_dict()['data']['job']['parameters']['generated']['status']
        else:
            raise Exception('Unsupported fields parameter')
コード例 #2
0
    def get_repo(self, category, user, name, fields='*'):
        api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))
        response = api.datums_get_one_by_class(user, category, name)

        if fields == '*':
            return response.to_dict()
        elif fields == 'status':
            return response.to_dict()['data']['datum']['generated']['status']
        else:
            raise Exception('Unsupported fields parameter')
コード例 #3
0
def validate_token(token):
    configuration.api_key['Authorization'] = token

    api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))

    response = api.tokeninfo()
    claims = response['data']
    user = claims['user']
    role = claims['role']

    return user, role
コード例 #4
0
 def delete_repo(self, category, user, name):
     api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))
     response = api.datums_delete_by_class(user, category, list(name))
コード例 #5
0
 def list_repos(self, category, user, filters='*'):
     api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))
     response = api.datums_get_by_class(user, category, False)
     return response.to_dict()
コード例 #6
0
 def create_repo(self, repo):
     api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))
     response = api.datums_add_one(repo.user, repo.datum)
     print(response.to_dict())
コード例 #7
0
 def delete_run(self, category, user, name):
     api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))
     api.jobs_list_delete_by_class(user, category, list(name))
コード例 #8
0
 def list_runs(self, category, user, filters='*'):
     api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))
     response = api.jobs_get_by_class(user, category, False, all='true')
     pprint(response)
     return response.to_dict()
コード例 #9
0
 def create_run(self, run):
     api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))
     response = api.jobs_add_one(run.user, run.job, run='true')
コード例 #10
0
 def validate_token(self):
     api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))
     response = api.tokeninfo()
     return response.to_dict()['data']
コード例 #11
0
    #api.create_dataset(odataset)
    #api.create_preprocessing_run(preprocessing)

    #claims = api.validate_token()

    from dkube.sdk.internal import dkube_client
    from dkube_client.rest import ApiException

    from url_normalize import url_normalize

    # Configure API key authorization: d3apikey
    configuration = dkube_client.Configuration()
    configuration.api_key_prefix['Authorization'] = 'Bearer'

    dkubeURL = 'https://192.168.200.106:32222'
    token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6Ijc0YmNkZjBmZWJmNDRiOGRhZGQxZWIyOGM2MjhkYWYxIn0.eyJ1c2VybmFtZSI6Im9jIiwicm9sZSI6Im9wZXJhdG9yIiwiaWF0IjoxNTg3NzIxNTE4LCJpc3MiOiJES3ViZSJ9.OQmeuygUqH9qPSUm-SrqeyTdekMOH0E3XBeaCYLSmEh-oRXRL3XhEtLnHhXn6KPzXWkEuDo1W_FyrUEpXZsXXHP-Fjt1cF08IXmSxWIRRw9-dcAuPJxBzgmxyJWpTVlSiwN8HhfJNuTPk8sSUhzPLmBD4eEN3gGS3FP7_VdvXDOpgYW7__IkN7qpfkdz6H0mMeAcsazDbZ1ZwMoVkBq-Ad6UnQ-5FvfWYxVPPKD95QGmpGz7TpAmbYHMFWTWIgyxuQnw24W72wn1Un21C1P9HUTSIPLQHqO6sbhHaZVmWGdzcMN1wmGSWqJucKyQHUCntVyx0axDMDbXSnuwNuBWaQ'
    configuration.host = url_normalize(
        '{}/dkube/v2/controller'.format(dkubeURL))
    configuration.api_key['Authorization'] = token
    configuration.verify_ssl = False

    api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration))
    jdict = preprocessing.job.to_dict()
    jdict['parameters']['class'] = 'preprocessing'
    #jdict = {'version': None, 'name': 'data-0528', 'description': '', 'parameters': {'class': 'preprocessing', 'gpu_allocation': None, 'priority': None, 'training': None, 'notebook': None, 'inference': None, 'preprocessing': {'kind': 'preprocessing', 'executor': {'choice': 'custom', 'custom': {'image': {'path': 'docker.io/ocdr/dkube-datascience-tf-cpu:v1.13', 'username': None, 'password': None, 'runas': None}}}, 'datums': {'workspace': {'data': {'name': 'oc:mak1', 'version': None, 'mountpath': None}, 'script': 'sleep 30'}, 'models': None, 'datasets': [{'name': 'oc:mak1', 'version': None, 'mountpath': '/opt/dkube/input'}], 'outputs': [{'name': 'oc:mak2', 'version': None, 'mountpath': '/opt/dkube/output'}]}, 'tags': [], 'config': {'envs': None, 'file': {'name': None, 'body': None}}}, 'custom': None, 'run': {'template': None, 'group': 'default'}, 'generated': None}}
    #response = api.jobs_add_one('oc', jdict, run='true')
    response = api.jobs_get_collection_one('oc', 'preprocessing', 'data-3797')
    print(response.to_dict())
    uuid = response.to_dict()['data']['job']['parameters']['generated']['uuid']
    response = api.get_one_run_lineage('oc', 'preprocessing', uuid)