Save pickled model to file.
358760
def save(self, f):
        """"""
        return pickle.dump((self.perceptron.weights, self.tagdict, self.classes, self.clusters), f, protocol=pickle.HIGHEST_PROTOCOL)
1071306
def pickle_data(data, picklefile):
    """"""
    with open(picklefile, 'wb') as f:
        pickle.dump(data, f, protocol=2)
1238363
def save(self, filename='saved.ol.p'):
        
        import dill as pickle
        sv = {
            # 'feature_function': self.feature_function,
            'cl': self.cl

        }
        pickle.dump(sv, open(filename, "wb"))
352299
def save(obj, filename, protocol=4):
    

    with open(filename, 'wb') as f:
        pickle.dump(obj, f, protocol=protocol)
611748
def unpickle_file(picklefile, **kwargs):
    """"""
    with open(picklefile, 'rb') as f:
        return pickle.load(f, **kwargs)
619965
def update_data(ctx, models=True, pickles=False, f=False):
    
    if pickles:
        save_sql_to_files(f)
    if models:
        if f:
            manage(ctx, 'create_models_from_sql --force True', env={})
        else:
            manage(ctx, 'create_models_from_sql', env={})
326069
def save_models(self, model_path):
        
        for group, condition_model_set in self.condition_models.items():
            for model_name, model_obj in condition_model_set.items():
                out_filename = model_path + \
                               "{0}_{1}_condition.pkl".format(group,
                                                              model_name.replace(" ", "-"))
                with open(out_filename, "wb") as pickle_file:
                    pickle.dump(model_obj,
                                pickle_file,
                                pickle.HIGHEST_PROTOCOL)
        for group, size_model_set in self.size_models.items():
            for model_name, model_obj in size_model_set.items():
                out_filename = model_path + \
                               "{0}_{1}_size.pkl".format(group,
                                                         model_name.replace(" ", "-"))
                with open(out_filename, "wb") as pickle_file:
                    pickle.dump(model_obj,
                                pickle_file,
                                pickle.HIGHEST_PROTOCOL)
        for group, dist_model_set in self.size_distribution_models.items():
            for model_type, model_objs in dist_model_set.items():
                for model_name, model_obj in model_objs.items():
                    out_filename = model_path + \
                                   "{0}_{1}_{2}_sizedist.pkl".format(group,
                                                                     model_name.replace(" ", "-"),
                                                                     model_type)
                    with open(out_filename, "wb") as pickle_file:
                        pickle.dump(model_obj,
                                    pickle_file,
                                    pickle.HIGHEST_PROTOCOL)
        for model_type, track_type_models in self.track_models.items():
            for group, track_model_set in track_type_models.items():
                for model_name, model_obj in track_model_set.items():
                    out_filename = model_path + \
                                   "{0}_{1}_{2}_track.pkl".format(group,
                                                                  model_name.replace(" ", "-"),
                                                                  model_type)
                    with open(out_filename, "wb") as pickle_file:
                        pickle.dump(model_obj,
                                    pickle_file,
                                    pickle.HIGHEST_PROTOCOL)

        return
539969
def register_pickle():
    """"""
    import cPickle
    registry.register('pickle', cPickle.dumps, cPickle.loads,
                      content_type='application/x-python-serialize',
                      content_encoding='binary')
820219
def load(self, key=None):
        """"""
        if key is None:
            key = '_pickle'
        obj = None
        if _compat_hooks:
            save = _compat_hooks[0]()
        try:
            self.__n += 1
            s = self.__file.Get(key + ';{0:d}'.format(self.__n))
            self.__io.setvalue(s.GetName())
            if sys.version_info[0] < 3:
                obj = pickle.Unpickler.load(self)
            else:
                obj = super(Unpickler, self).load()
            self.__io.reopen()
        finally:
            if _compat_hooks:
                save = _compat_hooks[1](save)
        return obj
964184
def save(self, obj, label, format='text'):
        

        # initialize hidden state directory

        objloc = '{0}/{1}'.format(self.statedir, label)

        with open(objloc, 'w') as fp:
            if format == 'pickle':
                pickle.dump(obj, fp)
            elif format == 'text':
                fp.write(str(obj))
            else:
                print('Format {0} not recognized. Please choose either pickle or text.'.format(format))

        print('Saving {0} to label {1}'.format(obj, label))
725186
def _dump(self, out_dir=''):
        """"""
        with self.no_unpicklable_properties():
            self.job_file = os.path.join(out_dir, 'job-instance.pickle')
            if self.__module__ == '__main__':
                d = pickle.dumps(self)
                module_name = os.path.basename(sys.argv[0]).rsplit('.', 1)[0]
                d = d.replace('(c__main__', "(c" + module_name)
                open(self.job_file, "w").write(d)
            else:
                pickle.dump(self, open(self.job_file, "w"))
1245328
def save_session_to_file(self, sessionfile):
        """"""
        pickle.dump(requests.utils.dict_from_cookiejar(self._session.cookies), sessionfile)
785581
def maybe_load_model(savedir, container):
  """"""
  if savedir is None:
    return

  state_path = os.path.join(os.path.join(savedir, 'training_state.pkl.zip'))
  if container is not None:
    logger.log("Attempting to download model from Azure")
    found_model = container.get(savedir, 'training_state.pkl.zip')
  else:
    found_model = os.path.exists(state_path)
  if found_model:
    state = pickle_load(state_path, compression=True)
    model_dir = "model-{}".format(state["num_iters"])
    if container is not None:
      container.get(savedir, model_dir)
    U.load_state(os.path.join(savedir, model_dir, "saved"))
    logger.log("Loaded models checkpoint at {} iterations".format(
        state["num_iters"]))
    return state
1298083
def store_model(factory, name, record)
      store_record(record.class.name, name, record) unless pickle_parser.canonical(factory) == pickle_parser.canonical(record.class.name)
      store_record(factory, name, record)
    end
1277840
def savetofile(self, filelike, sortkey = True):
        
        filelike.writelines(k + '=' + repr(v) + '\n' for k,v in self.config_items(sortkey))
1296180
def dump(self, filename):
        """"""
        f = open(filename, "wb")
        pickle.dump(self.__dict__, f, 2)
        f.close()
646186
def save(self, modelfile, layer=None):
        
        if layer:
            obj = {layer: self.model[layer]}
        else:
            obj = self.model
        with open(modelfile, 'w') as fp:
            json.dump(obj, fp, indent=2, sort_keys=True)