예제 #1
0
def test_save_updated_existing_task_with_existing_name(
        meta: MetadataRepository, project: Project):
    project = meta.create_project(project)
    task = Task("Task")
    task.project = project
    task = meta.create_task(task)

    task2 = Task("Task2")
    task2.project = project
    task2 = meta.create_task(task2)

    task.name = "Task2"
    with pytest.raises(ExistingTaskError):
        meta.save_task(task)
예제 #2
0
def test_update_task_with_models(meta: MetadataRepository, project: Project,
                                 task: Task, model: Model):
    task.project = meta.create_project(project)
    task = meta.create_task(task)
    assert task is not None

    id = task.id

    model.task = task
    model = meta.create_model(model)
    task.add_model(model)

    task = update_object_fields(task,
                                excepted_fields=['id', 'models', 'project_id'])
    model = update_object_fields(model,
                                 excepted_fields=[
                                     'id', 'wrapper', 'artifact',
                                     'output_meta', 'input_meta',
                                     'requirements', 'transformer', 'task_id'
                                 ])
    updated_task = meta.update_task(task)

    assert id == task.id
    assert updated_task is task
    assert task == meta.get_task_by_id(task.id)
    assert len(task.models) == 1

    assert model.id in task.models
    assert model == meta.get_model_by_id(model.id)
    assert meta.get_model_by_id(model.id).name == 'Test Model2'
    assert task.has_meta_repo
예제 #3
0
def test_update_task_is_reference(meta: MetadataRepository, project: Project,
                                  model: Model):
    task_entity = Task("Test Task")
    task_entity.project = meta.create_project(project)
    task = meta.create_task(task_entity)
    assert task is not None

    id = task.id

    model.task_id = task.id
    model = meta.create_model(model)

    task.name = "Test Task 2"
    task.add_model(model)
    task = meta.update_task(task)

    assert id == task.id
    assert "Test Task 2" == task.name
    assert model == task.models.get(model.id)

    task.name = "KEK"
    actual_task = meta.get_task_by_id(task.id)
    assert_objects_equal_except_fields(task,
                                       actual_task,
                                       excepted_fields=['name'])
예제 #4
0
def test_update_model_source_is_changed(meta: MetadataRepository,
                                        project: Project, task: Task,
                                        model: Model):
    task.project = meta.create_project(project)
    task = meta.create_task(task)
    assert task is not None

    model.task_id = task.id
    saved_model = meta.create_model(model)
    assert saved_model is not None

    id = saved_model.id

    saved_model = update_object_fields(model,
                                       excepted_fields=[
                                           'id', 'wrapper', 'artifact',
                                           'output_meta', 'input_meta',
                                           'requirements', 'transformer',
                                           'task_id'
                                       ])
    saved_model = meta.update_model(saved_model)

    assert id == saved_model.id
    assert model == meta.get_model_by_id(saved_model.id)
    assert model is saved_model
예제 #5
0
def test_get_task_by_name(meta: MetadataRepository, project: Project,
                          task: Task):
    project = meta.create_project(project)
    task.project = project
    task_new = meta.create_task(task)
    assert task_new is not None
    assert task_new == meta.get_task_by_name(project, task.name)
    assert task.has_meta_repo
예제 #6
0
def test_update_not_existing_task(meta: MetadataRepository, project: Project,
                                  task: Task):
    project = meta.create_project(project)
    assert project is not None

    task.project = project
    with pytest.raises(NonExistingTaskError):
        meta.update_task(task)
예제 #7
0
def test_delete_task(meta: MetadataRepository, project: Project, task: Task):
    task.project = meta.create_project(project)
    task = meta.create_task(task)
    assert task is not None

    meta.delete_task(task)
    assert meta.get_task_by_id(task.id) is None
    assert not task.has_meta_repo
    assert task.id is None
예제 #8
0
def test_get_models(meta: MetadataRepository, project: Project, task: Task,
                    model: Model):
    task.project = meta.create_project(project)
    created_task = meta.create_task(task)
    model.task = created_task
    created_model = meta.create_model(model)

    actual_models = meta.get_models(created_task)
    assert actual_models == [created_model]
예제 #9
0
def test_save_not_existing_task(meta: MetadataRepository, project: Project):
    project = meta.create_project(project)
    task = Task("Task")
    task.project = project

    saved_task = meta.save_task(task)
    assert saved_task.name == task.name
    assert saved_task.project_id == task.project_id
    assert task.name == meta.get_task_by_id(saved_task.id).name
    assert task.has_meta_repo
예제 #10
0
def test_update_not_existing_model(meta: MetadataRepository, project: Project,
                                   task: Task, model: Model):
    task.project = meta.create_project(project)
    task = meta.create_task(task)
    assert task is not None

    model.task_id = task.id

    with pytest.raises(NonExistingModelError):
        meta.update_model(model)
