Skip to content

Commit

Permalink
fix: add_tracks should return a list of tracks (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabebe authored Feb 28, 2024
1 parent 741babc commit 78ba963
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
8 changes: 5 additions & 3 deletions docs/usage/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ The first step in most AI audio workflows is to import existing assets for analy
!!! example

```pycon
>>> new_collection = nendo.library.add_tracks("/path/to/my/files/")
>>> type(new_collection)
<class 'nendo.schema.core.NendoCollection'>
>>> added_tracks = nendo.library.add_tracks("/path/to/my/files/")
>>> type(added_tracks)
<class 'list'>
>>> len(new_collection)
32
>>> type(added_tracks[0])
<class 'nendo.schema.core.NendoTrack'>
```

=== "Creating a collection"
Expand Down
7 changes: 3 additions & 4 deletions src/nendo/library/sqlalchemy_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,15 +1022,15 @@ def add_tracks(
user_id: Optional[Union[str, uuid.UUID]] = None,
copy_to_library: Optional[bool] = None,
skip_duplicate: bool = True,
) -> schema.NendoCollection:
) -> List[schema.NendoTrack]:
"""Scan the provided path and upsert the information into the library.
Args:
path (Union[str, DirectoryPath]): Path to the directory to be scanned
track_type (str, optional): Track type for the new tracks
user_id (UUID, optional): The ID of the user adding the track.
copy_to_library (bool): Copy and convert the data into the nendo Library?
skip_duplicate (bool): Skip adding duplicates?
skip_duplicate (bool): Skip adding duplicates.
Returns:
tracks (list[NendoTrack]): The tracks that were added to the Library
Expand All @@ -1047,14 +1047,13 @@ def add_tracks(
if AudioFileUtils().is_supported_filetype(file)
],
)
tracks = self._add_tracks_db(
return self._add_tracks_db(
file_paths=file_list,
track_type=track_type,
copy_to_library=copy_to_library,
skip_duplicate=skip_duplicate,
user_id=user_id,
)
return self.add_collection(name=path, track_ids=[t.id for t in tracks])

def add_track_relationship(
self,
Expand Down
4 changes: 2 additions & 2 deletions src/nendo/schema/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ def add_tracks(
user_id: Optional[Union[str, uuid.UUID]] = None,
copy_to_library: Optional[bool] = None,
skip_duplicate: bool = True,
) -> NendoCollection:
) -> List[NendoTrack]:
"""Scan the provided path and upsert the information into the library.
Args:
Expand All @@ -1295,7 +1295,7 @@ def add_tracks(
file checksum. Defaults to None.
Returns:
collection (NendoCollection): The collection of tracks that were added to the Library
List[NendoTrack]: List of tracks that were added to the library.
"""
raise NotImplementedError

Expand Down

0 comments on commit 78ba963

Please sign in to comment.