-
Notifications
You must be signed in to change notification settings - Fork 68
[PLT-1154] Vb/refactor project inputs plt 1154 #1844
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f26397c
Add project validation input
1f4a377
Use _CoreProjectInput in all create_project methods, create_model_eva…
8a36b7b
Added media_type to test projects
1ada7be
Removed queue_mode
cd5567f
Update rdoc
6c16f43
Remove auto_audit inputs
e1b7f66
Remove unnecessary test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
from typing import Optional, Set | ||
|
||
from pydantic import BaseModel, ConfigDict, Field, model_validator | ||
from typing_extensions import Annotated | ||
|
||
from labelbox.schema.media_type import MediaType | ||
from labelbox.schema.ontology_kind import EditorTaskType | ||
from labelbox.schema.quality_mode import ( | ||
BENCHMARK_AUTO_AUDIT_NUMBER_OF_LABELS, | ||
BENCHMARK_AUTO_AUDIT_PERCENTAGE, | ||
CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS, | ||
CONSENSUS_AUTO_AUDIT_PERCENTAGE, | ||
QualityMode, | ||
) | ||
from labelbox.schema.queue_mode import QueueMode | ||
|
||
PositiveInt = Annotated[int, Field(gt=0)] | ||
|
||
|
||
class _CoreProjectInput(BaseModel): | ||
name: str | ||
description: Optional[str] = None | ||
media_type: MediaType | ||
queue_mode: QueueMode = Field(default=QueueMode.Batch, frozen=True) | ||
auto_audit_percentage: Optional[float] = None | ||
auto_audit_number_of_labels: Optional[int] = None | ||
quality_modes: Optional[Set[QualityMode]] = Field( | ||
default={QualityMode.Benchmark, QualityMode.Consensus}, exclude=True | ||
) | ||
is_benchmark_enabled: Optional[bool] = None | ||
is_consensus_enabled: Optional[bool] = None | ||
dataset_name_or_id: Optional[str] = None | ||
append_to_existing_dataset: Optional[bool] = None | ||
data_row_count: Optional[PositiveInt] = None | ||
editor_task_type: Optional[EditorTaskType] = None | ||
|
||
model_config = ConfigDict(extra="forbid") | ||
|
||
@model_validator(mode="after") | ||
def validate_fields(self): | ||
if ( | ||
self.auto_audit_percentage is not None | ||
or self.auto_audit_number_of_labels is not None | ||
): | ||
raise ValueError( | ||
"quality_modes must be set instead of auto_audit_percentage or auto_audit_number_of_labels." | ||
) | ||
|
||
if not self.name.strip(): | ||
raise ValueError("project name must be a valid string.") | ||
|
||
if self.quality_modes == { | ||
QualityMode.Benchmark, | ||
QualityMode.Consensus, | ||
}: | ||
self._set_quality_mode_attributes( | ||
CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS, | ||
CONSENSUS_AUTO_AUDIT_PERCENTAGE, | ||
is_benchmark_enabled=True, | ||
is_consensus_enabled=True, | ||
) | ||
elif self.quality_modes == {QualityMode.Benchmark}: | ||
self._set_quality_mode_attributes( | ||
BENCHMARK_AUTO_AUDIT_NUMBER_OF_LABELS, | ||
BENCHMARK_AUTO_AUDIT_PERCENTAGE, | ||
is_benchmark_enabled=True, | ||
) | ||
elif self.quality_modes == {QualityMode.Consensus}: | ||
self._set_quality_mode_attributes( | ||
number_of_labels=CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS, | ||
percentage=CONSENSUS_AUTO_AUDIT_PERCENTAGE, | ||
is_consensus_enabled=True, | ||
) | ||
|
||
return self | ||
|
||
def _set_quality_mode_attributes( | ||
self, | ||
number_of_labels, | ||
percentage, | ||
is_benchmark_enabled=False, | ||
is_consensus_enabled=False, | ||
): | ||
self.auto_audit_number_of_labels = number_of_labels | ||
self.auto_audit_percentage = percentage | ||
self.is_benchmark_enabled = is_benchmark_enabled | ||
self.is_consensus_enabled = is_consensus_enabled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
needed to support json serializaiton