async def _create_and_save_dag(
        self, db, sync, sync_id, nodes, edges, current_user, uow
    ) -> schemas.SyncDag:
        """Create and save the DAG with nodes and edges."""
        sync_dag_create = SyncDagCreate(
            name=f"DAG for {sync.name}",
            sync_id=sync_id,
            nodes=nodes,
            edges=edges,
        )

        try:
            from airweave.core.logging import logger

            logger.info(
                f"Creating DAG for sync {sync.name} with {len(nodes)} nodes and {len(edges)} edges"
            )

            sync_dag = await crud.sync_dag.create_with_nodes_and_edges(
                db, obj_in=sync_dag_create, current_user=current_user, uow=uow
            )
            logger.info(f"Successfully created DAG with ID {sync_dag.id}")
            return schemas.SyncDag.model_validate(sync_dag, from_attributes=True)
        except Exception as e:
            from airweave.core.logging import logger

            logger.error(f"Error creating DAG: {e}")

            self._log_dag_errors(nodes, edges)
            raise
Create and save the DAG with nodes and edges.
backend/airweave/core/dag_service.py