class_docstr: Dataset client api class
class_docstr_tok: ["Dataset","client","api","class"]
docstr: Tries to delete records in a dataset for a given query/ids list.
  
  Args:
      name: The dataset name
      query: The query matching records
      ids: A list of records ids. If provided, the query param will be ignored
      mark_as_discarded: If `True`, the matched records will be marked as `Discarded` instead
          of delete them
      discard_when_forbidden: Only super-user or dataset creator can delete records from a dataset.
          So, running "hard" deletion for other users will raise an `ForbiddenApiError` error.
          If this parameter is `True`, the client API will automatically try to mark as ``Discarded``
          records instead.
  
  Returns:
      The total of matched records and real number of processed errors. These numbers could not
      be the same if some data conflicts are found during operations (some matched records change during
      deletion).
docstr_tok: ["Tries","to","delete","records","in","a","dataset","for","a","given","query\/ids","list",".","Args",":","name",":","The","dataset","name","query",":","The","query","matching","records","ids",":","A","list","of","records","ids",".","If","provided",",","the","query","param","will","be","ignored","mark_as_discarded",":","If","`","True","`",",","the","matched","records","will","be","marked","as","`","Discarded","`","instead","of","delete","them","discard_when_forbidden",":","Only","super-user","or","dataset","creator","can","delete","records","from","a","dataset",".","So",",","running","``","hard","''","deletion","for","other","users","will","raise","an","`","ForbiddenApiError","`","error",".","If","this","parameter","is","`","True","`",",","the","client","API","will","automatically","try","to","mark","as","``","Discarded","``","records","instead",".","Returns",":","The","total","of","matched","records","and","real","number","of","processed","errors",".","These","numbers","could","not","be","the","same","if","some","data","conflicts","are","found","during","operations","(","some","matched","records","change","during","deletion",")","."]
code: def delete_records(
      self,
      name: str,
      mark_as_discarded: bool = False,
      discard_when_forbidden: bool = True,
      **query: Optional[dict],
  ) -> Tuple[int, int]:
      """
      Tries to delete records in a dataset for a given query/ids list.
  
      Args:
          name: The dataset name
          query: The query matching records
          ids: A list of records ids. If provided, the query param will be ignored
          mark_as_discarded: If `True`, the matched records will be marked as `Discarded` instead
              of delete them
          discard_when_forbidden: Only super-user or dataset creator can delete records from a dataset.
              So, running "hard" deletion for other users will raise an `ForbiddenApiError` error.
              If this parameter is `True`, the client API will automatically try to mark as ``Discarded``
              records instead.
  
      Returns:
          The total of matched records and real number of processed errors. These numbers could not
          be the same if some data conflicts are found during operations (some matched records change during
          deletion).
  
      """
      with api_compatibility(self, min_version="0.18"):
          try:
              query = self._parse_query(query=query)
              response = self.http_client.delete(
                  path=f"{self._API_PREFIX}/{name}/data?mark_as_discarded={mark_as_discarded}",
                  json=query,
              )
              return response["matched"], response["processed"]
          except ForbiddenApiError as faer:
              if discard_when_forbidden:
                  warnings.warn(
                      message=f"{faer}. Records will be discarded instead",
                      category=UserWarning,
                  )
                  return self.delete_records(
                      name=name,
                      query=query,
                      mark_as_discarded=True,
                      discard_when_forbidden=False,  # Next time will raise the error
                  )
              else:
                  raise faer
  
imports: import math
  import warnings
  from dataclasses import dataclass
  from datetime import datetime
  from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Union
  from argilla.client.apis import AbstractApi, api_compatibility
  from argilla.client.sdk.commons.errors import AlreadyExistsApiError, ApiCompatibilityError, ForbiddenApiError, NotFoundApiError
  from argilla.client.sdk.datasets.api import get_dataset
  from argilla.client.sdk.datasets.models import TaskType
  from argilla.pydantic_v1 import BaseModel, Field
label_desc: Use image node_id 6 for calling the Datasets obj's underlying member method code with example usage: obj.delete_records(name, mark_as_discarded, discard_when_forbidden) and returns: response,  response, self