return the original model stored by create_model or find_model
17654
def created_model(name)
      factory, name_or_index = *parse_model(name)

      if name_or_index.blank?
        models_by_index(factory).last
      elsif name_or_index.is_a?(Integer)
        models_by_index(factory)[name_or_index]
      else
        models_by_name(factory)[name_or_index] or raise ModelNotKnownError, name
      end
    end
97661
def get_model(cls, version, model_name):
        
        models = cls.versions[version].model_options
        for keystore in models.values():
            if model_name in keystore:
                return keystore[model_name]
        raise ValueError("Unknown model name")
273498
def get_model():
    
    if not hasattr(g, 'model'):
        g.model = load_model(current_app.config['MODEL_CLS_PATH'],
                             current_app.config['MODEL_CLS_NAME'],
                             current_app.config['MODEL_LOAD_ARGS'])
    return g.model
1150054
def get_for_model(self, model):
        
        return self.get_or_create(
            content_type    = ContentType.objects.get_for_model(model),
            object_id       = model.pk
        )
747460
def model_saved(sender, instance,
                        created,
                        raw,
                        using,
                        **kwargs):
    
    opts = get_opts(instance)
    model = '.'.join([opts.app_label, opts.object_name])
    action = 'created' if created else 'updated'
    distill_model_event(instance, model, action)
16083
function(model_s, create, options){
      var toAdd = model_s instanceof Array ? model_s : [model_s],
          self = this;

      ko.utils.arrayForEach(toAdd, function(attributes){
        var model;
        if(attributes instanceof Model){
          model = attributes;
          model.collection = self;
        }else{
          model = new self.model(attributes, {collection: self});
        }
        self.models.push(model);
        if(create) model.save(options);
      });
    }
342852
def search_converted_models(root=None):
    
    if root is None:
        root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "tests"))
        root = os.path.normpath(root)
    if not os.path.exists(root):
        raise FileNotFoundError("Unable to find '{0}'.".format(root))
    
    founds = glob.iglob("{0}/**/*.model.onnx".format(root), recursive=True)
    keep = []
    for found in founds:
        onnx = found
        basename = onnx[:-len(".model.onnx")]
        data = basename + ".data.pkl"
        expected = basename + ".expected.pkl"
        res = dict(onnx=onnx, data=data, expected=expected)
        ok = True
        for k, v in res.items():
            if not os.path.exists(v):
                ok = False
        if ok:
            models = [basename + ".model.pkl", basename + ".model.keras"]
            for model in models:
                if os.path.exists(model):
                    res['model'] = model
                    break
            if 'model' in res:
                keep.append((basename, res))
    keep.sort()
    return [_[1] for _ in keep]
52384
def get_or_create(self, **kwargs):
        
        assert kwargs, \
                'get_or_create() must be passed at least one keyword argument'
        defaults = kwargs.pop('defaults', {})
        lookup = kwargs.copy()
        #TODO: check fields
        try:
            return self.get(**lookup), False
        except self.model.DoesNotExist:
            params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
            params.update(defaults)
            obj = self.model(**params)
            meta = obj.get_meta()
            meta.connection = get_es_connection(self.es_url, self.es_kwargs)
            meta.index=self.index
            meta.type=self.type
            obj.save(force=True)
            return obj, True
205281
def _find_models(self, constructor, table_name, constraints=None, *, columns=None,
                   order_by=None, limiting=None):
    """"""
    for record in self.find_all(table_name, constraints, columns=columns, order_by=order_by,
                                limiting=limiting):
      yield constructor(record)
285062
def model_getattr():
    

    def model_getattr(_value, context, **_params):
        value = getattr(context["model"], context["key"])
        return _attr(value)

    return model_getattr
1357373
def _create_model(self, view_getter=None, source_getters=None,
                      model_factory=None, officer=None):
        

        if view_getter is not None:
            d = defer.succeed(view_getter)
            d.addCallback(self._retrieve_view)
            d.addCallback(self._check_view)
        else:
            # views are inherited
            d = defer.succeed(self.model.view)

        d.addCallback(self._retrieve_model, source_getters,
                      model_factory, officer)

        d.addErrback(self._filter_errors)
        return d
964697
def import_model(self, source):
        """"""
        if not hasattr(source, 'read'):  # Not a File-like object
            with open(self._resolve_source(source), 'r') as f:
                return self._import(f)
        else:
            return self._import(source)
296502
def export_original_data(self):
        

        def export_field(value):
            """
            Export item
            """
            try:
                return value.export_original_data()
            except AttributeError:
                return value

        return [export_field(val) for val in self.__original_data__]
640909
def get_model(self, model, model_id):
        
        return self._store.find_record(self._get_model_class(model), int(model_id))
1095761
def find_models(self, constructor, constraints=None, *, columns=None, order_by=None,
                  limiting=None, table_name=None):
    """"""
    return self._find_models(
      constructor, table_name or constructor.table_name, constraints, columns=columns,
      order_by=order_by, limiting=limiting)
1065676
def get_model(self):
        

        return ToolModel(
            name=self.name,
            version="0.0.0",
            parameters=self.parameters_from_dicts(self.parameters)
        )
1322144
def get_or_create(self, commit=False, **kwargs) -> Tuple[model, bool]:
        
        instance = self.get_by(**kwargs)
        if not instance:
            return self.create(commit=commit, **kwargs), True
        return instance, False