Add test lock

This commit is contained in:
augustin64 2022-05-23 16:44:54 +02:00
parent b4e46d44b0
commit f904482199
2 changed files with 13 additions and 3 deletions

View File

@ -107,7 +107,7 @@ def post_network():
request.files["file"].save(training.delta) request.files["file"].save(training.delta)
training.patch() training.patch()
training.computed_images += clients[token].performance
# Préparation de la réponse # Préparation de la réponse
data = {} data = {}
data["status"] = "ok" data["status"] = "ok"
@ -132,7 +132,7 @@ def post_network():
data["nb_elem"] = 0 data["nb_elem"] = 0
data["start"] = 0 data["start"] = 0
data["instruction"] = "sleep" data["instruction"] = "sleep"
data["sleep_time"] = 0.2 data["sleep_time"] = 0.02
return data return data

View File

@ -32,7 +32,7 @@ class Client:
""" """
Donne un travail au client Donne un travail au client
""" """
if training.nb_images == training.cur_image: if training.nb_images <= training.computed_images:
if training.batchs == training.cur_batch: if training.batchs == training.cur_batch:
raise NoMoreJobAvailableError raise NoMoreJobAvailableError
raise TryLaterError raise TryLaterError
@ -54,6 +54,8 @@ class Training:
self.batchs = batchs self.batchs = batchs
self.cur_batch = 1 self.cur_batch = 1
self.cur_image = 0 self.cur_image = 0
self.computed_images = 0
self.lock_test = False
self.dataset = dataset self.dataset = dataset
self.test_set = test_set self.test_set = test_set
self.cache = cache self.cache = cache
@ -89,6 +91,10 @@ class Training:
""" """
Teste les performances du réseau avant le batch suivant Teste les performances du réseau avant le batch suivant
""" """
if self.lock_test:
return
self.lock_test = True
if not os.path.isfile("out/main"): if not os.path.isfile("out/main"):
subprocess.call(["./make.sh", "build", "main"]) subprocess.call(["./make.sh", "build", "main"])
@ -101,10 +107,14 @@ class Training:
]) ])
self.cur_batch += 1 self.cur_batch += 1
self.cur_image = 0 self.cur_image = 0
self.computed_images = 0
if self.cur_batch >= self.batchs: if self.cur_batch >= self.batchs:
print("Done.") print("Done.")
os._exit(0) os._exit(0)
self.lock_test = False
return
def patch(self): def patch(self):
""" """