예제 #11
0
def test_create_model(meta: MetadataRepository, project: Project, task: Task,
                      model: Model):
    task.project = meta.create_project(project)
    task = meta.create_task(task)
    assert task is not None

    model.task_id = task.id
    model = meta.create_model(model)
    assert model is not None
    assert model.has_meta_repo
예제 #12
0
def test_create_model_source_is_changed(meta: MetadataRepository,
                                        project: Project, task: Task,
                                        model: Model):
    task.project = meta.create_project(project)
    task = meta.create_task(task)
    assert task is not None

    model.task_id = task.id
    saved_model = meta.create_model(model)
    assert saved_model is model
예제 #13
0
def test_save_task_is_reference(meta: MetadataRepository, project: Project):
    project = meta.create_project(project)
    task = Task("Task")
    task.project = project
    saved_task = meta.save_task(task)

    saved_task.name = "KEK"
    actual_task = meta.get_task_by_id(saved_task.id)
    assert_objects_equal_except_fields(saved_task,
                                       actual_task,
                                       excepted_fields=['name'])
예제 #14
0
def test_save_updated_existing_task(meta: MetadataRepository,
                                    project: Project):
    project = meta.create_project(project)
    task = Task("Task")
    task.project = project
    task = meta.create_task(task)

    task = update_object_fields(task,
                                excepted_fields=['id', 'models', 'project_id'])

    saved_task = meta.save_task(task)
    assert saved_task == task
    assert task == meta.get_task_by_id(saved_task.id)
예제 #15
0
def test_save_existing_model(meta: MetadataRepository, project: Project,
                             task: Task, model: Model):
    project = meta.create_project(project)
    task.project = project
    task = meta.create_task(task)

    model.task_id = task.id
    model = meta.create_model(model)

    saved_model = meta.save_model(model)
    assert saved_model.id == model.id
    assert saved_model.task_id == model.task_id
    assert model == meta.get_model_by_id(saved_model.id)
예제 #16
0
파일: test_base.py 프로젝트: zyfra/ebonite
def test_pipeline_buildable(metadata_repo, pipeline):
    proj = Project('proj')
    task = Task('Test Task')
    proj = metadata_repo.create_project(proj)
    task.project = proj
    task = metadata_repo.create_task(task)

    pipeline.task = task
    pipeline = metadata_repo.create_pipeline(pipeline)
    buildable = PipelineBuildable(pipeline, server_type=FlaskServer.type)
    assert buildable.get_provider().get_python_version(
    ) == platform.python_version()
    assert buildable.task.name == 'Test Task'
    assert buildable.pipeline == pipeline
예제 #17
0
def test_create_existing_model(meta: MetadataRepository, project: Project,
                               task: Task, model: Model, model2: Model):
    task.project = meta.create_project(project)
    task = meta.create_task(task)
    assert task is not None

    model.task_id = task.id
    model = meta.create_model(model)
    assert model is not None

    model2.task_id = task.id
    model2.name = model.name
    with pytest.raises(ExistingModelError):
        meta.create_model(model2)
예제 #18
0
def test_get_or_create_task_exists(meta: MetadataRepository, project: Project,
                                   task: Task):
    task.project = meta.create_project(project)
    expected_task = meta.create_task(task)

    actual_task = meta.get_or_create_task(project.name, expected_task.name)
    assert actual_task is not None
    assert expected_task == actual_task
    assert id(expected_task) != id(actual_task)

    project = meta.get_project_by_name(project.name)
    assert expected_task in project.tasks.values()

    assert expected_task.project_id == actual_task.project_id
    assert actual_task.has_meta_repo
예제 #19
0
def test_save_model_is_reference(meta: MetadataRepository, project: Project,
                                 task: Task, model: Model):
    project = meta.create_project(project)
    task.project = project
    task = meta.create_task(task)

    model.task_id = task.id

    saved_model = meta.save_model(model)

    saved_model.name = "KEK"
    actual_model = meta.get_model_by_id(saved_model.id)
    assert_objects_equal_except_fields(saved_model,
                                       actual_model,
                                       excepted_fields=['name'])
예제 #20
0
def test_save_updated_existing_model_with_existing_name(
        meta: MetadataRepository, project: Project, task: Task, model: Model,
        model2: Model):
    project = meta.create_project(project)
    task.project = project
    task = meta.create_task(task)

    model.task_id = task.id
    model = meta.create_model(model)

    model2.task_id = task.id
    model2 = meta.create_model(model2)

    model.name = model2.name
    with pytest.raises(ExistingModelError):
        meta.save_model(model)
예제 #21
0
def test_inner_objects_binded(meta: MetadataRepository, project: Project,
                              task: Task, model: Model):
    task.project = meta.create_project(project)
    meta.create_task(task)

    model.task_id = task.id
    model = meta.create_model(model)

    new_project = meta.get_project_by_name(project.name)
    assert new_project.id is not None
    assert new_project.has_meta_repo
    new_task = new_project.tasks(task.name)
    assert new_task.id is not None
    assert new_task.has_meta_repo
    new_model = new_task.models(model.name)
    assert new_model.id is not None
    assert new_model.has_meta_repo
