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')
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')
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
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))
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()
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())
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))
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()
def create_run(self, run): api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration)) response = api.jobs_add_one(run.user, run.job, run='true')
def validate_token(self): api = dkube_client.DkubeApi(dkube_client.ApiClient(configuration)) response = api.tokeninfo() return response.to_dict()['data']
#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)