code: def test_stream_metrics(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
      exp = client.create_experiment(
          config, conf.fixtures_path("no_op")
      )
      assert exp.wait() == _client.ExperimentState.COMPLETED
  
      trials = exp.get_trials()
      assert len(trials) == 1
      trial = trials[0]
  
      for metrics in [
          list(trial.stream_metrics("training")),
          list(client.stream_trials_metrics([trial.id], "training")),
      ]:
          assert (
              len(metrics)
              == config["searcher"]["max_length"]["batches"]
          )
          for i, actual in enumerate(metrics):
              assert actual == TrialMetrics(
                  trial_id=trial.id,
                  trial_run_id=1,
                  steps_completed=i + 1,
                  end_time=actual.end_time,
                  metrics={
                      "loss": config["hyperparameters"]["metrics_base"]
                      ** (i + 1)
                  },
                  batch_metrics=[
                      {
                          "loss": config["hyperparameters"][
                              "metrics_base"
                          ]
                          ** (i + 1)
                      }
                  ],
                  group="training",
              )
  
      for val_metrics in [
          list(trial.stream_metrics("validation")),
          list(client.stream_trials_metrics([trial.id], "validation")),
      ]:
          assert len(val_metrics) == 1
          assert val_metrics[0] == TrialMetrics(
              trial_id=trial.id,
              trial_run_id=1,
              steps_completed=100,
              end_time=val_metrics[0].end_time,
              metrics={
                  "validation_error": config["hyperparameters"][
                      "metrics_base"
                  ]
                  ** 100,
                  "validation_metric_1": config["hyperparameters"][
                      "metrics_base"
                  ]
                  ** 100,
              },
              group="validation",
          )
  
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 6 for calling a global function with example usage: test_stream_metrics(client) without return types