From e7a0511f74dae4bd10fc70b4d48e738891a745b6 Mon Sep 17 00:00:00 2001 From: Kalyan R Date: Wed, 20 Nov 2024 23:55:32 +0530 Subject: [PATCH] remove `all()` for scalars (#44219) * remove all() for scalars * fix * fix --- airflow/api_fastapi/core_api/routes/public/assets.py | 4 ++-- airflow/api_fastapi/core_api/routes/public/backfills.py | 4 ++-- airflow/api_fastapi/core_api/routes/public/connections.py | 2 +- airflow/api_fastapi/core_api/routes/public/dag_warning.py | 2 +- airflow/api_fastapi/core_api/routes/public/dags.py | 2 +- airflow/api_fastapi/core_api/routes/public/event_logs.py | 2 +- airflow/api_fastapi/core_api/routes/public/import_error.py | 2 +- airflow/api_fastapi/core_api/routes/public/pools.py | 2 +- airflow/api_fastapi/core_api/routes/public/variables.py | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/airflow/api_fastapi/core_api/routes/public/assets.py b/airflow/api_fastapi/core_api/routes/public/assets.py index b3ee47c6b14ad..785f76c9662ba 100644 --- a/airflow/api_fastapi/core_api/routes/public/assets.py +++ b/airflow/api_fastapi/core_api/routes/public/assets.py @@ -106,7 +106,7 @@ def get_assets( assets_select.options( subqueryload(AssetModel.consuming_dags), subqueryload(AssetModel.producing_tasks) ) - ).all() + ) return AssetCollectionResponse( assets=[AssetResponse.model_validate(asset, from_attributes=True) for asset in assets], total_entries=total_entries, @@ -153,7 +153,7 @@ def get_asset_events( ) assets_event_select = assets_event_select.options(subqueryload(AssetEvent.created_dagruns)) - assets_events = session.scalars(assets_event_select).all() + assets_events = session.scalars(assets_event_select) return AssetEventCollectionResponse( asset_events=[ diff --git a/airflow/api_fastapi/core_api/routes/public/backfills.py b/airflow/api_fastapi/core_api/routes/public/backfills.py index 41e9314e9f95d..5eb265243c047 100644 --- a/airflow/api_fastapi/core_api/routes/public/backfills.py +++ b/airflow/api_fastapi/core_api/routes/public/backfills.py @@ -67,11 +67,11 @@ def list_backfills( limit=limit, session=session, ) - backfills = session.scalars(select_stmt).all() + backfills = session.scalars(select_stmt) return BackfillCollectionResponse( backfills=[BackfillResponse.model_validate(x, from_attributes=True) for x in backfills], - total_entries=len(backfills), + total_entries=total_entries, ) diff --git a/airflow/api_fastapi/core_api/routes/public/connections.py b/airflow/api_fastapi/core_api/routes/public/connections.py index 473d3edc4623b..22a23cdb65540 100644 --- a/airflow/api_fastapi/core_api/routes/public/connections.py +++ b/airflow/api_fastapi/core_api/routes/public/connections.py @@ -108,7 +108,7 @@ def get_connections( session=session, ) - connections = session.scalars(connection_select).all() + connections = session.scalars(connection_select) return ConnectionCollectionResponse( connections=[ diff --git a/airflow/api_fastapi/core_api/routes/public/dag_warning.py b/airflow/api_fastapi/core_api/routes/public/dag_warning.py index a0746b80ecb0e..2213df9bdc425 100644 --- a/airflow/api_fastapi/core_api/routes/public/dag_warning.py +++ b/airflow/api_fastapi/core_api/routes/public/dag_warning.py @@ -63,7 +63,7 @@ def list_dag_warnings( select(DagWarning), [warning_type, dag_id], order_by, offset, limit, session ) - dag_warnings = session.scalars(dag_warnings_select).all() + dag_warnings = session.scalars(dag_warnings_select) return DAGWarningCollectionResponse( dag_warnings=[ diff --git a/airflow/api_fastapi/core_api/routes/public/dags.py b/airflow/api_fastapi/core_api/routes/public/dags.py index 8ab1ae3798d66..e97ad24d832cc 100644 --- a/airflow/api_fastapi/core_api/routes/public/dags.py +++ b/airflow/api_fastapi/core_api/routes/public/dags.py @@ -90,7 +90,7 @@ def get_dags( session, ) - dags = session.scalars(dags_select).all() + dags = session.scalars(dags_select) return DAGCollectionResponse( dags=[DAGResponse.model_validate(dag, from_attributes=True) for dag in dags], diff --git a/airflow/api_fastapi/core_api/routes/public/event_logs.py b/airflow/api_fastapi/core_api/routes/public/event_logs.py index 1a0e7fad2f63f..6c1117bebbe36 100644 --- a/airflow/api_fastapi/core_api/routes/public/event_logs.py +++ b/airflow/api_fastapi/core_api/routes/public/event_logs.py @@ -132,7 +132,7 @@ def get_event_logs( limit, session, ) - event_logs = session.scalars(event_logs_select).all() + event_logs = session.scalars(event_logs_select) return EventLogCollectionResponse( event_logs=[ diff --git a/airflow/api_fastapi/core_api/routes/public/import_error.py b/airflow/api_fastapi/core_api/routes/public/import_error.py index 5312904fc7b35..abccdf163c2ee 100644 --- a/airflow/api_fastapi/core_api/routes/public/import_error.py +++ b/airflow/api_fastapi/core_api/routes/public/import_error.py @@ -96,7 +96,7 @@ def get_import_errors( limit, session, ) - import_errors = session.scalars(import_errors_select).all() + import_errors = session.scalars(import_errors_select) return ImportErrorCollectionResponse( import_errors=[ diff --git a/airflow/api_fastapi/core_api/routes/public/pools.py b/airflow/api_fastapi/core_api/routes/public/pools.py index 547ec5265851c..1e5cf47b1b248 100644 --- a/airflow/api_fastapi/core_api/routes/public/pools.py +++ b/airflow/api_fastapi/core_api/routes/public/pools.py @@ -103,7 +103,7 @@ def get_pools( session=session, ) - pools = session.scalars(pools_select).all() + pools = session.scalars(pools_select) return PoolCollectionResponse( pools=[PoolResponse.model_validate(pool, from_attributes=True) for pool in pools], diff --git a/airflow/api_fastapi/core_api/routes/public/variables.py b/airflow/api_fastapi/core_api/routes/public/variables.py index 9818e70db4419..6c9dccc5ea7ad 100644 --- a/airflow/api_fastapi/core_api/routes/public/variables.py +++ b/airflow/api_fastapi/core_api/routes/public/variables.py @@ -98,7 +98,7 @@ def get_variables( session=session, ) - variables = session.scalars(variable_select).all() + variables = session.scalars(variable_select) return VariableCollectionResponse( variables=[VariableResponse.model_validate(variable, from_attributes=True) for variable in variables],