3
3
import datetime
4
4
import os
5
5
import shlex
6
+ from replotting import replotting
6
7
7
8
class plot_process_monitor (object ):
8
9
proc = None
@@ -16,19 +17,19 @@ class plot_process_monitor(object):
16
17
file_name = ""
17
18
step = ""
18
19
plot_number = 0
19
- number_of_iterations = 0
20
20
client_identifier = ""
21
+ replotting = None
21
22
22
- def __init__ (self , proc , temp_drive , temp_drive_two , destination_drive , number_of_iterations , client_identifier ):
23
+ def __init__ (self , proc , temp_drive , temp_drive_two , destination_drive , client_identifier , replotting ):
23
24
self .proc = proc
24
25
self .temp_drive = temp_drive
25
26
self .temp_drive_two = temp_drive_two
26
27
self .destination_drive = destination_drive
27
28
self .file_name = str (self .proc .pid ) + ".txt"
28
29
self .start_time = datetime .datetime .now ()
29
- self .number_of_iterations = number_of_iterations
30
30
self .client_identifier = client_identifier
31
-
31
+ self .replotting = replotting
32
+
32
33
@property
33
34
def plotting_drives (self ):
34
35
joined_drive_names = self .temp_drive
@@ -47,6 +48,13 @@ def start_monitoring(self):
47
48
48
49
if "Starting phase 1/4" .lower () in line .lower () or "plot name" in line .lower ():
49
50
self .plot_number += 1
51
+ #client_identifier has significance. If a user has multiple plot processes running to same destination drive, not all want might want to replot OG. client_identifier is correlated to the individual plot kickoff, which contains if replotting is enabled or not
52
+ deletedPlot = self .replotting .deletePlot (self .destination_drive , self .client_identifier )
53
+ replottingEnabled = deletedPlot == None
54
+ if replottingEnabled :
55
+ if deletedPlot == False :
56
+ #might want to check HD space at this point. If none, we kick out. If there is still enough for the size of the plot let it continue.
57
+ placeHolder = "placeHolder"
50
58
51
59
parsed_phase = self .get_phase (line )
52
60
if parsed_phase != 0 :
@@ -88,7 +96,8 @@ class settings_config(object):
88
96
plotter_type = ""
89
97
pool_type = "OriginalPlot"
90
98
client_identifier = ""
91
-
99
+ replot = False
100
+
92
101
def __init__ (self , dictionary_config ):
93
102
self .drives = dictionary_config ["drives" ]
94
103
self .stagger_type = dictionary_config ['stagger_type' ]
@@ -105,13 +114,15 @@ def __init__(self, dictionary_config):
105
114
self .buckets = dictionary_config ['buckets' ]
106
115
self .pool_type = dictionary_config ['pool_type' ]
107
116
self .plotter_type = dictionary_config ['plotter_type' ]
117
+ self .replot = dictionary_config ['replot' ]
108
118
109
119
110
120
class plot_process_controller (object ):
111
121
list_of_plotting_processes = []
112
122
log_file_name = "log_file_"
113
123
active_plot_monitors = []
114
-
124
+ replotting = replotting ()
125
+
115
126
def add_monitor (self , monitor ):
116
127
self .active_plot_monitors .add (monitor )
117
128
@@ -163,7 +174,9 @@ def start_plot(self, config, plot_config, iteration):
163
174
164
175
plot_config ["parallel_plots" ] -= 1
165
176
166
- monitor = plot_process_monitor (proc , plot_config ["temp_drive" ], plot_config ["temp_drive_two" ], plot_config ["destination_drive" ], iteration , plot_config ["client_identifier" ])
177
+ #we check if enabled inside
178
+ self .replotting .addDrivePlots (plot_config ["destination_drive" ], plot_config ["client_identifier" ], config .replot )
179
+ monitor = plot_process_monitor (proc , plot_config ["temp_drive" ], plot_config ["temp_drive_two" ], plot_config ["destination_drive" ], plot_config ["client_identifier" ], self .replotting )
167
180
168
181
thread = threading .Thread (target = monitor .start_monitoring )
169
182
thread .daemon = True
@@ -219,12 +232,18 @@ def begin_mad_max_plot(self):
219
232
command = self .build_mad_max_command_safe ()
220
233
print ('#Beginning Temp Plot: ' + self .plotting_drives + ' Plotting to ' + self .final_drive + " using Chia Plotter" )
221
234
print ("Count: " + str (self .config .count ) + " Threads: " + str (self .config .threads ) + " Buckets: " + str (self .config .buckets ) + " TempDrive: " + str (self .plotting_drives ) + " Final Drive: " + str (self .final_drive ) + " Farm Key: " + self .config .farm_key + " Pool Key: " + self .config .pool_key )
222
- proc = subprocess .Popen (command , stdout = subprocess .PIPE , text = True )
235
+ try :
236
+ proc = subprocess .Popen (command , stdout = subprocess .PIPE , text = True )
237
+ except OSError as e :
238
+ raise Exception ('Please make sure you have permission to plot in the assigned directory, and that you have chia_plot in your PATH' )
223
239
return proc
224
240
225
241
def begin_chia_plot (self ):
226
242
command = self .build_chia_plot_command_safe ()
227
243
print ('#Beginning Temp Plot: ' + self .temp_drive + ' Plotting to ' + self .final_drive + " using Chia Plotter" )
228
244
print ("Count: " + str (self .config .count ) + " Ram: " + str (self .config .ram ) + " Threads: " + str (self .config .threads ) + " Size: " + str (self .config .size ) + " TempDrive: " + str (self .temp_drive ) + " Final Drive: " + str (self .final_drive ) + " Farm Key: " + self .config .farm_key + " Pool Key: " + self .config .pool_key )
229
- proc = subprocess .Popen (command , stdout = subprocess .PIPE , text = True )
245
+ try :
246
+ proc = subprocess .Popen (command , stdout = subprocess .PIPE , text = True )
247
+ except OSError as e :
248
+ raise Exception ('Please make sure you have permission to plot in the assigned directory, and that you have chia in your PATH' )
230
249
return proc
0 commit comments