class_docstr: Dataset client api class
class_docstr_tok: ["Dataset","client","api","class"]
docstr: Search records over a dataset
  
  Args:
      name: the dataset
      query: the search query
      projection: a subset of record fields to retrieve. If not provided,
           only id's will be returned
      sort: The fields on which to sort [(<field_name>, 'asc|decs')].
      limit: The number of records to retrieve
      id_from: If provided, starts gathering the records starting from that Record.
          As the Records returned with the load method are sorted by ID, ´id_from´
          can be used to load using batches.
      batch_size: If provided, load `batch_size` samples per request. A lower batch
          size may help avoid timeouts.
  
  Returns:
      An iterable of raw object containing per-record info
docstr_tok: ["Search","records","over","a","dataset","Args",":","name",":","the","dataset","query",":","the","search","query","projection",":","a","subset","of","record","fields","to","retrieve",".","If","not","provided",",","only","id","'s","will","be","returned","sort",":","The","fields","on","which","to","sort","[","(","<","field_name",">",",","'asc|decs","'",")","]",".","limit",":","The","number","of","records","to","retrieve","id_from",":","If","provided",",","starts","gathering","the","records","starting","from","that","Record",".","As","the","Records","returned","with","the","load","method","are","sorted","by","ID",",","\u00b4id_from\u00b4","can","be","used","to","load","using","batches",".","batch_size",":","If","provided",",","load","`","batch_size","`","samples","per","request",".","A","lower","batch","size","may","help","avoid","timeouts",".","Returns",":","An","iterable","of","raw","object","containing","per-record","info"]
code: def scan(
      self,
      name: str,
      projection: Optional[Set[str]] = None,
      limit: Optional[int] = None,
      sort: Optional[List[Tuple[str, str]]] = None,
      id_from: Optional[str] = None,
      batch_size: int = 250,
      **query,
  ) -> Iterable[dict]:
      """
      Search records over a dataset
  
      Args:
          name: the dataset
          query: the search query
          projection: a subset of record fields to retrieve. If not provided,
               only id's will be returned
          sort: The fields on which to sort [(<field_name>, 'asc|decs')].
          limit: The number of records to retrieve
          id_from: If provided, starts gathering the records starting from that Record.
              As the Records returned with the load method are sorted by ID, ´id_from´
              can be used to load using batches.
          batch_size: If provided, load `batch_size` samples per request. A lower batch
              size may help avoid timeouts.
  
      Returns:
          An iterable of raw object containing per-record info
      """
  
      if limit and limit < 0:
          raise ValueError("The scan limit must be non-negative.")
  
      limit = limit if limit else math.inf
      url = f"{self._API_PREFIX}/{name}/records/:search?limit={{limit}}"
      query = self._parse_query(query=query)
  
      request = {
          "fields": list(projection) if projection else ["id"],
          "query": query,
      }
  
      if sort is not None:
          try:
              if isinstance(sort, list):
                  assert all(
                      [
                          (isinstance(item, tuple))
                          and (item[-1] in ["asc", "desc"])
                          for item in sort
                      ]
                  )
              else:
                  raise Exception()
          except Exception:
              raise ValueError(
                  "sort must be a dict formatted as List[Tuple[<field_name>, 'asc|desc']]"
              )
          request["sort_by"] = [
              {"id": item[0], "order": item[-1]} for item in sort
          ]
  
      elif id_from:
          # TODO: Show message since sort + next_id is not compatible since fixes a sort by id
          request["next_idx"] = id_from
  
      with api_compatibility(self, min_version="1.2.0"):
          request_limit = min(limit, batch_size)
          response = self.http_client.post(
              url.format(limit=request_limit),
              json=request,
          )
  
          while response.get("records"):
              yield from response["records"]
              limit -= request_limit
              if limit <= 0:
                  return
  
              next_request_params = {
                  k: response[k]
                  for k in ["next_idx", "next_page_cfg"]
                  if response.get(k)
              }
              if not next_request_params:
                  return
  
              request_limit = min(limit, batch_size)
              response = self.http_client.post(
                  path=url.format(limit=request_limit),
                  json={**request, **next_request_params},
              )
  
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 4 for calling the Datasets obj's underlying member method code with example usage: obj.scan(name, projection, limit, sort, id_from, batch_size) without return types