class_docstr: ScenarioSetMeta helps create "scenario sets", glob-like definitions of inputs and expectations.
  
  Example:
  
      MyTestSpec(metaclass=ScenarioSetMeta):
          field_1 = {"y": True, "n": False}
          field_2 = {"h": "hello", "b": "bye"}
  
      # Defined dynamically by the metaclass:
      #
      #   scenariotype = namedtuple("MyTestSpecScenario", ["field_1", "field_2"])
      #
      #   def __init__(self, field_1, field_2, *expected):
      #       self.field_1 = field_1
      #       self.field_2 = field_2
      #       # Note that extra args become "expected"
      #       self.expected = expected
      #
      #   def scenarios(self):
      #       for f1 in ("yn" if self.field_1 == "*" else self.field_1):
      #           for f2 in ("hb" if self.field_2 == "*" else self.field_2):
      #               f1_val = {"y": True, "n": False}[f1]
      #               f2_val = {"h": "hello", "b": "bye"}[f2]
      #               yield scenariotype(f1_val, f2_val)
class_docstr_tok: ["ScenarioSetMeta","helps","create","``","scenario","sets","''",",","glob-like","definitions","of","inputs","and","expectations",".","Example",":","MyTestSpec","(","metaclass=ScenarioSetMeta",")",":","field_1","=","{","``","y","''",":","True",",","``","n","''",":","False","}","field_2","=","{","``","h","''",":","``","hello","''",",","``","b","''",":","``","bye","''","}","#","Defined","dynamically","by","the","metaclass",":","#","#","scenariotype","=","namedtuple","(","``","MyTestSpecScenario","''",",","[","``","field_1","''",",","``","field_2","''","]",")","#","#","def","__init__","(","self",",","field_1",",","field_2",",","*","expected",")",":","#","self.field_1","=","field_1","#","self.field_2","=","field_2","#","#","Note","that","extra","args","become","``","expected","''","#","self.expected","=","expected","#","#","def","scenarios","(","self",")",":","#","for","f1","in","(","``","yn","''","if","self.field_1","==","``","*","''","else","self.field_1",")",":","#","for","f2","in","(","``","hb","''","if","self.field_2","==","``","*","''","else","self.field_2",")",":","#","f1_val","=","{","``","y","''",":","True",",","``","n","''",":","False","}","[","f1","]","#","f2_val","=","{","``","h","''",":","``","hello","''",",","``","b","''",":","``","bye","''","}","[","f2","]","#","yield","scenariotype","(","f1_val",",","f2_val",")"]
code: def __new__(cls: type, name: str, bases: Tuple, dct: dict) -> Any:
      # Collect the "fields", which are dict-type attributes on the class.
      fields = collections.OrderedDict()
      for field, opts in dct.items():
          if field.startswith("_"):
              continue
          if not isinstance(opts, dict):
              continue
          fields[field] = opts
  
      # Build the namedtuple.
      scenariotype = collections.namedtuple(  # type: ignore
          name + "Scenario", [*fields, "expected"]
      )
  
      # Define the __init__ method.
      def __init__(self, *args, **kwargs):
          args, expected = args[: len(fields)], args[len(fields) :]
          # Read and validate the fields passed in.
          for (field, opts), arg in zip(fields.items(), args):
              if arg != "*" and not all(a in opts for a in arg):
                  raise ValueError(
                      f"unknown option {arg!r} not in allowable set {opts!r} for field {field!r}"
                  )
              setattr(self, field, arg)
          # Also track the expected.
          self.expected = expected
  
      # Define the scenarios() method.
      def scenarios(self):
          iterables = []
          for field, opts in fields.items():
              val = getattr(self, field)
              if val == "*":
                  # Yield one of every valid value for this field.
                  iterables.append(opts.values())
              else:
                  # Yield the corresponding value for each field key in the val string.
                  iterables.append([opts[v] for v in val])
          yield from (
              scenariotype(*x, self.expected)
              for x in itertools.product(*iterables)
          )
  
      # Also define a __repr__ method().
      def __repr__(self):
          argstr = ", ".join(
              repr(getattr(self, field)) for field in fields
          )
          return f"{name}({argstr}, expected={self.expected!r})"
  
      # Actually construct the dynamic class.
      dct["__init__"] = __init__
      dct["scenarios"] = scenarios
      dct["scenariotype"] = scenariotype
      dct["__repr__"] = __repr__
      return super().__new__(cls, name, bases, dct)
  
imports: import collections
  import contextlib
  import itertools
  from typing import Any, Iterator, List, Tuple, no_type_check
  from unittest import mock
  import pytest
  import responses
  from responses import matchers, registries
  from determined.cli import cli
  from determined.common.api import authentication
  from tests.cli import util
label_desc: Use image node_id 1 for calling the ScenarioSetMeta obj's underlying member method code with example usage: obj.__new__(cls, name, bases, dct) and returns: super, name, str, argstr, str, self, str