Ejemplo n.º 1
0
        def destroy_job():
            secret = request.args.get('secret')
            job = self.get_submitted_job(secret)
            if job is not None and not job.running():
                with self.mutex:
                    model = self.jobs[secret].get_trained_model()
                    history = self.jobs[secret].get_history()
                    model = pickle_object(
                        serialize_keras_model(model)).encode('hex_codec')
                    history = pickle_object(history).encode('hex_codec')
                    d = {}
                    d['model'] = model
                    d['history'] = history
                    del self.jobs[secret]
                return json.dumps(d), 200

            return '', 400
Ejemplo n.º 2
0
 def send(self, address):
     data = {}
     data['secret'] = self.secret
     data['job_name'] = self.job_name
     data['num_executors'] = self.num_executors
     data['num_processes'] = self.num_processes
     data['data_path'] = self.data_path
     data['trainer'] = pickle_object(self.trainer).encode('hex_codec')
     request = urllib2.Request(address + "/api/submit")
     request.add_header('Content-Type', 'application/json')
     urllib2.urlopen(request, json.dumps(data))
     self.address = address
     self.start()
Ejemplo n.º 3
0
 def serialize(self):
     return pickle_object(self)
Ejemplo n.º 4
0
 def serialize_trainer(self):
     trainer = pickle_object(self.trainer)
     home = expanduser("~")
     with open(home + "/trainers/" + self.secret, "w") as f:
         f.write(trainer)
Ejemplo n.º 5
0
 def serialize(self):
     return pickle_object(self)