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

Joe/feat 806 #863

Merged
merged 1 commit into from
Jan 24, 2025
Merged

Joe/feat 806 #863

merged 1 commit into from
Jan 24, 2025

Conversation

JoeStrout
Copy link
Contributor

Adds clearing_bbox parameter to Annotation.write_in_bounds, and uses this in the PUT web API to replace only the annotations in the specified region.

Also shores up how resolution is handled — reading and writing now allow the caller to specify the resolution at which the line coordinates should be interpreted (converting to/from the underlying file resolution as needed).

layer = build_annotation_layer(path, mode="read")
response = []
for line in layer.read_in_bounds(index):
for line in layer.read_in_bounds(bbox, strict=True, annotation_resolution=resolution_vec):
Copy link
Member

Choose a reason for hiding this comment

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

Should we decouple the bbox specification resolution from the resolution we want the resulting annotations to be in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd say that's up to the users of the web API (your team in Ukraine, I guess). Most of the time I would expect them to be the same; it's also easier to avoid mistakes if you don't have to keep two different resolutions in mind. But if they have some reason to need them separate, we can easily do that.

@@ -65,8 +67,8 @@ async def add_multiple(
resolution: Annotated[tuple[float, float, float], Query()],
Copy link
Member

Choose a reason for hiding this comment

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

Same for the write -- should we allow the start and end coord to be given in resolutions that are not the same as the ones used for annotations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same answer. I don't have strong feelings about it, but slightly prefer to have only one resolution.

@@ -57,7 +58,9 @@ def __init__(self, line_id: int, start: Sequence[float], end: Sequence[float]):
:param start: A tuple of three floats representing the start coordinate (x, y, z).
:param end: A tuple of three floats representing the end coordinate (x, y, z).

Coordinates are in units defined by "dimensions" in the info file.
Copy link
Member

Choose a reason for hiding this comment

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

btw, is there a reason we're not using attrs here like we do in the rest of the codebase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just that I'm still not super familiar with it, or the reasons one might want to use it.

Copy link
Member

Choose a reason for hiding this comment

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

It's just a cleaner more modern way to use python that reduces boilerplate and comes with a lot of free gooddies

Copy link
Member

Choose a reason for hiding this comment

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

We are trying to use it for all classes except for the ones that inherent from pytorch.nn.module (pytorch does some incompatible black magic)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. I know you were eager to get this to your web team, so it's up to you whether you want to hold this until I can do that refactoring (probably tomorrow), or merge this as-is and I'll do another little PR to add attrs.

Copy link
Member

Choose a reason for hiding this comment

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

does the internal need to update here or is this an accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dangit. That's an accident again. To check my code against the pre-commit hooks I have to commit them multiple times, and when there are multiple files, the easiest way to do that is commit -a. And I forget that, even though I didn't touch internal, git sees it as changed (I guess because I was required, by another pre-commit hook, to switch internal to main). So, that must be how this keeps happening.

I will try to undo that part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh! Actually, no, in this case I do need to update internal as well (to track changes to the AnnotationLayer API). I'll make a separate PR for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/ZettaAI/internal/pull/67
Not sure whether/how to remove the change to internal in this case, or make it point at the right thing. But maybe it doesn't matter, since to get everything tidied up we will need to merge internal PR#67, and then pull that into main, and make another mini-PR on main to update internal, right?

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (e452f9d) to head (22228f5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #863   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          142       142           
  Lines         6041      6066   +25     
=========================================
+ Hits          6041      6066   +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JoeStrout JoeStrout force-pushed the joe/feat_806 branch 2 times, most recently from 4b341d7 to 6d79e8c Compare January 23, 2025 18:40
Re #806.

Add support for annotation_resolution on write methods.
Re #806.

AnnotationLayer.write_annotations now has an optional `clearing_bbox` parameter.
Update the web API to make use of this, so PUT now replaces lines within bounds.
Fixes #806.
@JoeStrout JoeStrout merged commit 68e5fd1 into main Jan 24, 2025
10 checks passed
@JoeStrout JoeStrout deleted the joe/feat_806 branch January 24, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants