docstr: Checks that the Snapshotter class saves as expected.
docstr_tok: ["Checks","that","the","Snapshotter","class","saves","as","expected","."]
code: def test_snapshotter(self):
      """Checks that the Snapshotter class saves as expected."""
      directory = self.get_tempdir()
  
      models_snapshotter = snapshotter.JAXSnapshotter(
          variable_source=_DummyVariableSource(),
          models=self._test_models,
          path=directory,
          max_to_keep=2,
          add_uid=False,
      )
      models_snapshotter._save()
  
      # The snapshots are written in a folder of the form:
      # PATH/{time.strftime}/MODEL_NAME
      first_snapshots = os.listdir(directory)
      self.assertEqual(len(first_snapshots), 1)
      self._check_snapshot(directory, first_snapshots[0])
      # Make sure that the second snapshot is constructed.
      time.sleep(1.1)
      models_snapshotter._save()
      snapshots = os.listdir(directory)
      self.assertEqual(len(snapshots), 2)
      self._check_snapshot(directory, snapshots[0])
      self._check_snapshot(directory, snapshots[1])
  
      # Make sure that new snapshotter deletes the oldest snapshot upon _save().
      time.sleep(1.1)
      models_snapshotter2 = snapshotter.JAXSnapshotter(
          variable_source=_DummyVariableSource(),
          models=self._test_models,
          path=directory,
          max_to_keep=2,
          add_uid=False,
      )
      self.assertEqual(snapshots, os.listdir(directory))
      time.sleep(1.1)
      models_snapshotter2._save()
      snapshots = os.listdir(directory)
      self.assertNotIn(first_snapshots[0], snapshots)
      self.assertEqual(len(snapshots), 2)
      self._check_snapshot(directory, snapshots[0])
      self._check_snapshot(directory, snapshots[1])
  
imports: import os
  import time
  from typing import Any, Sequence
  from acme import core
  from acme.jax import snapshotter
  from acme.jax import types
  from acme.testing import test_utils
  import jax.numpy
  from absl.testing import absltest
label_desc: Use image node_id 3 for calling the SnapshotterTest obj's underlying member method code with example usage: obj.test_snapshotter() without return types