Skip to content

Add functions to extract first frame labels from cliplabels#64

Merged
niksirbi merged 2 commits into
mainfrom
feat_extract_start_frame_label
Jul 22, 2026
Merged

Add functions to extract first frame labels from cliplabels#64
niksirbi merged 2 commits into
mainfrom
feat_extract_start_frame_label

Conversation

@sharmishtaa

Copy link
Copy Markdown
Collaborator

Adds two new functions to extract only the first frame's labels from cliplabels.json files:

  • extract_start_frames_label: processes local files
  • extract_start_frames_label_s3: processes files on S3 (requires boto3)

Both functions read *_cliplabels.json files and create corresponding *_startlabels.json files containing only labels for frame id=0.

Before submitting a pull request (PR), please read the contributing guide.

Please fill out as much of this template as you can, but if you have any problems or questions, just leave a comment and we will help out :)

Description

What is this PR

  • Bug fix
  • [X ] Addition of a new feature
  • Other

Why is this PR needed?

This PR addresses the first step in the issue #63 which is a script for copying benchmark data from the temporary location to the benchmark location.

What does this PR do?
This script adds a function forstripping the cliplabels file and creating a new file that only contains the first label of the frame which will be shared in the benchmark for the Test data.

References

#63

How has this PR been tested?

Please explain how any new code has been tested, and how you have ensured that no existing functionality has changed.

Is this a breaking change?

No

Does this PR require an update to the documentation?

If any features have changed, or have been added. Please explain how the
documentation has been updated.

Checklist:

  • [ X] The code has been tested locally
  • Tests have been added to cover all new functionality
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

@sharmishtaa

Copy link
Copy Markdown
Collaborator Author

I noticed that Matt had already generated startframe_labels.json but SWC and Allen had not, so we need to functionality to do this either locally or on s3. In general I will also add the script for copying data here, so will plan to update pyproject.toml with the boto installation. Just wanted to flag that in case you had other thoughts.

@sharmishtaa
sharmishtaa requested review from niksirbi and sfmig July 9, 2026 00:07
@niksirbi

niksirbi commented Jul 9, 2026

Copy link
Copy Markdown
Member

Thanks for the PR @sharmishtaa ! I will make sure to take a look at this next week when I'm back from FENS.

@niksirbi niksirbi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey @sharmishtaa, finally found the time to take a proper look at this and left comments inline.

I think the main thing that's still unclear in my head is what sort of workflow do we want for generating startlabels.json files. I can see at least three alternatives:

  1. Data contributors extract startlabels.json files themselves and include them at data submission stage. Then the files are already present at the scratch bucket. Your implementation is consistent with that workflow.
  2. Data contributors just submit clipabels.json files, and our upcoming script will auto-extract startlabels.json from them at the time of moving data from one bucket to the other.

The direction this PR will go depends on that key decision.

I personally have a slight preference towards the 2nd option, because I think it's more robust to have our script auto-extract that information, rather than have every data contributor pre-generate startlabels.json (essentially duplicating data that's already present in cliplabels.json).

Let me know what you think.

Note that tests are currently missing for the two new public functions, but let's first settle on the right workflow/interface before we worry about that.

Let's keep the conversation going here. I'm happy to take another look at this when you need me to.

Comment thread poseinterface/clips.py Outdated
Comment thread poseinterface/clips.py Outdated
Comment thread poseinterface/clips.py Outdated
Comment thread poseinterface/clips.py Outdated
Comment thread poseinterface/clips.py Outdated
Comment thread poseinterface/clips.py Outdated
Comment thread poseinterface/clips.py Outdated
Comment thread poseinterface/clips.py Outdated
Comment thread poseinterface/clips.py
Comment thread poseinterface/clips.py
@sharmishtaa

Copy link
Copy Markdown
Collaborator Author

Hey @sharmishtaa, finally found the time to take a proper look at this and left comments inline.

I think the main thing that's still unclear in my head is what sort of workflow do we want for generating startlabels.json files. I can see at least three alternatives:

  1. Data contributors extract startlabels.json files themselves and include them at data submission stage. Then the files are already present at the scratch bucket. Your implementation is consistent with that workflow.
  2. Data contributors just submit clipabels.json files, and our upcoming script will auto-extract startlabels.json from them at the time of moving data from one bucket to the other.

The direction this PR will go depends on that key decision.

I personally have a slight preference towards the 2nd option, because I think it's more robust to have our script auto-extract that information, rather than have every data contributor pre-generate startlabels.json (essentially duplicating data that's already present in cliplabels.json).

Let me know what you think.

Note that tests are currently missing for the two new public functions, but let's first settle on the right workflow/interface before we worry about that.

Let's keep the conversation going here. I'm happy to take another look at this when you need me to.

I don't think we can expect data contributors to extract the startframe themselves. But what I was unclear about was if we want to leave it as an option - for example Matt had generated his files already. But you bring up a good point about consistency and it will also be a good validation step to ensure that cliplabels.json conforms with what we expect before we copy it. So I'm good with option 2.

@sharmishtaa

Copy link
Copy Markdown
Collaborator Author

Will separate out the s3 utils and will take a look at the other comments later this week.

@sharmishtaa

Copy link
Copy Markdown
Collaborator Author

Hi @niksirbi - I made the changes to function names, outputs, error catching descriptions, docs, pyproject.toml and separated out the s3 utils. At the moment, I added utilities for just copying json files, but we will need one for generic copying of directories, which can be a separate ticket.

@niksirbi niksirbi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for updating the PR @Sharmisthaa!

I added a few commits on top for some finishing touches—fixed linting errors, made sure that typing and docstrings are consistent and added a few more tests.

I also got rid of the boto3 availablity check: that would be useful if boto3 was an optional extra dependency, but we can safely assume its availability since it's now a core dependency.

The only significant behaviour I added was to also validate fie suffixes for output_path/uri: basically, output paths (and URIs) are also validated (if provided) to ensure that they end with startlabels.json (as the schema stipulates).

The only remaining task is to resolve the merge conflicts by rebasing. I am happy to take care of that; just wanted to check in that you are fine with the changes I made (any of them can be easily undone) before I undertake the rebasing (which will alter the git history).

@sharmishtaa

Copy link
Copy Markdown
Collaborator Author

Looks good to me. Please go ahead!

Add extract_startlabels (local) and extract_startlabels_s3 (S3) to derive
*_startlabels.json files from *_cliplabels.json, plus a dedicated s3.py
module (parse_s3_uri, download/upload JSON helpers). Register the new public
functions in the docs API index, add boto3 as a dependency, and add unit
tests for the new functionality.
@niksirbi
niksirbi force-pushed the feat_extract_start_frame_label branch from 78dc661 to e59c1e8 Compare July 22, 2026 17:15
@niksirbi
niksirbi merged commit 7872789 into main Jul 22, 2026
25 checks passed
@niksirbi
niksirbi deleted the feat_extract_start_frame_label branch July 22, 2026 17:23
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