9
9
import numpy as np
10
10
import requests
11
11
import torch
12
+ from datetime import datetime
13
+ now = datetime .now ()
12
14
from datasets import load_dataset
13
15
from transformers import (AutoModelForSequenceClassification , AutoTokenizer ,
14
16
Trainer , TrainingArguments )
@@ -98,7 +100,9 @@ def model_init():
98
100
def print_in_color (text , color_code ):
99
101
"""This function prints the text in the specified color."""
100
102
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 } " )
102
106
103
107
104
108
def register_particle (addr ):
@@ -146,8 +150,10 @@ def perform():
146
150
print_in_color (f"Address { addr } started to work." , "\033 [33m" )
147
151
while True :
148
152
try :
153
+ print_in_color ("### Checking for updated miner:" , "\033 [31m" )
154
+ check_for_updates ()
149
155
print_in_color (f"Preparing" , "\033 [33m" )
150
- time .sleep (5 )
156
+ time .sleep (30 )
151
157
task_args = register_particle (addr )
152
158
print_in_color (f"Address { addr } received the task." , "\033 [33m" )
153
159
execute (task_args )
@@ -158,9 +164,7 @@ def perform():
158
164
print_in_color ("### Deleted the model." , "\033 [31m" )
159
165
print_in_color ("### Disk space:" , "\033 [31m" )
160
166
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 )
164
168
except Exception as e :
165
169
print_in_color (f"Error: { e } " , "\033 [31m" )
166
170
else :
0 commit comments