예제 #22
0
파일: test_base.py 프로젝트: zyfra/ebonite
def test_multimodel_buildable(metadata_repo):
    # Dunno why, but it only worked w/o fixtures
    proj = Project('proj')
    task = Task('Test Task')
    mdl = Model.create(lambda data: data, 'input', 'test_model')

    proj = metadata_repo.create_project(proj)
    task.project = proj
    task = metadata_repo.create_task(task)
    mdl.task = task
    mdl = metadata_repo.create_model(mdl)

    with pytest.raises(ValueError):
        MultiModelBuildable([], server_type=FlaskServer.type)
    assert mdl.has_meta_repo
    mm_buildable = MultiModelBuildable([mdl], server_type=FlaskServer.type)
    assert mm_buildable.task.name == 'Test Task'
    assert mm_buildable.get_provider().get_python_version(
    ) == platform.python_version()
    assert len(mm_buildable.models) == 1
예제 #23
0
def test_save_updated_existing_model(meta: MetadataRepository,
                                     project: Project, task: Task,
                                     model: Model):
    project = meta.create_project(project)
    task.project = project
    task = meta.create_task(task)

    model.task_id = task.id
    model = meta.create_model(model)

    model = update_object_fields(model,
                                 excepted_fields=[
                                     'id', 'wrapper', 'artifact',
                                     'output_meta', 'input_meta',
                                     'requirements', 'transformer', 'task_id'
                                 ])

    saved_model = meta.save_model(model)
    assert saved_model == model
    assert model == meta.get_model_by_id(saved_model.id)
예제 #24
0
def test_create_model_is_reference(meta: MetadataRepository, project: Project,
                                   task: Task, model: Model):
    task.project = meta.create_project(project)
    task = meta.create_task(task)
    assert task is not None

    model.task_id = task.id
    model = meta.create_model(model)
    assert model is not None

    model.name = "KEK"
    actual_model = meta.get_model_by_id(model.id)
    assert_objects_equal_except_fields(model,
                                       actual_model,
                                       excepted_fields=['name'])

    model.task_id = None
    actual_model = meta.get_model_by_id(model.id)
    assert_objects_equal_except_fields(model,
                                       actual_model,
                                       excepted_fields=['name', 'task_id'])
예제 #25
0
def test_update_project_with_tasks(meta: MetadataRepository, project: Project,
                                   task: Task):
    project = meta.create_project(project)

    task.project = project
    task = meta.create_task(task)
    project.add_task(task)

    project = update_object_fields(project, excepted_fields=['id', 'tasks'])
    task = update_object_fields(task,
                                excepted_fields=['id', 'models', 'project_id'])

    updated_project = meta.update_project(project)

    assert updated_project is project
    assert project.has_meta_repo
    assert "Test project2" == updated_project.name
    assert project == meta.get_project_by_id(project.id)
    assert len(updated_project.tasks) == 1
    assert task.id in updated_project.tasks
    assert task == updated_project.tasks.get(task.id)
예제 #26
0
def test_update_model(meta: MetadataRepository, project: Project, task: Task,
                      model: Model):
    task.project = meta.create_project(project)
    task = meta.create_task(task)
    assert task is not None

    model.task_id = task.id
    model = meta.create_model(model)
    assert model is not None

    id = model.id

    model = update_object_fields(model,
                                 excepted_fields=[
                                     'id', 'wrapper', 'artifact',
                                     'requirements', 'wrapper_meta', 'task_id',
                                     'wrapper_obj', 'params'
                                 ])
    model = meta.update_model(model)

    assert id == model.id
    assert model == meta.get_model_by_id(model.id)
    assert model.has_meta_repo
예제 #27
0
def test_update_task_source_is_changed(meta: MetadataRepository,
                                       project: Project, task: Task,
                                       model: Model):
    task.project = meta.create_project(project)

    saved_task = meta.create_task(task)
    assert saved_task is task

    id = saved_task.id

    model.task = saved_task
    model = meta.create_model(model)

    saved_task = update_object_fields(
        saved_task, excepted_fields=['id', 'models', 'project_id'])

    saved_task.add_model(model)
    saved_task = meta.update_task(saved_task)

    assert id == saved_task.id
    assert saved_task == meta.get_task_by_id(saved_task.id)
    assert model == saved_task.models.get(model.id)

    assert task is saved_task
예제 #28
0
def test_get_tasks(meta: MetadataRepository, project: Project, task: Task):
    created_project = meta.create_project(project)
    task.project = created_project
    created_task = meta.create_task(task)

    assert meta.get_tasks(created_project) == [created_task]
예제 #29
0
def project_task(project):
    task = Task("Test Task")
    task.project = project
    return task
예제 #30
0
def test_create_task_source_is_not_changed(meta: MetadataRepository,
                                           project: Project, task: Task):
    task.project = meta.create_project(project)
    new_task = meta.create_task(task)

    assert new_task is task