Fix/Use relative paths in annotation project exports #67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses an issue where annotation project exports included absolute paths to recordings instead of paths relative to a common base directory. Absolute paths are undesirable as they reduce portability and may leak personal folder structures.
Root Cause
The problem was traced to the
whombat.routes.annotation_project.download
function, which handles the export of annotation projects in AEOF format. Although the conversion function accepts an optionalaudio_dir
parameter to compute relative paths, this argument was not being utilized.Solution
Because recordings within a single annotation project may originate from different datasets—each with its own root directory—it wasn’t feasible to simply make paths relative to their individual dataset roots. Furthermore, the same recording might appear in multiple datasets with different root paths, complicating the decision further.
To resolve this, I implemented a new
annotation_project.get_base_dir
function, which computes the first common parent directory across all dataset root directories involved in the project. This common base directory is then used to generate relative paths for all recordings in the export.This approach allows users to copy or share the annotation project folder (or any subsection of it) while maintaining a consistent internal structure. Importing such a project elsewhere should work without modification, improving portability and usability.
Additional Changes
base_dir
.get_base_dir
with multiple datasets.base_dir
.