Skip to content

[X-0] Add field definitions #1745

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

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion libs/labelbox/src/labelbox/schema/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def validate_labeling_parameter_overrides(


class Project(DbObject, Updateable, Deletable):
""" A Project is a container that includes a labeling frontend, an ontology,
"""A Project is a container that includes a labeling frontend, an ontology,
datasets and labels.

Attributes:
Expand All @@ -96,6 +96,8 @@ class Project(DbObject, Updateable, Deletable):
queue_mode (string)
auto_audit_number_of_labels (int)
auto_audit_percentage (float)
is_benchmark_enabled (bool)
is_consensus_enabled (bool)

created_by (Relationship): `ToOne` relationship to User
organization (Relationship): `ToOne` relationship to Organization
Expand Down Expand Up @@ -123,6 +125,8 @@ class Project(DbObject, Updateable, Deletable):
data_row_count = Field.Int("data_row_count")
model_setup_complete: Field = Field.Boolean("model_setup_complete")
upload_type: Field = Field.Enum(UploadType, "upload_type")
is_benchmark_enabled = Field.Boolean("is_benchmark_enabled")
is_consensus_enabled = Field.Boolean("is_consensus_enabled")

# Relationships
created_by = Relationship.ToOne("User", False, "created_by")
Expand Down
10 changes: 4 additions & 6 deletions libs/labelbox/tests/integration/test_legacy_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ def test_project_dataset(client, rand_gen):

def test_project_auto_audit_parameters(client, rand_gen):
with pytest.raises(
ValueError,
match=
"quality_mode must be set instead of auto_audit_percentage or auto_audit_number_of_labels."
ValueError,
match="quality_modes must be set instead of auto_audit_percentage or auto_audit_number_of_labels.",
):
client.create_project(name=rand_gen(str), auto_audit_percentage=0.5)

with pytest.raises(
ValueError,
match=
"quality_mode must be set instead of auto_audit_percentage or auto_audit_number_of_labels."
ValueError,
match="quality_modes must be set instead of auto_audit_percentage or auto_audit_number_of_labels.",
):
client.create_project(name=rand_gen(str), auto_audit_number_of_labels=2)

Expand Down
16 changes: 12 additions & 4 deletions libs/labelbox/tests/unit/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
@pytest.fixture
def project_entity():
return Project(
MagicMock(), {
MagicMock(),
{
"id": "test",
"name": "test",
"createdAt": "2021-06-01T00:00:00.000Z",
Expand All @@ -24,7 +25,10 @@ def project_entity():
"setupComplete": "2021-06-01T00:00:00.000Z",
"modelSetupComplete": None,
"uploadType": "Auto",
})
"isBenchmarkEnabled": False,
"isConsensusEnabled": False,
},
)


@pytest.mark.parametrize(
Expand All @@ -39,7 +43,8 @@ def test_project_editor_task_type(api_editor_task_type,
expected_editor_task_type, project_entity):
client = MagicMock()
project = Project(
client, {
client,
{
"id": "test",
"name": "test",
"createdAt": "2021-06-01T00:00:00.000Z",
Expand All @@ -55,7 +60,10 @@ def test_project_editor_task_type(api_editor_task_type,
"setupComplete": "2021-06-01T00:00:00.000Z",
"modelSetupComplete": None,
"uploadType": "Auto",
})
"isBenchmarkEnabled": False,
"isConsensusEnabled": False,
},
)

assert project.editor_task_type == expected_editor_task_type

Expand Down
Loading