def insert_dataset(
        self, dataset: dataset_schema.Dataset
    ) -> types_schema.DatasetID:
        """See [DB.insert_dataset][trulens.core.database.base.DB.insert_dataset]."""

        with self.session.begin() as session:
            if (
                _dataset := session.query(self.orm.Dataset)
                .filter_by(dataset_id=dataset.dataset_id)
                .first()
            ):
                # Update the existing record for idempotency
                _dataset.dataset_json = dataset.model_dump_json()
            else:
                _dataset = self.orm.Dataset.parse(
                    dataset, redact_keys=self.redact_keys
                )
                session.merge(_dataset)

            logger.info(
                f"{text_utils.UNICODE_CHECK} added dataset {_dataset.dataset_id}"
            )

            return _dataset.dataset_id
See [DB.insert_dataset][trulens.core.database.base.DB.insert_dataset].
src/core/trulens/core/database/sqlalchemy.py