Example #1
0
def test_validate_index_does_not_exist():

    bad_examples = [(3, 4, 'template'), (3, 3, 'serve'), (3, -1, 'train')]
    good_examples = [(3, 0, 'template'), (3, 1, 'serve'), (3, 2, 'train')]

    for n, ind, command in bad_examples:
        with pytest.raises(
                IndexError,
                match=
                f"Index {ind} does not exist... Run `kaos {command} list` again"
        ):
            validate_index(n=n, ind=ind, command=command)

    for n, ind, command in good_examples:
        validate_index(n=n, ind=ind, command=command)
Example #2
0
 def get_endpoint_by_ind(ind):
     data = validate_cache(SERVE_CACHE, command='serve')
     loc = validate_index(len(data), ind, command='serve')
     return data[loc]['name']
Example #3
0
 def get_notebook_by_ind(ind):
     data = validate_cache(NOTEBOOK_CACHE, command='notebook')
     loc = validate_index(len(data), ind, command='notebook')
     return data[loc]['name']
Example #4
0
 def get_job_by_ind(ind):
     data = validate_cache(TRAIN_CACHE, command='train')
     loc = validate_index(len(data), ind, command='train')
     return data[loc]['job_id']
Example #5
0
 def get_template_name_by_ind(self, ind):
     templates = self.list()
     loc = validate_index(len(templates), ind, command='template')
     return templates[loc]["name"]
Example #6
0
 def get_workspace_by_ind(ind):
     data = validate_cache(WORKSPACE_CACHE, command='workspace')
     loc = validate_index(len(data), ind, command='workspace')
     return data[loc]['name']