From fabf3e18bf2bcbdf00edcf71703c79a1ab7d0432 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Thu, 21 Nov 2024 18:21:44 +0000 Subject: [PATCH 1/3] Re-add profiling calls --- app/models.py | 4 +++- app/musicmuster.py | 8 ++++++++ app/playlistmodel.py | 7 +++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/models.py b/app/models.py index cedbc7e..38ffa88 100644 --- a/app/models.py +++ b/app/models.py @@ -8,6 +8,7 @@ import sys # PyQt imports # Third party imports +import line_profiler from sqlalchemy import ( bindparam, delete, @@ -563,8 +564,9 @@ class PlaylistRows(dbtables.PlaylistRowsTable): ) @staticmethod + @line_profiler.profile def update_plr_row_numbers( - session: Session, playlist_id: int, sqla_map: List[dict[str, int]] + session: Session, playlist_id: int, sqla_map: List[dict[str, int]], dummy_for_profiling=None ) -> None: """ Take a {plrid: row_number} dictionary and update the row numbers accordingly diff --git a/app/musicmuster.py b/app/musicmuster.py index ceec98d..32fbba5 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -44,6 +44,7 @@ from PyQt6.QtWidgets import ( ) # Third party imports +import line_profiler import pipeclient from pygame import mixer from sqlalchemy.exc import IntegrityError @@ -1068,7 +1069,14 @@ class Window(QMainWindow, Ui_MainWindow): else: webbrowser.get("browser").open_new_tab(url) +<<<<<<< HEAD def paste_rows(self) -> None: +||||||| parent of 6879950 (Re-add profiling calls) + def paste_rows(self, dummy_for_profiling=None) -> None: +======= + @line_profiler.profile + def paste_rows(self, dummy_for_profiling=None) -> None: +>>>>>>> 6879950 (Re-add profiling calls) """ Paste earlier cut rows. """ diff --git a/app/playlistmodel.py b/app/playlistmodel.py index f45c8fb..6719027 100644 --- a/app/playlistmodel.py +++ b/app/playlistmodel.py @@ -26,6 +26,7 @@ from PyQt6.QtGui import ( ) # Third party imports +import line_profiler import obswebsocket # type: ignore # import snoop # type: ignore @@ -736,7 +737,8 @@ class PlaylistModel(QAbstractTableModel): self.update_track_times() self.invalidate_rows(row_numbers) - def move_rows(self, from_rows: list[int], to_row_number: int) -> None: + @line_profiler.profile + def move_rows(self, from_rows: list[int], to_row_number: int, dummy_for_profiling=None) -> None: """ Move the playlist rows given to to_row and below. """ @@ -975,7 +977,8 @@ class PlaylistModel(QAbstractTableModel): # Update display self.invalidate_row(track_sequence.previous.row_number) - def refresh_data(self, session: db.session) -> None: + @line_profiler.profile + def refresh_data(self, session: db.session, dummy_for_profiling=None) -> None: """Populate self.playlist_rows with playlist data""" # We used to clear self.playlist_rows each time but that's From 0737c58dff8242b0e517576b3e0cddd4fc837bbb Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sat, 23 Nov 2024 07:27:49 +0000 Subject: [PATCH 2/3] Add indexes to PlaylistRowsTable --- app/dbtables.py | 4 ++-- app/musicmuster.py | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/dbtables.py b/app/dbtables.py index 48f367e..95945c6 100644 --- a/app/dbtables.py +++ b/app/dbtables.py @@ -90,11 +90,11 @@ class PlaylistRowsTable(Model): __tablename__ = "playlist_rows" id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True) - row_number: Mapped[int] + row_number: Mapped[int] = mapped_column(index=True) note: Mapped[str] = mapped_column( String(2048), index=False, default="", nullable=False ) - playlist_id: Mapped[int] = mapped_column(ForeignKey("playlists.id")) + playlist_id: Mapped[int] = mapped_column(ForeignKey("playlists.id"), index=True) playlist: Mapped[PlaylistsTable] = relationship(back_populates="rows") track_id: Mapped[Optional[int]] = mapped_column(ForeignKey("tracks.id")) track: Mapped["TracksTable"] = relationship( diff --git a/app/musicmuster.py b/app/musicmuster.py index 32fbba5..46a84a0 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -1069,14 +1069,8 @@ class Window(QMainWindow, Ui_MainWindow): else: webbrowser.get("browser").open_new_tab(url) -<<<<<<< HEAD - def paste_rows(self) -> None: -||||||| parent of 6879950 (Re-add profiling calls) - def paste_rows(self, dummy_for_profiling=None) -> None: -======= @line_profiler.profile def paste_rows(self, dummy_for_profiling=None) -> None: ->>>>>>> 6879950 (Re-add profiling calls) """ Paste earlier cut rows. """ From ac2e811ed6ab283b9ca6e4c0e56e5ecea6b84162 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sun, 24 Nov 2024 21:56:12 +0000 Subject: [PATCH 3/3] Remove all profiling calls --- app/models.py | 4 +--- app/musicmuster.py | 4 +--- app/playlistmodel.py | 7 ++----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/models.py b/app/models.py index 38ffa88..cedbc7e 100644 --- a/app/models.py +++ b/app/models.py @@ -8,7 +8,6 @@ import sys # PyQt imports # Third party imports -import line_profiler from sqlalchemy import ( bindparam, delete, @@ -564,9 +563,8 @@ class PlaylistRows(dbtables.PlaylistRowsTable): ) @staticmethod - @line_profiler.profile def update_plr_row_numbers( - session: Session, playlist_id: int, sqla_map: List[dict[str, int]], dummy_for_profiling=None + session: Session, playlist_id: int, sqla_map: List[dict[str, int]] ) -> None: """ Take a {plrid: row_number} dictionary and update the row numbers accordingly diff --git a/app/musicmuster.py b/app/musicmuster.py index 46a84a0..ceec98d 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -44,7 +44,6 @@ from PyQt6.QtWidgets import ( ) # Third party imports -import line_profiler import pipeclient from pygame import mixer from sqlalchemy.exc import IntegrityError @@ -1069,8 +1068,7 @@ class Window(QMainWindow, Ui_MainWindow): else: webbrowser.get("browser").open_new_tab(url) - @line_profiler.profile - def paste_rows(self, dummy_for_profiling=None) -> None: + def paste_rows(self) -> None: """ Paste earlier cut rows. """ diff --git a/app/playlistmodel.py b/app/playlistmodel.py index 6719027..f45c8fb 100644 --- a/app/playlistmodel.py +++ b/app/playlistmodel.py @@ -26,7 +26,6 @@ from PyQt6.QtGui import ( ) # Third party imports -import line_profiler import obswebsocket # type: ignore # import snoop # type: ignore @@ -737,8 +736,7 @@ class PlaylistModel(QAbstractTableModel): self.update_track_times() self.invalidate_rows(row_numbers) - @line_profiler.profile - def move_rows(self, from_rows: list[int], to_row_number: int, dummy_for_profiling=None) -> None: + def move_rows(self, from_rows: list[int], to_row_number: int) -> None: """ Move the playlist rows given to to_row and below. """ @@ -977,8 +975,7 @@ class PlaylistModel(QAbstractTableModel): # Update display self.invalidate_row(track_sequence.previous.row_number) - @line_profiler.profile - def refresh_data(self, session: db.session, dummy_for_profiling=None) -> None: + def refresh_data(self, session: db.session) -> None: """Populate self.playlist_rows with playlist data""" # We used to clear self.playlist_rows each time but that's