-
Notifications
You must be signed in to change notification settings - Fork 68
[AL-2778][AL-2779] Add name field to annotations #614
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
Conversation
| annot, | ||
| (VideoClassificationAnnotation, VideoObjectAnnotation)): | ||
| video_annotations[annot.feature_schema_id].append(annot) | ||
| video_annotations[annot.name or annot.schema_id].append(annot) |
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.
I think it likely doesn't actually do anything to this line since we don't use video_annotations outside of the purpose of having the values(), but maybe we should make it so that it is annot.schema_id or annot.name instead of the reverse?
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.
yeah good idea
| @@ -1,3 +1,4 @@ | |||
| from typing import Optional | |||
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.
writing the comment here, but it looks like the test cases are failing as a result of these changes. they will likely need some updates
| res = super().dict(*args, **kwargs) | ||
| if 'name' in res and res['name'] is None: | ||
| res.pop('name') | ||
| if 'featureSchemaId' in res and res.featureSchemaId is None: |
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.
is there a reason we use res['name'] and res.featureSchemaId?
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.
ah forgot to change it
jtsodapop
left a comment
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.
LGTM, nit comments + i think some extra lines that don't need to be in there.
| @@ -1,3 +1,4 @@ | |||
| from tkinter import N | |||
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.
Suggestion maybe this was added via your editor? if so, let's drop
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.
yes
|
|
||
| video_annotations = defaultdict(list) | ||
| for annot in label.annotations: | ||
| # print(dict(annot)) |
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.
suggestion think this may be extra line we can cut out
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.
leftover
kkim-labelbox
left a comment
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.
Code LGTM other than one super minor nit. Could you add tests as well?
| @validator('name', pre=True, always=True) | ||
| def validate_name(cls, v, values): | ||
| if v is None and 'schema_id' not in values: | ||
| raise ValueError("Name is not set. Either set name or schema_id.") |
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.
Name and schema_id are not set. Either set name or schema_id
| feature_schema_id: Cuid) -> "NDRadioSubclass": | ||
| return cls(answer=NDFeature(schema_id=radio.answer.feature_schema_id), | ||
| return cls(answer=NDFeature(name=radio.answer.name, | ||
| schema_id=radio.answer.feature_schema_id), |
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.
Unnecessary newline? unless github messed up formatting?
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.
formatter did this 🤷
|
It might also be good to add updates to docstrings that talk about schema_ids being required for MAL:
|
kkim-labelbox
left a comment
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.
I had a couple nit comments around wording, and have a request for more test cases.
Could you also add tests for the serialization/deserialization logic, since a bulk of your change touches the annotation type conversion logic?
I see we have a suite of tests under tests/data/serialization/ndsjon that are calling NDJsonConverter.serialize/deserialize across different data types. It'd be great to add tests cases here, for when only name is present. I just want to make sure we're covering test cases for the changes being made, and these additional test cases will ensure that the serialization/deserialization logic are working properly. Thanks!
| @@ -1,5 +1,6 @@ | |||
| from collections import defaultdict | |||
| from typing import Any, Callable, Dict, List, Union, Optional | |||
| import warnings | |||
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.
Unnecessary import?
| Returns: | ||
| LabelList. useful for chaining these modifying functions | ||
| Warning: assign_feature_schema_ids is now obsolete, you can |
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.
Warning: assign_feature_schema_ids is now obsolete, you can
now use names directly without having to lookup schema_ids.
- Warning might be too "harsh". I'd just put "Note:"
- I'd add
you can now import annotations using names directly without having to lookup schema_ids
| Label. useful for chaining these modifying functions | ||
| Warning: assign_feature_schema_ids is now obsolete, you can | ||
| now use names directly without having to lookup schema_ids. |
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.
Same wording as above
| if self.name: | ||
| if self.name not in valid_feature_schemas_by_name: | ||
| raise ValueError( | ||
| f"name {self.name} is not valid for the provided project's ontology." |
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.
Let's make sure the error outputted to customers are all formatted and capitalized consistently.
Name {self.name} is not valid for the provided project's ontology
| if self.schemaId: | ||
| if self.schemaId not in valid_feature_schemas_by_id: | ||
| raise ValueError( | ||
| f"schema id {self.schemaId} is not valid for the provided project's ontology." |
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.
Capitalize Schema
| @@ -0,0 +1,20 @@ | |||
| [ | |||
| { | |||
| "answer": { "schemaId": "ckrb1sfl8099g0y91cxbd5ftb" }, | |||
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.
Could you use name here instead of schemaId for answer?
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.
sure
| }, | ||
| { | ||
| "answer": "a value", | ||
| "name": "classification b", |
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.
There are two classifications named classification b
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.
updating
# Conflicts: # labelbox/data/serialization/ndjson/label.py # labelbox/data/serialization/ndjson/objects.py
kkim-labelbox
left a comment
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.
Added one more tiny comment, but LGTM otherwise!
| Returns: | ||
| Label. useful for chaining these modifying functions | ||
| Warning: You can now import annotations using names directly without having to lookup schema_ids |
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.
Change this to Note: You can now import annotations using names directly without having to lookup schema_ids, and remove import warning?
Adds name field to annotation objects where feature_id required. Makes both fields optional and require one field to be present.