def patch_export(export_name: str, request: PatchExportRequest) -> ExportTask:
    """Pathes an existing ExportTask in the database."""
    db_export = ExportTask.find(name=export_name)
    if not db_export:
        raise HTTPException(
            status_code=404, detail=f"ExportTask {export_name} not found"
        )

    template = Template.find(name=request.export.template_name)
    if not template:
        raise HTTPException(
            status_code=422,
            detail=f"ExportTask could not be patched: Template {request.export.template_name} not found",
        )

    update_data = request.export.model_dump(exclude_unset=True)
    updated_export = db_export.model_copy(update=update_data)
    new = updated_export.save()
    return new
Pathes an existing ExportTask in the database.
core/web/apiv2/tasks.py