def remove_dataset_dependencies(
        self, dataset: DatasetRecord, version: Optional[str] = None
    ) -> None:
        """
        When we remove dataset, we need to clean up it's dependencies as well
        """
        dd = self._datasets_dependencies

        q = self._datasets_dependencies_delete().where(
            dd.c.source_dataset_id == dataset.id
        )

        if version:
            q = q.where(
                dd.c.source_dataset_version_id == dataset.get_version(version).id
            )

        self.db.execute(q)

        When we remove dataset, we need to clean up it's dependencies as well
        
src/datachain/data_storage/metastore.py