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)
training.patch()
training.computed_images += clients[token].performance
# Préparation de la réponse
data = {}
data["status"] = "ok"
@ -132,7 +132,7 @@ def post_network():
data["nb_elem"] = 0
data["start"] = 0
data["instruction"] = "sleep"
data["sleep_time"] = 0.2
data["sleep_time"] = 0.02
return data

View File

@ -32,7 +32,7 @@ class 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:
raise NoMoreJobAvailableError
raise TryLaterError
@ -54,6 +54,8 @@ class Training:
self.batchs = batchs
self.cur_batch = 1
self.cur_image = 0
self.computed_images = 0
self.lock_test = False
self.dataset = dataset
self.test_set = test_set
self.cache = cache
@ -89,6 +91,10 @@ class Training:
"""
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"):
subprocess.call(["./make.sh", "build", "main"])
@ -101,9 +107,13 @@ class Training:
])
self.cur_batch += 1
self.cur_image = 0
self.computed_images = 0
if self.cur_batch >= self.batchs:
print("Done.")
os._exit(0)
self.lock_test = False
return
def patch(self):