From a362d8d9fe7679d05b02ce75f882f444eea2319b Mon Sep 17 00:00:00 2001 From: Lucas Gautheron Date: Wed, 8 Sep 2021 09:42:17 +0200 Subject: [PATCH] let --recordings accept paths to the recordings too --- ChildProject/projects.py | 8 ++++++++ tests/test_pipelines.py | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/ChildProject/projects.py b/ChildProject/projects.py index cec584e26..021243c39 100644 --- a/ChildProject/projects.py +++ b/ChildProject/projects.py @@ -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) diff --git a/tests/test_pipelines.py b/tests/test_pipelines.py index 384092e63..acd3c1e0d 100644 --- a/tests/test_pipelines.py +++ b/tests/test_pipelines.py @@ -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"]