|
| 1 | +from nucleus.prediction import BoxPrediction |
| 2 | +from nucleus.job import AsyncJob |
| 3 | +from nucleus import autocurate, DatasetItem |
| 4 | +import time |
| 5 | +from nucleus.constants import ERROR_PAYLOAD |
| 6 | +from tests.helpers import ( |
| 7 | + TEST_BOX_PREDICTIONS, |
| 8 | + TEST_DATASET_NAME, |
| 9 | + TEST_IMG_URLS, |
| 10 | + TEST_MODEL_NAME, |
| 11 | + TEST_MODEL_RUN, |
| 12 | + reference_id_from_url, |
| 13 | +) |
| 14 | +import pytest |
| 15 | + |
| 16 | + |
| 17 | +@pytest.fixture() |
| 18 | +def model_run(CLIENT): |
| 19 | + ds = CLIENT.create_dataset(TEST_DATASET_NAME) |
| 20 | + ds_items = [] |
| 21 | + for url in TEST_IMG_URLS[:2]: |
| 22 | + ds_items.append( |
| 23 | + DatasetItem( |
| 24 | + image_location=url, |
| 25 | + reference_id=reference_id_from_url(url), |
| 26 | + ) |
| 27 | + ) |
| 28 | + |
| 29 | + response = ds.append(ds_items) |
| 30 | + |
| 31 | + assert ERROR_PAYLOAD not in response.json() |
| 32 | + |
| 33 | + model = CLIENT.add_model( |
| 34 | + name=TEST_MODEL_NAME, reference_id="model_" + str(time.time()) |
| 35 | + ) |
| 36 | + |
| 37 | + run = model.create_run(name=TEST_MODEL_RUN, dataset=ds, predictions=[]) |
| 38 | + prediction = BoxPrediction(**TEST_BOX_PREDICTIONS[1]) |
| 39 | + run.predict(annotations=[prediction]) |
| 40 | + |
| 41 | + yield run |
| 42 | + |
| 43 | + response = CLIENT.delete_dataset(ds.id) |
| 44 | + assert response == {"message": "Beginning dataset deletion..."} |
| 45 | + response = CLIENT.delete_model(model.id) |
| 46 | + assert response == {} |
| 47 | + |
| 48 | + |
| 49 | +@pytest.mark.integration |
| 50 | +def test_autocurate_integration(model_run, CLIENT): |
| 51 | + job = autocurate.entropy( |
| 52 | + "Test Autocurate Integration", [model_run], CLIENT |
| 53 | + ) |
| 54 | + job.sleep_until_complete() |
| 55 | + assert job.job_last_known_status == "Completed" |
0 commit comments