This method is used in DagFileProcessor.process_file - it may be easier to migrate all it's internal calls instead of the whole method.
import shutil
import sys
import textwrap
import zipfile
from copy import deepcopy
from datetime import datetime, timedelta, timezone
from tempfile import NamedTemporaryFile, mkdtemp
from typing import Iterator
from unittest import mock
from unittest.mock import patch
import pytest
import time_machine
from sqlalchemy import func
from sqlalchemy.exc import OperationalError
import airflow.example_dags
from airflow import models, settings
from airflow.exceptions import SerializationError
from airflow.models import DagBag, DagModel
from airflow.models.serialized_dag import SerializedDagModel
from airflow.serialization.serialized_objects import SerializedDAG
from airflow.utils.dates import timezone as tz
from airflow.utils.session import create_session
from airflow.www.security import ApplessAirflowSecurityManager
from tests import cluster_policies
from tests.models import TEST_DAGS_FOLDER
from tests.test_utils import db
from tests.test_utils.asserts import assert_queries_count
from tests.test_utils.config import conf_vars
example_dags_folder = pathlib.Path(airflow.example_dags.__path__[0])  
def db_clean_up():