-
Notifications
You must be signed in to change notification settings - Fork 68
[MODEL-1448] Upsert label feedback method #1684
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 7 commits
8d5b97c
1fd1d57
2b9c0b6
3dd32d4
2c2d070
55c710b
1d49d35
a859280
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 |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
from labelbox.schema.slice import CatalogSlice, ModelSlice | ||
from labelbox.schema.task import Task | ||
from labelbox.schema.user import User | ||
from labelbox.schema.label_score import LabelScore | ||
from labelbox.schema.ontology_kind import (OntologyKind, EditorTaskTypeMapper, | ||
EditorTaskType) | ||
|
||
|
@@ -2197,3 +2198,53 @@ def get_embedding_by_name(self, name: str) -> Embedding: | |
return e | ||
raise labelbox.exceptions.ResourceNotFoundError(Embedding, | ||
dict(name=name)) | ||
|
||
def upsert_label_feedback( | ||
self, label_id: str, feedback: str, | ||
scores: Dict[str, float]) -> List[LabelScore]: | ||
""" | ||
Submits the label feedback which is a free-form text and numeric | ||
label scores. | ||
|
||
Args: | ||
label_id: Target label ID | ||
feedback: Free text comment regarding the label | ||
scores: A dict of scores, the key is a score name and the value is | ||
the score value | ||
|
||
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. extra whitespace |
||
Returns: | ||
A list of LabelScore instances | ||
""" | ||
mutation_str = """ | ||
mutation UpsertAutoQaLabelFeedbackPyApi( | ||
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.
can you elaborate?
will add a usage example now 👍 |
||
$labelId: ID! | ||
$feedback: String! | ||
$scores: Json! | ||
) { | ||
upsertAutoQaLabelFeedback( | ||
input: { | ||
labelId: $labelId, | ||
feedback: $feedback, | ||
scores: $scores | ||
} | ||
) { | ||
id | ||
scores { | ||
id | ||
name | ||
score | ||
} | ||
} | ||
} | ||
""" | ||
res = self.execute(mutation_str, { | ||
"labelId": label_id, | ||
"feedback": feedback, | ||
"scores": scores | ||
}) | ||
scores_raw = res["upsertAutoQaLabelFeedback"]["scores"] | ||
|
||
return [ | ||
labelbox.LabelScore(name=x['name'], score=x['score']) | ||
for x in scores_raw | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from labelbox import pydantic_compat | ||
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. Since this is a new package / class we also need to make sure it will appear in readthedocs by adding a new .rst in docs/labelbox/ file and updating docs/labelbox/index.rst |
||
|
||
|
||
class LabelScore(pydantic_compat.BaseModel): | ||
""" | ||
A label score. | ||
|
||
Attributes: | ||
name (str) | ||
score (float) | ||
|
||
""" | ||
|
||
name: str | ||
score: float |
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.
extra whitespace