From c0d765b1a78b2689bc632685c17db5eb010e77a4 Mon Sep 17 00:00:00 2001 From: Ash Berlin-Taylor Date: Tue, 29 Oct 2024 12:13:13 +0000 Subject: [PATCH] fix some tests [skip ci] --- airflow/api_connexion/schemas/dag_schema.py | 1 - .../core_api/openapi/v1-generated.yaml | 4 --- .../api_fastapi/core_api/serializers/dags.py | 1 - airflow/cli/commands/dag_command.py | 1 - airflow/models/dag.py | 2 +- .../ui/openapi-gen/requests/schemas.gen.ts | 5 --- airflow/ui/openapi-gen/requests/types.gen.ts | 1 - .../endpoints/test_dag_endpoint.py | 32 ------------------- .../api_connexion/schemas/test_dag_schema.py | 5 --- .../core_api/routes/public/test_dags.py | 1 - tests/serialization/test_pydantic_models.py | 5 +-- 11 files changed, 4 insertions(+), 54 deletions(-) diff --git a/airflow/api_connexion/schemas/dag_schema.py b/airflow/api_connexion/schemas/dag_schema.py index 4fb1dd6ae4b39..f22812abd1114 100644 --- a/airflow/api_connexion/schemas/dag_schema.py +++ b/airflow/api_connexion/schemas/dag_schema.py @@ -56,7 +56,6 @@ class Meta: last_parsed_time = auto_field(dump_only=True) last_pickled = auto_field(dump_only=True) last_expired = auto_field(dump_only=True) - pickle_id = auto_field(dump_only=True) default_view = auto_field(dump_only=True) fileloc = auto_field(dump_only=True) file_token = fields.Method("get_token", dump_only=True) diff --git a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml index 136d6a4ed0271..e4a432b0c5be8 100644 --- a/airflow/api_fastapi/core_api/openapi/v1-generated.yaml +++ b/airflow/api_fastapi/core_api/openapi/v1-generated.yaml @@ -1797,9 +1797,6 @@ components: - type: boolean - type: 'null' title: Is Paused Upon Creation - orientation: - type: string - title: Orientation params: anyOf: - type: object @@ -1869,7 +1866,6 @@ components: - start_date - end_date - is_paused_upon_creation - - orientation - params - render_template_as_native_obj - template_search_path diff --git a/airflow/api_fastapi/core_api/serializers/dags.py b/airflow/api_fastapi/core_api/serializers/dags.py index c6294324c7e67..6e2c3933e176f 100644 --- a/airflow/api_fastapi/core_api/serializers/dags.py +++ b/airflow/api_fastapi/core_api/serializers/dags.py @@ -116,7 +116,6 @@ class DAGDetailsResponse(DAGResponse): start_date: datetime | None end_date: datetime | None is_paused_upon_creation: bool | None - orientation: str params: abc.MutableMapping | None render_template_as_native_obj: bool template_search_path: Iterable[str] | None diff --git a/airflow/cli/commands/dag_command.py b/airflow/cli/commands/dag_command.py index 89c5fd477f056..92d1825dc627e 100644 --- a/airflow/cli/commands/dag_command.py +++ b/airflow/cli/commands/dag_command.py @@ -227,7 +227,6 @@ def _get_dagbag_dag_details(dag: DAG) -> dict: "last_parsed_time": None, "last_pickled": None, "last_expired": None, - "pickle_id": dag.pickle_id, "default_view": dag.default_view, "fileloc": dag.fileloc, "file_token": None, diff --git a/airflow/models/dag.py b/airflow/models/dag.py index b9620e5220237..851d2a5129346 100644 --- a/airflow/models/dag.py +++ b/airflow/models/dag.py @@ -314,7 +314,7 @@ def _convert_max_consecutive_failed_dag_runs(val: int) -> int: @functools.total_ordering -@attrs.define(hash=False, repr=False, eq=False) +@attrs.define(hash=False, repr=False, eq=False, slots=False) class DAG(TaskSDKDag, LoggingMixin): """ A dag (directed acyclic graph) is a collection of tasks with directional dependencies. diff --git a/airflow/ui/openapi-gen/requests/schemas.gen.ts b/airflow/ui/openapi-gen/requests/schemas.gen.ts index 4bbf448ca8eec..076531d3a585a 100644 --- a/airflow/ui/openapi-gen/requests/schemas.gen.ts +++ b/airflow/ui/openapi-gen/requests/schemas.gen.ts @@ -517,10 +517,6 @@ export const $DAGDetailsResponse = { ], title: "Is Paused Upon Creation", }, - orientation: { - type: "string", - title: "Orientation", - }, params: { anyOf: [ { @@ -619,7 +615,6 @@ export const $DAGDetailsResponse = { "start_date", "end_date", "is_paused_upon_creation", - "orientation", "params", "render_template_as_native_obj", "template_search_path", diff --git a/airflow/ui/openapi-gen/requests/types.gen.ts b/airflow/ui/openapi-gen/requests/types.gen.ts index e3df16ea82980..b189eb52fc7a6 100644 --- a/airflow/ui/openapi-gen/requests/types.gen.ts +++ b/airflow/ui/openapi-gen/requests/types.gen.ts @@ -95,7 +95,6 @@ export type DAGDetailsResponse = { start_date: string | null; end_date: string | null; is_paused_upon_creation: boolean | null; - orientation: string; params: { [key: string]: unknown; } | null; diff --git a/tests/api_connexion/endpoints/test_dag_endpoint.py b/tests/api_connexion/endpoints/test_dag_endpoint.py index ecb0052a8a03b..5249944ea113b 100644 --- a/tests/api_connexion/endpoints/test_dag_endpoint.py +++ b/tests/api_connexion/endpoints/test_dag_endpoint.py @@ -190,7 +190,6 @@ def test_should_respond_200(self): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, } == response.json @conf_vars({("webserver", "secret_key"): "mysecret"}) @@ -230,7 +229,6 @@ def test_should_respond_200_with_schedule_none(self, session): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, } == response.json def test_should_respond_404(self): @@ -331,7 +329,6 @@ def test_should_respond_200(self, url_safe_serializer): "value": 1, } }, - "pickle_id": None, "render_template_as_native_obj": False, "timetable_summary": "2 2 * * *", "start_date": "2020-06-15T00:00:00+00:00", @@ -393,7 +390,6 @@ def test_should_respond_200_with_asset_expression(self, url_safe_serializer): "value": 1, } }, - "pickle_id": None, "render_template_as_native_obj": False, "timetable_summary": "2 2 * * *", "start_date": "2020-06-15T00:00:00+00:00", @@ -443,7 +439,6 @@ def test_should_response_200_with_doc_md_none(self, url_safe_serializer): "orientation": "LR", "owners": [], "params": {}, - "pickle_id": None, "render_template_as_native_obj": False, "timetable_summary": "2 2 * * *", "start_date": "2020-06-15T00:00:00+00:00", @@ -493,7 +488,6 @@ def test_should_response_200_for_null_start_date(self, url_safe_serializer): "orientation": "LR", "owners": [], "params": {}, - "pickle_id": None, "render_template_as_native_obj": False, "timetable_summary": "2 2 * * *", "start_date": None, @@ -552,7 +546,6 @@ def test_should_respond_200_serialized(self, url_safe_serializer): "value": 1, } }, - "pickle_id": None, "render_template_as_native_obj": False, "timetable_summary": "2 2 * * *", "start_date": "2020-06-15T00:00:00+00:00", @@ -612,7 +605,6 @@ def test_should_respond_200_serialized(self, url_safe_serializer): "value": 1, } }, - "pickle_id": None, "render_template_as_native_obj": False, "timetable_summary": "2 2 * * *", "start_date": "2020-06-15T00:00:00+00:00", @@ -712,7 +704,6 @@ def test_should_respond_200(self, session, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, { "dag_id": "TEST_DAG_2", @@ -739,7 +730,6 @@ def test_should_respond_200(self, session, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, ], "total_entries": 2, @@ -778,7 +768,6 @@ def test_only_active_true_returns_active_dags(self, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, } ], "total_entries": 1, @@ -818,7 +807,6 @@ def test_only_active_false_returns_all_dags(self, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, { "dag_id": "TEST_DAG_DELETED_1", @@ -845,7 +833,6 @@ def test_only_active_false_returns_all_dags(self, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, ], "total_entries": 2, @@ -1001,7 +988,6 @@ def test_paused_true_returns_paused_dags(self, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, } ], "total_entries": 1, @@ -1040,7 +1026,6 @@ def test_paused_false_returns_unpaused_dags(self, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, } ], "total_entries": 1, @@ -1079,7 +1064,6 @@ def test_paused_none_returns_all_dags(self, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, { "dag_id": "TEST_DAG_UNPAUSED_1", @@ -1106,7 +1090,6 @@ def test_paused_none_returns_all_dags(self, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, ], "total_entries": 2, @@ -1195,7 +1178,6 @@ def test_should_respond_200_on_patch_is_paused(self, url_safe_serializer, sessio "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, } assert response.json == expected_response _check_last_log( @@ -1293,7 +1275,6 @@ def test_should_respond_200_with_update_mask(self, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, } assert response.json == expected_response @@ -1387,7 +1368,6 @@ def test_should_respond_200_on_patch_is_paused(self, session, url_safe_serialize "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, { "dag_id": "TEST_DAG_2", @@ -1414,7 +1394,6 @@ def test_should_respond_200_on_patch_is_paused(self, session, url_safe_serialize "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, ], "total_entries": 2, @@ -1466,7 +1445,6 @@ def test_should_respond_200_on_patch_is_paused_using_update_mask(self, session, "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, { "dag_id": "TEST_DAG_2", @@ -1493,7 +1471,6 @@ def test_should_respond_200_on_patch_is_paused_using_update_mask(self, session, "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, ], "total_entries": 2, @@ -1585,7 +1562,6 @@ def test_only_active_true_returns_active_dags(self, url_safe_serializer, session "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, } ], "total_entries": 1, @@ -1633,7 +1609,6 @@ def test_only_active_false_returns_all_dags(self, url_safe_serializer, session): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, { "dag_id": "TEST_DAG_DELETED_1", @@ -1660,7 +1635,6 @@ def test_only_active_false_returns_all_dags(self, url_safe_serializer, session): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, ], "total_entries": 2, @@ -1858,7 +1832,6 @@ def test_should_respond_200_and_pause_dags(self, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, { "dag_id": "TEST_DAG_2", @@ -1885,7 +1858,6 @@ def test_should_respond_200_and_pause_dags(self, url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, ], "total_entries": 2, @@ -1933,7 +1905,6 @@ def test_should_respond_200_and_pause_dag_pattern(self, session, url_safe_serial "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, { "dag_id": "TEST_DAG_10", @@ -1960,7 +1931,6 @@ def test_should_respond_200_and_pause_dag_pattern(self, session, url_safe_serial "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, ], "total_entries": 2, @@ -2010,7 +1980,6 @@ def test_should_respond_200_and_reverse_ordering(self, session, url_safe_seriali "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, { "dag_id": "TEST_DAG_1", @@ -2037,7 +2006,6 @@ def test_should_respond_200_and_reverse_ordering(self, session, url_safe_seriali "last_parsed_time": None, "timetable_description": None, "has_import_errors": False, - "pickle_id": None, }, ], "total_entries": 2, diff --git a/tests/api_connexion/schemas/test_dag_schema.py b/tests/api_connexion/schemas/test_dag_schema.py index 1576f9cf3d6ee..4a6829a5c8312 100644 --- a/tests/api_connexion/schemas/test_dag_schema.py +++ b/tests/api_connexion/schemas/test_dag_schema.py @@ -72,7 +72,6 @@ def test_serialize_test_dag_schema(url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": None, - "pickle_id": None, } == serialized_dag @@ -108,7 +107,6 @@ def test_serialize_test_dag_collection_schema(url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": None, - "pickle_id": None, }, { "dag_id": "test_dag_id_b", @@ -135,7 +133,6 @@ def test_serialize_test_dag_collection_schema(url_safe_serializer): "last_parsed_time": None, "timetable_description": None, "has_import_errors": None, - "pickle_id": None, }, ], "total_entries": 2, @@ -190,7 +187,6 @@ def test_serialize_test_dag_detail_schema(url_safe_serializer): "timezone": UTC_JSON_REPR, "max_active_runs": 16, "max_consecutive_failed_dag_runs": 0, - "pickle_id": None, "end_date": None, "is_paused_upon_creation": None, "render_template_as_native_obj": False, @@ -254,7 +250,6 @@ def test_serialize_test_dag_with_asset_schedule_detail_schema(url_safe_serialize "timezone": UTC_JSON_REPR, "max_active_runs": 16, "max_consecutive_failed_dag_runs": 0, - "pickle_id": None, "end_date": None, "is_paused_upon_creation": None, "render_template_as_native_obj": False, diff --git a/tests/api_fastapi/core_api/routes/public/test_dags.py b/tests/api_fastapi/core_api/routes/public/test_dags.py index 72f4f70179f35..0e9b7a4085830 100644 --- a/tests/api_fastapi/core_api/routes/public/test_dags.py +++ b/tests/api_fastapi/core_api/routes/public/test_dags.py @@ -320,7 +320,6 @@ def test_dag_details( "next_dagrun_create_after": None, "next_dagrun_data_interval_end": None, "next_dagrun_data_interval_start": None, - "orientation": "LR", "owners": ["airflow"], "params": { "foo": { diff --git a/tests/serialization/test_pydantic_models.py b/tests/serialization/test_pydantic_models.py index aac83ec28da8f..7bfc7eda32af4 100644 --- a/tests/serialization/test_pydantic_models.py +++ b/tests/serialization/test_pydantic_models.py @@ -81,11 +81,10 @@ def test_serializing_pydantic_task_instance(session, create_task_instance): def test_deserialize_ti_mapped_op_reserialized_with_refresh_from_task(session, dag_maker): op_class_dict_expected = { "_needs_expansion": True, - "_task_type": "_PythonDecoratedOperator", + "task_type": "_PythonDecoratedOperator", "downstream_task_ids": [], "start_from_trigger": False, "start_trigger_args": None, - "_operator_name": "@task", "ui_fgcolor": "#000", "ui_color": "#ffefeb", "template_fields": ["templates_dict", "op_args", "op_kwargs"], @@ -128,6 +127,8 @@ def target(val=None): assert desered.task.__class__ == MappedOperator assert desered.task.operator_class == op_class_dict_expected + assert desered.task.task_type == "_PythonDecoratedOperator" + assert desered.task.operator_name == "@task" desered.refresh_from_task(deser_task)