class_docstr: ``TrainContext`` gives access to report training and validation metrics to the Determined master
  during trial tasks.
class_docstr_tok: ["``","TrainContext","``","gives","access","to","report","training","and","validation","metrics","to","the","Determined","master","during","trial","tasks","."]
code: def _get_last_validation(self) -> Optional[int]:
      # This is needed by the workload sequencer, but it is not generally stable, because it is
      # easy to call this before reporting any metrics.  If your last checkpoint was older than
      # your last validation, then the value you get from this function might be higher before
      # you report metrics than after (since metrics get archived on first report of new metrics,
      # not on trial restart).  However, this bug does not happen to affect the workload sequencer
      # because of the workload sequencer's very specific use of this function.
      r = self._session.get(f"/api/v1/trials/{self._trial_id}")
      val = r.json()["trial"].get("latestValidation") or {}
      steps_completed = val.get("totalBatches")
      logger.debug(f"_get_last_validation() -> {steps_completed}")
      return steps_completed
  
imports: import enum
  import logging
  import pathlib
  from typing import Any, Callable, Dict, List, Optional, Set
  import determined
  from determined import core, tensorboard
  from determined.common import api, util
  from determined.common.api import bindings, errors
label_desc: Use image node_id 3 for calling the TrainContext obj's underlying member method code with example usage: obj._get_last_validation() and returns: steps_completed