Used in https://github.com/mhenc/airflow/blob/master/airflow/dag_processing/manager.py#L613

should be straighforward
dag_tags = set(dag.tags or {})
            orm_dag_tags = list(orm_dag.tags or [])
            for orm_tag in orm_dag_tags:
                if orm_tag.name not in dag_tags:
                    session.delete(orm_tag)
                    orm_dag.tags.remove(orm_tag)
            orm_tag_names = {t.name for t in orm_dag_tags}
            for dag_tag in dag_tags:
                if dag_tag not in orm_tag_names:
                    dag_tag_orm = DagTag(name=dag_tag, dag_id=dag.dag_id)
                    orm_dag.tags.append(dag_tag_orm)
                    session.add(dag_tag_orm)
            orm_dag_links = orm_dag.dag_owner_links or []
            for orm_dag_link in orm_dag_links:
                if orm_dag_link not in dag.owner_links:
                    session.delete(orm_dag_link)
            for owner_name, owner_link in dag.owner_links.items():
                dag_owner_orm = DagOwnerAttributes(dag_id=dag.dag_id, owner=owner_name, link=owner_link)
                session.add(dag_owner_orm)
        DagCode.bulk_sync_to_db(filelocs, session=session)
        from airflow.datasets import Dataset
        from airflow.models.dataset import (
            DagScheduleDatasetReference,
            DatasetModel,
            TaskOutletDatasetReference,
        )
        dag_references = collections.defaultdict(set)
        outlet_references = collections.defaultdict(set)
        
        outlet_datasets: dict[Dataset, None] = {}