def __init__()

in marketplace/deployer_util/config_helper.py [0:0]


  def __init__(self, dictionary):
    self._cpu = dictionary.get('cpu', None)
    self._memory = dictionary.get('memory', None)
    self._gpu = None

    rawGpu = dictionary.get('gpu', None)
    if rawGpu != None:
      if not isinstance(rawGpu, dict):
        raise InvalidSchema(
            'requests.gpu in clusterConstraints.resources must be a map')
      if not rawGpu.keys():
        raise InvalidSchema('GPU requests map must contain one or more entries')
      if self._cpu or self._memory:
        raise InvalidSchema(
            'constraints with GPU requests must not specify cpu or memory')
      for key in rawGpu.keys():
        if key not in _GPU_PROVIDER_KEYS:
          raise InvalidSchema('Unsupported GPU provider %s', key)
      self._gpu = {
          key: SchemaGpuResourceRequest(value)
          for (key, value) in rawGpu.items()
      }

    if not self._cpu and not self._memory and not self._gpu:
      raise InvalidSchema(
          'Requests in clusterConstraints.resources must specify '
          'at least one of cpu, memory, or gpu')