Skip to content

Commit

Permalink
let --recordings accept paths to the recordings too
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgautheron committed Sep 8, 2021
1 parent 5b7bfb9 commit a362d8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ChildProject/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,14 @@ def get_converted_recording_filename(
def get_recordings_from_list(self, recordings: list):
_recordings = self.recordings.copy()

# if the user provided paths,
# transform those paths into recording_filename values
if all(map(os.path.exists, recordings)):
recordings = [
os.path.relpath(recording, os.path.join(self.path, self.RAW_RECORDINGS))
for recording in recordings
]

if recordings is not None:
_recordings = _recordings[
_recordings["recording_filename"].isin(recordings)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,13 @@ def test_whitelist():
caught_value_error = True

assert caught_value_error == True

recordings = project.get_recordings_from_list(
Pipeline.recordings_from_list(
[
"examples/valid_raw_data/recordings/raw/sound.wav",
"examples/valid_raw_data/recordings/raw/sound2.wav",
]
)
)
assert recordings["recording_filename"].tolist() == ["sound.wav", "sound2.wav"]

0 comments on commit a362d8d

Please sign in to comment.