Skip to content

Commit

Permalink
Fix SA2.0 usage in managers.library_datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Oct 19, 2023
1 parent 328d4d0 commit 04193c7
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/galaxy/managers/library_datasets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Manager and Serializer for library datasets."""
import logging

from sqlalchemy import select

from galaxy import (
model,
util,
Expand All @@ -13,6 +15,10 @@
)
from galaxy.managers import datasets
from galaxy.managers.context import ProvidesUserContext
from galaxy.model import (
LibraryDataset,
LibraryFolder,
)
from galaxy.model.base import transaction
from galaxy.structured_app import MinimalManagerApp
from galaxy.util import validation
Expand Down Expand Up @@ -41,11 +47,7 @@ def get(self, trans, decoded_library_dataset_id, check_accessible=True):
:rtype: galaxy.model.LibraryDataset
"""
try:
ld = (
trans.sa_session.query(trans.app.model.LibraryDataset)
.filter(trans.app.model.LibraryDataset.table.c.id == decoded_library_dataset_id)
.one()
)
ld = get_library_dataset(trans.sa_session, decoded_library_dataset_id)
except Exception as e:
raise InternalServerError(f"Error loading from the database.{util.unicodify(e)}")
ld = self.secure(trans, ld, check_accessible)
Expand Down Expand Up @@ -276,6 +278,11 @@ def _build_path(self, trans, folder):
else:
# We add the current folder and traverse up one folder.
path_to_root.append((f"F{trans.security.encode_id(folder.id)}", folder.name))
upper_folder = trans.sa_session.query(trans.app.model.LibraryFolder).get(folder.parent_id)
upper_folder = trans.sa_session.get(LibraryFolder, folder.parent_id)
path_to_root.extend(self._build_path(trans, upper_folder))
return path_to_root


def get_library_dataset(session, library_dataset_id):
stmt = select(LibraryDataset).where(LibraryDataset.id == library_dataset_id)
return session.scalars(stmt).one()

0 comments on commit 04193c7

Please sign in to comment.