Skip to content
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

Add default value for info argument of ClassDescription #3017

Merged
merged 5 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace rerun.datatypes;
/// Color and label will be used to annotate entities/keypoints which reference the id.
/// The id refers either to a class or key-point id
table AnnotationInfo (
"attr.python.aliases": "Tuple[int, str], Tuple[int, str, datatypes.ColorLike]",
"attr.python.aliases": "int, Tuple[int, str], Tuple[int, str, datatypes.ColorLike]",
"attr.rust.derive": "Default, Eq, PartialEq",
order: 500
) {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_types/source_hash.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

def classdescription_init(
self: ClassDescription,
info: AnnotationInfoLike,
info: AnnotationInfoLike = 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still strikes me as a bit of a footgun, but it matches the pre-existing behavior.

Copy link
Member Author

@emilk emilk Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna remove it in a follow-up-PR, but keep it here to not break API further in the 0.8.1 patch release

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to break it in the future, why not break it now? Is there a meaningful difference between breaking it in 0.8 and breaking it in 0.9?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more that I want to do the least intrusive change for 0.8.1.

If we require info to be explicit, should we also make it explicit for log_points? Why require explicitness in one but not the other?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

*,
keypoint_annotations: Sequence[AnnotationInfoLike] = [],
keypoint_connections: Sequence[KeypointPairLike] = [],
) -> None:
Expand Down Expand Up @@ -89,6 +90,8 @@ def classdescription_info_converter(

if isinstance(data, AnnotationInfo):
return data
elif isinstance(data, int):
return AnnotationInfo(id=data)
else:
return AnnotationInfo(*data)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/python/roundtrips/annotation_context/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main() -> None:
[
(1, "hello"),
rrd.ClassDescription(
(2, "world", [3, 4, 5]),
info=(2, "world", [3, 4, 5]),
keypoint_annotations=[(17, "head"), (42, "shoulders")],
keypoint_connections=[(1, 2), (3, 4)],
),
Expand Down