-
Notifications
You must be signed in to change notification settings - Fork 68
[QQC-2474] Expose quality mode through SDK create_project method #1224
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
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 |
|---|---|---|
|
|
@@ -31,6 +31,8 @@ | |
| from labelbox.schema.model_run import ModelRun | ||
| from labelbox.schema.ontology import Ontology, Tool, Classification, FeatureSchema | ||
| from labelbox.schema.organization import Organization | ||
| from labelbox.schema.quality_mode import QualityMode, BENCHMARK_AUTO_AUDIT_NUMBER_OF_LABELS, \ | ||
| BENCHMARK_AUTO_AUDIT_PERCENTAGE, CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS, CONSENSUS_AUTO_AUDIT_PERCENTAGE | ||
| from labelbox.schema.user import User | ||
| from labelbox.schema.project import Project | ||
| from labelbox.schema.role import Role | ||
|
|
@@ -636,16 +638,33 @@ def create_project(self, **kwargs) -> Project: | |
| description (str): A short summary for the project | ||
| media_type (MediaType): The type of assets that this project will accept | ||
| queue_mode (Optional[QueueMode]): The queue mode to use | ||
| auto_audit_percentage (Optional[float]): The percentage of data rows that will require more than 1 label | ||
| auto_audit_number_of_labels (Optional[float]): Number of labels required for data rows selected for multiple labeling (auto_audit_percentage) | ||
| quality_mode (Optional[QualityMode]): The quality mode to use (e.g. Benchmark, Consensus). Defaults to | ||
| Benchmark | ||
| Returns: | ||
| A new Project object. | ||
| Raises: | ||
| InvalidAttributeError: If the Project type does not contain | ||
| any of the attribute names given in kwargs. | ||
| """ | ||
| media_type = kwargs.get("media_type") | ||
|
|
||
| auto_audit_percentage = kwargs.get("auto_audit_percentage") | ||
|
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. if these attributes are removed from the model, why are we dealing with them here?
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 is here to help present a more readable message that can inform users how to migrate to the new usage model |
||
| auto_audit_number_of_labels = kwargs.get("auto_audit_number_of_labels") | ||
| if auto_audit_percentage is not None or auto_audit_number_of_labels is not None: | ||
| raise ValueError( | ||
| "quality_mode must be set instead of auto_audit_percentage or auto_audit_number_of_labels." | ||
| ) | ||
|
|
||
| queue_mode = kwargs.get("queue_mode") | ||
| if queue_mode is QueueMode.Dataset: | ||
| raise ValueError( | ||
| "Dataset queue mode is deprecated. Please prefer Batch queue mode." | ||
| ) | ||
| elif queue_mode is QueueMode.Batch: | ||
| logger.warning( | ||
| "Passing a queue mode of batch is redundant and will soon no longer be supported." | ||
| ) | ||
|
|
||
| media_type = kwargs.get("media_type") | ||
| if media_type: | ||
| if MediaType.is_supported(media_type): | ||
| media_type = media_type.value | ||
|
|
@@ -658,20 +677,25 @@ def create_project(self, **kwargs) -> Project: | |
| "Creating a project without specifying media_type" | ||
| " through this method will soon no longer be supported.") | ||
|
|
||
| if not queue_mode: | ||
| logger.warning( | ||
| "Default createProject behavior will soon be adjusted to prefer " | ||
| "batch projects. Pass in `queue_mode` parameter explicitly to opt-out for the " | ||
| "time being.") | ||
| elif queue_mode == QueueMode.Dataset: | ||
| logger.warning( | ||
| "QueueMode.Dataset will eventually be deprecated, and is no longer " | ||
| "recommended for new projects. Prefer QueueMode.Batch instead.") | ||
| quality_mode = kwargs.get("quality_mode") | ||
|
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. Looks like dupe lines, since we do the same line 684-..
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. These aren't duplicate lines; one exists to inform the user that a default has been selected, and the other exists to translate the given quality_mode to something our backend can interpret |
||
| if not quality_mode: | ||
| logger.info("Defaulting quality mode to Benchmark.") | ||
|
|
||
| data = kwargs | ||
| data.pop("quality_mode", None) | ||
| if quality_mode is None or quality_mode is QualityMode.Benchmark: | ||
| data[ | ||
| "auto_audit_number_of_labels"] = BENCHMARK_AUTO_AUDIT_NUMBER_OF_LABELS | ||
| data["auto_audit_percentage"] = BENCHMARK_AUTO_AUDIT_PERCENTAGE | ||
| else: | ||
| data[ | ||
| "auto_audit_number_of_labels"] = CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS | ||
| data["auto_audit_percentage"] = CONSENSUS_AUTO_AUDIT_PERCENTAGE | ||
|
|
||
| return self._create(Entity.Project, { | ||
| **kwargs, | ||
| **data, | ||
| **({ | ||
| 'media_type': media_type | ||
| "media_type": media_type | ||
| } if media_type else {}) | ||
| }) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class QualityMode(str, Enum): | ||
| Benchmark = "BENCHMARK" | ||
| Consensus = "CONSENSUS" | ||
|
|
||
|
|
||
| BENCHMARK_AUTO_AUDIT_NUMBER_OF_LABELS = 1 | ||
| BENCHMARK_AUTO_AUDIT_PERCENTAGE = 1 | ||
| CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS = 3 | ||
| CONSENSUS_AUTO_AUDIT_PERCENTAGE = 0 |
Uh oh!
There was an error while loading. Please reload this page.
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.
what happens to existing projects where these attributes are set and, say, we do smth like
client.get_project(). I suppose it would work but the attributes will be missing? From the client point of view, is there any migration needs to happen, i.e. if auto_audit_percentage and auto_audit_number_of_labels => set quality mode etcvThere 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.
Also if the quality mode default to Benchmark, shouldn't we set it here?
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.
auto_audit_percentageandauto_audit_number_of_labelsare still in the Project model but have no meaning anymore - it has been replaced with equivalents at the batch level (specified during batch creation). The migration has already been performed on the backend, this change simply removes the old obsolete data from the client model