code: def test_checkout(self, temp_workdir, tmpdir_factory):
      project = Project()
      with open("foo.txt", "w") as f:
          f.write("foo")
  
      with open("keepsake.yaml", "w") as f:
          f.write("repository: file://.keepsake/")
  
      exp = project.experiments.create(
          path=".", params={"foo": "bar"}, disable_heartbeat=True
      )
      with open("bar.txt", "w") as f:
          f.write("bar")
      chk = exp.checkpoint(
          path="bar.txt", metrics={"accuracy": "awesome"}
      )
  
      chk_tar_path = os.path.join(
          ".keepsake/checkpoints", chk.id + ".tar.gz"
      )
      wait(
          lambda: os.path.exists(chk_tar_path),
          timeout_seconds=5,
          sleep_seconds=0.01,
      )
      time.sleep(0.1)  # wait to finish writing
  
      # test with already existing checkpoint
      tmpdir = tmpdir_factory.mktemp("checkout")
      chk.checkout(output_directory=str(tmpdir))
      with open(tmpdir / "foo.txt") as f:
          assert f.read() == "foo"
      with open(tmpdir / "bar.txt") as f:
          assert f.read() == "bar"
  
      # test with checkpoint from keepsake.experiments.list()
      exp = project.experiments.list()[0]
      chk = exp.checkpoints[0]
      tmpdir = tmpdir_factory.mktemp("checkout")
      chk.checkout(output_directory=str(tmpdir))
      with open(tmpdir / "foo.txt") as f:
          assert f.read() == "foo"
      with open(tmpdir / "bar.txt") as f:
          assert f.read() == "bar"
  
      # test with no paths
      exp = project.experiments.create(
          params={"foo": "bar"}, disable_heartbeat=True
      )
      chk = exp.checkpoint(metrics={"accuracy": "awesome"})
      tmpdir = tmpdir_factory.mktemp("checkout")
      with pytest.raises(DoesNotExist):
          chk.checkout(output_directory=str(tmpdir))
  
      # test experiment with no path
      exp = project.experiments.create(
          params={"foo": "bar"}, disable_heartbeat=True
      )
      chk = exp.checkpoint(
          path="bar.txt", metrics={"accuracy": "awesome"}
      )
  
      chk_tar_path = os.path.join(
          ".keepsake/checkpoints", chk.id + ".tar.gz"
      )
      wait(
          lambda: os.path.exists(chk_tar_path),
          timeout_seconds=5,
          sleep_seconds=0.01,
      )
      time.sleep(0.1)  # wait to finish writing
  
      tmpdir = tmpdir_factory.mktemp("checkout")
      chk.checkout(output_directory=str(tmpdir))
      assert not os.path.exists(tmpdir / "foo.txt")
      with open(tmpdir / "bar.txt") as f:
          assert f.read() == "bar"
  
      # test checkpoint with no path
      exp = project.experiments.create(
          path="foo.txt", params={"foo": "bar"}, disable_heartbeat=True
      )
      chk = exp.checkpoint(metrics={"accuracy": "awesome"})
  
      exp_tar_path = os.path.join(
          ".keepsake/experiments", exp.id + ".tar.gz"
      )
      wait(
          lambda: os.path.exists(exp_tar_path),
          timeout_seconds=5,
          sleep_seconds=0.01,
      )
      time.sleep(0.1)  # wait to finish writing
  
      tmpdir = tmpdir_factory.mktemp("checkout")
      chk.checkout(output_directory=str(tmpdir))
      assert not os.path.exists(tmpdir / "bar.txt")
      with open(tmpdir / "foo.txt") as f:
          assert f.read() == "foo"
  
file_path: keepsake/python/tests/test_checkpoint.py
imports: import datetime
  import time
  import os
  import pytest
  from waiting import wait
  from keepsake.checkpoint import Checkpoint, CheckpointList
  from keepsake.exceptions import DoesNotExist
  from keepsake.project import Project
  from tests.factories import experiment_factory, checkpoint_factory
label_desc: Use image node_id 3 for calling the TestCheckpoint obj's underlying member method code with example usage: obj.test_checkout(temp_workdir, tmpdir_factory) without return types