示例#1
0
    def put_trajectory(self, trajectory, raw=False):
        try:
            trajectory_ = utils.structed2dict_trajectory(trajectory)
            trajectory_ = utils.pack(trajectory_)
            collection = self._raw_trajectory_collection if raw \
                else self._trajectory_collection

            collection.insert_one(
                {
                    "trajectory": trajectory_,
                    "date": datetime.datetime.utcnow(),
                    "epoch": self._epoch
                }
            )
        except pymongo.errors.AutoReconnect:
            time.sleep(self._reconnect_timeout)
            return self.put_trajectory(trajectory, raw)
示例#2
0
    def put_checkpoint(self, checkpoint, epoch):
        try:
            self._epoch = epoch
            checkpoint_ = utils.pack(checkpoint)
            if self._checkpoint_collection.exists({"filename": "checkpoint"}):
                self.del_checkpoint()

            self._checkpoint_collection.put(
                checkpoint_,
                encoding="ascii",
                filename="checkpoint",
                epoch=self._epoch
            )

        except pymongo.errors.AutoReconnect:
            time.sleep(self._reconnect_timeout)
            return self.put_checkpoint(checkpoint, epoch)
示例#3
0
 def save_checkpoint(self, checkpoint, epoch):
     self._epoch = epoch
     checkpoint = {"checkpoint": checkpoint, "epoch": self._epoch}
     checkpoint = utils.pack(checkpoint)
     self._server.set(f"{self._prefix}_checkpoint", checkpoint)
示例#4
0
 def push_trajectory(self, trajectory, raw=False):
     trajectory = utils.structed2dict_trajectory(trajectory)
     trajectory = {"trajectory": trajectory, "epoch": self._epoch}
     trajectory = utils.pack(trajectory)
     name = "raw_trajectories" if raw else "trajectories"
     self._server.rpush(name, trajectory)
示例#5
0
文件: redis.py 项目: Russ76/catalyst
 def dump_weights(self, weights, prefix, epoch):
     self._epoch = epoch
     weights = {"weights": weights, "epoch": self._epoch}
     weights = utils.pack(weights)
     self._server.set(f"{self._prefix}_{prefix}_weights", weights)
示例#6
0
文件: redis.py 项目: Russ76/catalyst
 def push_trajectory(self, trajectory):
     trajectory = utils.structed2dict_trajectory(trajectory)
     trajectory = {"trajectory": trajectory, "epoch": self._epoch}
     trajectory = utils.pack(trajectory)
     self._server.rpush("trajectories", trajectory)