code: def test_completed_experiment_and_checkpoint_apis(
      client: _client.Determined,
  ) -> None:
      with open(
          conf.fixtures_path("no_op/single-one-short-step.yaml")
      ) as f:
          config = util.yaml_safe_load(f)
      config["hyperparameters"]["num_validation_metrics"] = 2
      # Test the use of the includes parameter, by feeding the model definition file via includes.
      emptydir = tempfile.mkdtemp()
      try:
          model_def = conf.fixtures_path("no_op/model_def.py")
          exp = client.create_experiment(
              config, emptydir, includes=[model_def]
          )
      finally:
          os.rmdir(emptydir)
      exp = client.create_experiment(
          config, conf.fixtures_path("no_op")
      )
  
      # Await first trial is safe to call before a trial has started.
      trial = exp.await_first_trial()
  
      # .logs(follow=True) block until the trial completes.
      all_logs = list(trial.logs(follow=True))
  
      assert exp.wait() == _client.ExperimentState.COMPLETED
  
      assert all_logs == list(trial.logs())
      assert list(trial.logs(head=10)) == all_logs[:10]
      assert list(trial.logs(tail=10)) == all_logs[-10:]
  
      trials = exp.get_trials()
      assert len(trials) == 1, trials
      assert client.get_trial(trial.id).id == trial.id
  
      ckpt = trial.top_checkpoint()
  
      # Training checkpoints should have training metadata.
      assert ckpt.training is not None
      assert ckpt.training.trial_id == trial.id
      assert ckpt.training.experiment_id == exp.id
  
      # Various ways to look up the trial.
      assert trial.select_checkpoint(uuid=ckpt.uuid).uuid == ckpt.uuid
      assert trial.select_checkpoint(latest=True).uuid == ckpt.uuid
      assert trial.select_checkpoint(best=True).uuid == ckpt.uuid
      assert (
          trial.select_checkpoint(
              best=True,
              sort_by="validation_metric_1",
              smaller_is_better=True,
          ).uuid
          == ckpt.uuid
      )
      assert len(trial.get_checkpoints()) == 1
      assert trial.get_checkpoints()[0].uuid == ckpt.uuid
  
      assert exp.top_checkpoint().uuid == ckpt.uuid
      assert ckpt.uuid in (c.uuid for c in exp.top_n_checkpoints(100))
      assert client.get_checkpoint(ckpt.uuid).uuid == ckpt.uuid
  
      # Adding checkpoint metadata.
      ckpt.add_metadata({"newkey": "newvalue"})
      # Cache should be updated.
      assert ckpt.metadata
      assert ckpt.metadata["newkey"] == "newvalue"
      # Database should be updated.
      ckpt = client.get_checkpoint(ckpt.uuid)
      assert ckpt.metadata
      assert ckpt.metadata["newkey"] == "newvalue"
  
      # Removing checkpoint metadata
      ckpt.remove_metadata(["newkey"])
      assert "newkey" not in ckpt.metadata
      ckpt = client.get_checkpoint(ckpt.uuid)
      assert ckpt.metadata
      assert "newkey" not in ckpt.metadata
  
      # Test creation of experiment without a model definition
      with open(conf.fixtures_path("no_op/empty_model_dir.yaml")) as f:
          config = util.yaml_safe_load(f)
      exp = client.create_experiment(config)
  
file_path: determined/e2e_tests/tests/test_sdk.py
imports: import os
  import random
  import shutil
  import tempfile
  import time
  import pytest
  from determined.common import util
  from determined.common.api import bindings, errors
  from determined.common.experimental import resource_pool
  from determined.common.experimental.metrics import TrialMetrics
  from determined.experimental import client
  from tests import config
label_desc: Use image node_id 1 for calling a global function with example usage: test_completed_experiment_and_checkpoint_apis(client) without return types