Skip to content

Commit 79b42fc

Browse files
authored
Reorder the flow a bit and add timestamp in printing. (nimble-technology#22)
1 parent bf53b4c commit 79b42fc

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

execute.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import numpy as np
1010
import requests
1111
import torch
12+
from datetime import datetime
13+
now = datetime.now()
1214
from datasets import load_dataset
1315
from transformers import (AutoModelForSequenceClassification, AutoTokenizer,
1416
Trainer, TrainingArguments)
@@ -98,7 +100,9 @@ def model_init():
98100
def print_in_color(text, color_code):
99101
"""This function prints the text in the specified color."""
100102
END_COLOR = "\033[0m"
101-
print(f"{color_code}{text}{END_COLOR}")
103+
now = datetime.now()
104+
formatted_now = now.strftime("%Y-%m-%d %H:%M:%S")
105+
print(f"{color_code}{formatted_now} {text}{END_COLOR}")
102106

103107

104108
def register_particle(addr):
@@ -146,8 +150,10 @@ def perform():
146150
print_in_color(f"Address {addr} started to work.", "\033[33m")
147151
while True:
148152
try:
153+
print_in_color("### Checking for updated miner:", "\033[31m")
154+
check_for_updates()
149155
print_in_color(f"Preparing", "\033[33m")
150-
time.sleep(5)
156+
time.sleep(30)
151157
task_args = register_particle(addr)
152158
print_in_color(f"Address {addr} received the task.", "\033[33m")
153159
execute(task_args)
@@ -158,9 +164,7 @@ def perform():
158164
print_in_color("### Deleted the model.", "\033[31m")
159165
print_in_color("### Disk space:", "\033[31m")
160166
check_disk_space()
161-
print_in_color("### Checking for updated miner:", "\033[31m")
162-
check_for_updates()
163-
time.sleep(60)
167+
time.sleep(30)
164168
except Exception as e:
165169
print_in_color(f"Error: {e}", "\033[31m")
166170
else:

0 commit comments

Comments
 (0)