class_docstr: A class representing a Trial object.
  
  A Trial object is usually obtained from :func:`determined.experimental.client.get_trial`.
  Trial reference class used for querying relevant :class:`~determined.experimental.Checkpoint`
  instances.
  
  Attributes:
      trial_id: ID of trial.
      session: HTTP request session.
      experiment_id: (Mutable, Optional[int]) ID of the experiment this trial belongs to.
      hparams: (Mutable, Optional[Dict]) Dict[name, value] of the trial's hyperparameters.
          This is an instance of the hyperparameter space defined by the experiment.
      state: (Mutable, Optional[TrialState]) Trial state (ex: ACTIVE, PAUSED, COMPLETED).
      summary_metrics: (Mutable, Optional[Dict]) Summary metrics for the trial. Includes
          aggregated metrics for training and validation steps for each reported metric name.
          Example:
  
          .. code::
  
              {
                  "avg_metrics": {
                      "loss": {
                          "count": 100,
                          "last": 0.2,
                          "max": 0.4,
                          "min", 0.2,
                          "sum": 1.2,
                          "type": "number",
                      }
              }
  
  Note:
      All attributes are cached by default.
  
      The :attr:`hparams` and :attr:`summary_metrics` attributes are mutable and may be changed
      by methods that update these values, either automatically or explicitly with :meth:`reload`.
class_docstr_tok: ["A","class","representing","a","Trial","object",".","A","Trial","object","is","usually","obtained","from",":","func",":","`","determined.experimental.client.get_trial","`",".","Trial","reference","class","used","for","querying","relevant",":","class",":","`","~determined.experimental.Checkpoint","`","instances",".","Attributes",":","trial_id",":","ID","of","trial",".","session",":","HTTP","request","session",".","experiment_id",":","(","Mutable",",","Optional","[","int","]",")","ID","of","the","experiment","this","trial","belongs","to",".","hparams",":","(","Mutable",",","Optional","[","Dict","]",")","Dict","[","name",",","value","]","of","the","trial","'s","hyperparameters",".","This","is","an","instance","of","the","hyperparameter","space","defined","by","the","experiment",".","state",":","(","Mutable",",","Optional","[","TrialState","]",")","Trial","state","(","ex",":","ACTIVE",",","PAUSED",",","COMPLETED",")",".","summary_metrics",":","(","Mutable",",","Optional","[","Dict","]",")","Summary","metrics","for","the","trial",".","Includes","aggregated","metrics","for","training","and","validation","steps","for","each","reported","metric","name",".","Example",":","..","code",":",":","{","``","avg_metrics","''",":","{","``","loss","''",":","{","``","count","''",":","100",",","``","last","''",":","0.2",",","``","max","''",":","0.4",",","``","min","''",",","0.2",",","``","sum","''",":","1.2",",","``","type","''",":","``","number","''",",","}","}","Note",":","All","attributes","are","cached","by","default",".","The",":","attr",":","`","hparams","`","and",":","attr",":","`","summary_metrics","`","attributes","are","mutable","and","may","be","changed","by","methods","that","update","these","values",",","either","automatically","or","explicitly","with",":","meth",":","`","reload","`","."]
docstr: Return a list of :class:`~determined.experimental.Checkpoint` instances for the current
  trial.
  
  Either ``sort_by`` and ``order_by`` are both specified or neither are.
  
  Arguments:
      sort_by (string, :class:`~determined.experimental.CheckpointSortBy`): Which field to
          sort by. Strings are assumed to be validation metric names.
      order_by (:class:`~determined.experimental.OrderBy`): Whether to sort in
          ascending or descending order.
code: def get_checkpoints(
      self,
      sort_by: Optional[Union[str, checkpoint.CheckpointSortBy]] = None,
      order_by: Optional[OrderBy] = None,
  ) -> List[checkpoint.Checkpoint]:
      """
      Return a list of :class:`~determined.experimental.Checkpoint` instances for the current
      trial.
  
      Either ``sort_by`` and ``order_by`` are both specified or neither are.
  
      Arguments:
          sort_by (string, :class:`~determined.experimental.CheckpointSortBy`): Which field to
              sort by. Strings are assumed to be validation metric names.
          order_by (:class:`~determined.experimental.OrderBy`): Whether to sort in
              ascending or descending order.
      """
  
      warnings.warn(
          "Trial.get_checkpoints() has been deprecated and will be removed in a future "
          "version."
          "Please call Experiment.list_checkpoints() instead.",
          FutureWarning,
          stacklevel=2,
      )
  
      if (sort_by is None) != (order_by is None):
          raise AssertionError(
              "sort_by and order_by must be set together"
          )
  
      def get_trial_checkpoints(
          offset: int,
      ) -> bindings.v1GetTrialCheckpointsResponse:
          return bindings.get_GetTrialCheckpoints(
              self._session,
              id=self.id,
              orderBy=order_by._to_bindings() if order_by else None,
              sortByAttr=sort_by._to_bindings()
              if isinstance(sort_by, checkpoint.CheckpointSortBy)
              else None,
              offset=offset,
          )
  
      resps = api.read_paginated(get_trial_checkpoints)
  
      checkpoints = [
          checkpoint.Checkpoint._from_bindings(c, self._session)
          for r in resps
          for c in r.checkpoints
      ]
  
      # If sort_by was a defined field, we already sorted and ordered.
      if (
          isinstance(sort_by, checkpoint.CheckpointSortBy)
          or not checkpoints
      ):
          return checkpoints
  
      # If sort not specified, sort and order default to searcher configs.
      if not sort_by:
          training = checkpoints[0].training
          assert training
          config = training.experiment_config
          searcher_metric = config.get("searcher", {}).get("metric")
          if not isinstance(searcher_metric, str):
              raise ValueError(
                  "no searcher.metric found in experiment config; please provide a sort_by metric"
              )
          sort_by = searcher_metric
          smaller_is_better = config.get("searcher", {}).get(
              "smaller_is_better", True
          )
          order_by = OrderBy.ASC if smaller_is_better else OrderBy.DESC
  
      assert (
          sort_by is not None and order_by is not None
      ), "sort_by and order_by not defined."
  
      reverse = order_by == OrderBy.DESC
  
      def key(ckpt: checkpoint.Checkpoint) -> Any:
          training = ckpt.training
          assert training
          metric = training.validation_metrics.get("avgMetrics") or {}
          metric = metric.get(sort_by)
  
          # Return a bool here to sort checkpoints that may have no validation metrics.
          if reverse:
              return metric is not None, metric
          else:
              return metric is None, metric
  
      checkpoints.sort(reverse=reverse, key=key)
  
      return checkpoints
  
imports: import datetime
  import enum
  import inspect
  import warnings
  from typing import Any, Dict, Iterable, List, Optional, Union
  from determined.common import api, util
  from determined.common.api import bindings, logs
  from determined.common.experimental import checkpoint, metrics
  from determined.common.experimental._util import OrderBy
label_desc: Use image node_id 8 for calling the Trial obj's underlying member method code with example usage: obj.get_checkpoints(sort_by, order_by) and returns: checkpoints, bindings, checkpoints, unknown,  metric, unknown,  metric