-
Notifications
You must be signed in to change notification settings - Fork 68
[AL-4418] [AL-3976] Make dataset tests parallelizable #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
360c539
d068392
aff3da0
03263cb
71f481a
6177b59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| [pytest] | ||
| addopts = -s -vv -x --reruns 5 --reruns-delay 10 --durations=20 | ||
| addopts = -s -vv --reruns 5 --reruns-delay 10 --durations=20 | ||
| markers = | ||
| slow: marks tests as slow (deselect with '-m "not slow"') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,4 +13,5 @@ typeguard | |
| imagesize | ||
| pyproj | ||
| pygeotile | ||
| typing-extensions | ||
| typing-extensions | ||
| pytest-xdist | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,26 @@ | ||
| import pytest | ||
|
|
||
| from labelbox import Model | ||
| from labelbox.exceptions import ResourceNotFoundError | ||
|
|
||
|
|
||
| def test_model(client, configured_project, rand_gen): | ||
| before = list(client.get_models()) | ||
| for m in before: | ||
| # Get all | ||
| models = list(client.get_models()) | ||
| for m in models: | ||
| assert isinstance(m, Model) | ||
|
|
||
| # Create | ||
| ontology = configured_project.ontology() | ||
|
|
||
| data = {"name": rand_gen(str), "ontology_id": ontology.uid} | ||
| model = client.create_model(data["name"], data["ontology_id"]) | ||
| assert model.name == data["name"] | ||
|
|
||
| after = list(client.get_models()) | ||
| assert len(after) == len(before) + 1 | ||
| assert model in after | ||
|
|
||
| # Get one | ||
| model = client.get_model(model.uid) | ||
| assert model.name == data["name"] | ||
|
|
||
|
|
||
| def test_model_delete(client, model): | ||
| before = list(client.get_models()) | ||
|
|
||
| model = before[0] | ||
| # Delete | ||
| model.delete() | ||
|
|
||
| after = list(client.get_models()) | ||
|
|
||
| assert len(before) == len(after) + 1 | ||
| with pytest.raises(ResourceNotFoundError): | ||
| client.get_model(model.uid) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,27 +7,19 @@ | |
|
|
||
|
|
||
| def test_dataset(client, rand_gen): | ||
| before = list(client.get_datasets()) | ||
| for o in before: | ||
| assert isinstance(o, Dataset) | ||
|
|
||
| # confirm dataset can be created | ||
| name = rand_gen(str) | ||
| dataset = client.create_dataset(name=name) | ||
| assert dataset.name == name | ||
| assert dataset.created_by() == client.get_user() | ||
| assert dataset.organization() == client.get_organization() | ||
|
|
||
| after = list(client.get_datasets()) | ||
| assert len(after) == len(before) + 1 | ||
| assert dataset in after | ||
|
|
||
| # confirm get_one returns first dataset | ||
| get_one_dataset = client.get_datasets().get_one() | ||
| assert get_one_dataset.uid == after[0].uid | ||
|
|
||
| # confirm get_many(1) returns first dataset | ||
| get_many_datasets = client.get_datasets().get_many(1) | ||
| assert get_many_datasets[0].uid == after[0].uid | ||
| retrieved_dataset = client.get_dataset(dataset.uid) | ||
| assert retrieved_dataset.name == dataset.name | ||
| assert retrieved_dataset.uid == dataset.uid | ||
| assert retrieved_dataset.created_by() == dataset.created_by() | ||
| assert retrieved_dataset.organization() == dataset.organization() | ||
|
|
||
| dataset = client.get_dataset(dataset.uid) | ||
| assert dataset.name == name | ||
|
|
@@ -48,9 +40,6 @@ def test_dataset(client, rand_gen): | |
| assert dataset.description == description | ||
|
|
||
| dataset.delete() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to add a check for the deleted dataset here by querying for the dataset
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This already exists on line 44. |
||
| final = list(client.get_datasets()) | ||
| assert dataset not in final | ||
| assert set(final) == set(before) | ||
|
|
||
| with pytest.raises(ResourceNotFoundError): | ||
| dataset = client.get_dataset(dataset.uid) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from copy import copy | ||
|
|
||
|
|
||
| def test_get_one_and_many_dataset_order(client): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice work adding coverage for pagination!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I felt that part of the test_dataset was really testing pagination so I moved that here. |
||
| paginator = client.get_datasets() | ||
| # confirm get_one returns first dataset | ||
| all_datasets = list(paginator) | ||
| get_one_dataset = copy(paginator).get_one() | ||
| assert get_one_dataset.uid == all_datasets[0].uid | ||
|
|
||
| # confirm get_many(1) returns first dataset | ||
| get_many_datasets = copy(paginator).get_many(1) | ||
| assert get_many_datasets[0].uid == all_datasets[0].uid | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,5 +19,5 @@ def test_user_and_org_projects(project): | |
|
|
||
| assert project.created_by() == user | ||
| assert project.organization() == org | ||
| assert set(user.projects()) == user_projects.union({project}) | ||
| assert set(org.projects()) == org_projects.union({project}) | ||
| assert project in user_projects | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great catch! It has been intermittently failing recently on staging and with your change now should be fine! |
||
| assert project in org_projects | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how did it even work ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it timed out before this got evaluated.