For a given model and metadata class, ensure there is metadata for every instance.
161222
def populate_metadata(model, MetadataClass):
    
    content_type = ContentType.objects.get_for_model(model)
    for instance in model.objects.all():
        create_metadata_instance(MetadataClass, instance)
68369
private function createMetadataDefinition()
    {
        $id = $this->getServiceId('metadata');
        if (!$this->container->has($id)) {
            $definition = new Definition(self::CLASS_METADATA);
            $definition
                ->setFactory([new Reference($this->getManagerServiceId()), 'getClassMetadata'])
                ->setArguments([
                    $this->container->getParameter($this->getServiceId('class'))
                ])//->setPublic(false)
            ;
            $this->container->setDefinition($id, $definition);
        }
    }
341395
def build_metadata_class(specfile):
    """"""
    with open(specfile) as f:
        spec = json.load(f)
        name = os.path.basename(specfile).split('.')[0]
        spec['name'] = name

        env = get_jinja_env()

        metadata_template = env.get_template('metadata.py.jinja2')
        with open('pycanvas/meta/{}.py'.format(name), 'w') as t:
            t.write(metadata_template.render(spec=spec))
1172376
def _check_model(obj, models=None):
    """"""
    return isinstance(obj, type) and issubclass(obj, pw.Model) and hasattr(obj, '_meta')
739708
def ensure_table(self, cls):
        """"""
        exists = True
        conn = get_conn()

        try:
            descrip = conn.describe_table(cls.get_table_name())
            assert descrip is not None
        except ResourceNotFoundException:
            # Expected - this is what we get if there is no table
            exists = False
        except JSONResponseError:
            # Also assuming no table
            exists = False

        if not exists:
            table = self.table_schema_call(Table.create, cls)
            assert table is not None
1288407
def write_sampler_metadata(self, sampler):
        """"""
        self.attrs['sampler'] = sampler.name
        self[self.sampler_group].attrs['nwalkers'] = sampler.nwalkers
        # write the model's metadata
        sampler.model.write_metadata(self)
542001
def validate_metadata(train_config):
  

  # Make sure we have a default for every column
  if len(train_config['csv_header']) != len(train_config['csv_defaults']):
    raise ValueError('Unequal number of columns in input features file and '
                     'schema file.')

  # Check there are no missing columns. sorted_colums has two copies of the
  # target column because the target column is also listed in
  # categorical_columns or numerical_columns.
  sorted_columns = sorted(train_config['csv_header'] +
                          [train_config['target_column']])

  sorted_columns2 = sorted(train_config['categorical_columns'] +
                           train_config['numerical_columns'] +
                           [train_config['key_column']] +
                           [train_config['target_column']])
  if sorted_columns2 != sorted_columns:
    raise ValueError('Each csv header must be a numerical/categorical type, a '
                     ' key, or a target.')
317958
public static void validateMetadata(Map<String, String> metadata) throws ServiceException {
        for ( String key : metadata.keySet()){
            if (!validateRequiredField(key, metaKeyRegEx)){
               throw new ServiceException(
                    ErrorCode.SERVICE_INSTANCE_METAKEY_FORMAT_ERROR,
                    ErrorCode.SERVICE_INSTANCE_METAKEY_FORMAT_ERROR.getMessageTemplate(),key
               );
            }
        }

    }
340803
def metadata(namespace: :default)
      entity = current_entity
      if entity
        entity.metadata(namespace: namespace)
      else
        FacadeMetadata
      end
    end
1333131
def repr_new_instance(self, class_data):
        
        classname = self.formatted_classname(class_data["classname"])
        instancename = self.formatted_instancename(class_data["classname"])
        arguments = list()
        for key, value in self.sorted_dict(class_data.get("metadata", dict())):
            arguments.append("%s=%r" % (key, value))
        return "%s = %s(%s)" % (
            instancename, classname, ", ".join(arguments))
188573
def has_metadata(self, name):
        
        return self.has_implementation(name) or \
            name in self.non_returning or \
            name in self.prototypes
235439
def validate_metadata(self, metadata):
        
        response = self.requests_session.post(
            f'{self.url}/validate',
            data=json.dumps(metadata),
            headers=self._headers
        )
        if response.content == b'true\n':
            return True
        else:
            logger.info(self._parse_search_response(response.content))
            return False
1305944
def setSizeMetadata(self, size):
    
    assert((self.needMetadataUpdate(CoverImageMetadata.SIZE)) or
           (self.size == size))
    self.size = size
    self.check_metadata &= ~CoverImageMetadata.SIZE
779642
public void addMetadata(Metadata meta) {
    for (String k : meta.keySet()) {
      for (TiffObject to : meta.getList(k)) {
        add(k, to, meta.getMetadataObject(k).isDublinCore(), meta.getMetadataObject(k).getPath());
      }
    }
  }
111075
def _check_all_metadata_found(metadata, items):
    """"""
    for name in metadata:
        seen = False
        for sample in items:
            check_file = sample["files"][0] if sample.get("files") else sample["vrn_file"]
            if isinstance(name, (tuple, list)):
                if check_file.find(name[0]) > -1:
                    seen = True
            elif check_file.find(name) > -1:
                seen = True
            elif "*" in name and fnmatch.fnmatch(check_file, "*/%s" % name):
                seen = True
        if not seen:
            print("WARNING: sample not found %s" % str(name))
241518
def __meta_metadata(self, field, key):
        """"""
        mf = ''
        try:
            mf = str([f[key] for f in self.metadata
                     if f['field_name'] == field][0])
        except IndexError:
            print("%s not in metadata field:%s" % (key, field))
            return mf
        else:
            return mf
850801
def validate_meta(meta):
    
    if not isinstance(meta, (dict,)):
        raise TypeError('Model Meta "linguist" must be a dict')

    required_keys = ("identifier", "fields")

    for key in required_keys:
        if key not in meta:
            raise KeyError('Model Meta "linguist" dict requires %s to be defined', key)

    if not isinstance(meta["fields"], (list, tuple)):
        raise ImproperlyConfigured(
            "Linguist Meta's fields attribute must be a list or tuple"
        )