Skip to content

Commit

Permalink
Fix select([foo]) SA2.0 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Jun 16, 2023
1 parent c60f72b commit 65f5416
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/galaxy/jobs/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __init__(

def setup_query(self):
subq = (
select([self.grab_this.id])
select(self.grab_this.id)
.where(
and_(
self.grab_this.table.c.handler.in_(self.self_handler_tags),
Expand Down Expand Up @@ -817,7 +817,7 @@ def get_user_job_count(self, user_id):
rval = self.user_job_count.get(user_id, 0)
if not self.app.config.cache_user_job_count:
result = self.sa_session.execute(
select([func.count(model.Job.table.c.id)]).where(
select(func.count(model.Job.table.c.id)).where(
and_(
model.Job.table.c.state.in_(
(model.Job.states.QUEUED, model.Job.states.RUNNING, model.Job.states.RESUBMITTED)
Expand All @@ -836,7 +836,7 @@ def __cache_user_job_count(self):
if self.user_job_count is None and self.app.config.cache_user_job_count:
self.user_job_count = {}
query = self.sa_session.execute(
select([model.Job.table.c.user_id, func.count(model.Job.table.c.user_id)])
select(model.Job.table.c.user_id, func.count(model.Job.table.c.user_id))
.where(
and_(
model.Job.table.c.state.in_(
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/managers/hdas.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def __init__(self, hda_manager: HDAManager, dataset_manager: datasets.DatasetMan

def get_discarded_summary(self, user: model.User) -> CleanableItemsSummary:
stmt = (
select([func.sum(model.Dataset.total_size), func.count(model.HistoryDatasetAssociation.id)])
select(func.sum(model.Dataset.total_size), func.count(model.HistoryDatasetAssociation.id))
.select_from(model.HistoryDatasetAssociation)
.join(model.Dataset, model.HistoryDatasetAssociation.table.c.dataset_id == model.Dataset.id)
.join(model.History, model.HistoryDatasetAssociation.table.c.history_id == model.History.id)
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/managers/histories.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def __init__(self, history_manager: HistoryManager):
}

def get_discarded_summary(self, user: model.User) -> CleanableItemsSummary:
stmt = select([func.sum(model.History.disk_size), func.count(model.History.id)]).where(
stmt = select(func.sum(model.History.disk_size), func.count(model.History.id)).where(
model.History.user_id == user.id,
model.History.deleted == true(),
model.History.purged == false(),
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/managers/history_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def state_counts(self, history):
]
contents_subquery = self._union_of_contents_query(history, filters=filters).subquery()
statement = (
sql.select([sql.column("state"), func.count("*")])
sql.select(sql.column("state"), func.count("*"))
.select_from(contents_subquery)
.group_by(sql.column("state"))
)
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/managers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def replace_dataset_ids(path, key, value):
c = aliased(model.HistoryDatasetAssociation)
d = aliased(model.JobParameter)
e = aliased(model.HistoryDatasetAssociationHistory)
stmt = select([model.HistoryDatasetAssociation.id]).where(
stmt = select(model.HistoryDatasetAssociation.id).where(
model.HistoryDatasetAssociation.id == e.history_dataset_association_id
)
name_condition = []
Expand Down Expand Up @@ -789,7 +789,7 @@ def summarize_jobs_to_dict(sa_session, jobs_source):
model.ImplicitCollectionJobsJobAssociation.table.join(model.Job)
)
statement = (
select([model.Job.state, func.count("*")])
select(model.Job.state, func.count("*"))
.select_from(join)
.where(model.ImplicitCollectionJobs.id == jobs_source.id)
.group_by(model.Job.state)
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/managers/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def get_user_total_unread_notification_count(self, user: User) -> int:
Only published and not expired notifications are accounted.
"""
stmt = (
select([func.count(UserNotificationAssociation.id)])
select(func.count(UserNotificationAssociation.id))
.select_from(UserNotificationAssociation)
.join(
Notification,
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3263,7 +3263,7 @@ def disk_size(cls):
distinct_datasets_alias = aliased(distinct_datasets.subquery(), name="datasets")
# then, bind as property of history using the cls.id
size_query = (
select([func.coalesce(func.sum(distinct_datasets_alias.c.dataset_size), 0)])
select(func.coalesce(func.sum(distinct_datasets_alias.c.dataset_size), 0))
.select_from(distinct_datasets_alias)
.where(distinct_datasets_alias.c.history_id == cls.id)
)
Expand Down Expand Up @@ -8544,7 +8544,7 @@ class WorkflowInvocationStep(Base, Dictifiable, Serializable):
viewonly=True,
)
order_index = column_property(
select([WorkflowStep.order_index]).where(WorkflowStep.id == workflow_step_id).scalar_subquery()
select(WorkflowStep.order_index).where(WorkflowStep.id == workflow_step_id).scalar_subquery()
)

subworkflow_invocation_id: column_property
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/reports/controllers/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ def per_user(self, trans, **kwd):
q_time.stop()
query1time = q_time.time_elapsed()

users = sa.select([model.User.table.c.email], from_obj=[model.User.table])
users = sa.select(model.User.table.c.email).select_from(model.User.table)

all_jobs_per_user = sa.select(
(
Expand Down

0 comments on commit 65f5416

Please sign in to comment.