@@ -165,7 +165,6 @@ def __init__(self, langs=None, name=None):
165
165
self ._data_path = os .path .join (self ._root_path , 'data' )
166
166
self ._logs_path = os .path .join (self ._root_path , 'logs' )
167
167
self ._temp_path = os .path .join (self ._root_path , 'temp' )
168
- self .runtime_path = os .path .join (self ._root_path , 'runtime' )
169
168
170
169
self ._config_file = os .path .join (self ._root_path , 'engine.ini' )
171
170
self ._pt_model = os .path .join (self ._data_path , 'phrase_tables' )
@@ -218,23 +217,23 @@ def config(self):
218
217
self ._config .read (self ._config_file )
219
218
return self ._config
220
219
221
- def get_tempdir (self , name , ensure = True ):
222
- if ensure and not os .path .isdir (self ._temp_path ):
223
- fileutils .makedirs (self ._temp_path , exist_ok = True )
224
-
225
- folder = os .path .join (self ._temp_path , name )
226
-
227
- if ensure :
228
- shutil .rmtree (folder , ignore_errors = True )
229
- os .makedirs (folder )
230
-
231
- return folder
232
-
233
- def get_logfile (self , name , ensure = True ):
234
- if ensure and not os .path .isdir (self ._logs_path ):
235
- fileutils .makedirs (self ._logs_path , exist_ok = True )
236
-
237
- return os .path .join (self ._logs_path , name + '.log' )
220
+ # def get_tempdir(self, name, ensure=True):
221
+ # if ensure and not os.path.isdir(self._temp_path):
222
+ # fileutils.makedirs(self._temp_path, exist_ok=True)
223
+ #
224
+ # folder = os.path.join(self._temp_path, name)
225
+ #
226
+ # if ensure:
227
+ # shutil.rmtree(folder, ignore_errors=True)
228
+ # os.makedirs(folder)
229
+ #
230
+ # return folder
231
+ #
232
+ # def get_logfile(self, name, ensure=True):
233
+ # if ensure and not os.path.isdir(self._logs_path):
234
+ # fileutils.makedirs(self._logs_path, exist_ok=True)
235
+ #
236
+ # return os.path.join(self._logs_path, name + '.log')
238
237
239
238
def build (self , corpora , debug = False , steps = None ):
240
239
if len (corpora ) == 0 :
@@ -448,9 +447,13 @@ def __exit__(self, *_):
448
447
449
448
450
449
class MMTServer (_ProcessMonitor ):
451
- def __init__ (self , engine , api_port = None , cluster_ports = None ):
452
- _ProcessMonitor .__init__ (self , os .path .join (engine .runtime_path , 'master_pid' ))
450
+ def _get_runtimedir (self , ensure = True ):
451
+ path = os .path .join (scripts .RUNTIME_DIR , self .engine .name , 'master' )
452
+ if ensure :
453
+ os .makedirs (path )
454
+ return path
453
455
456
+ def __init__ (self , engine , api_port = None , cluster_ports = None ):
454
457
self ._mert_script = os .path .join (Moses .bin_path , 'scripts' , 'mert-moses.pl' )
455
458
self ._mert_i_script = os .path .join (scripts .MMT_ROOT , 'scripts' , 'mertinterface.py' )
456
459
@@ -461,6 +464,8 @@ def __init__(self, engine, api_port=None, cluster_ports=None):
461
464
self .log_file = engine .get_logfile ('mmtmaster' , ensure = False )
462
465
self .api = MMTServerApi (api_port )
463
466
467
+ _ProcessMonitor .__init__ (self , os .path .join (self ._get_runtimedir (), 'process.pid' ))
468
+
464
469
def _start_process (self ):
465
470
classpath = [scripts .MMT_JAR ]
466
471
@@ -548,7 +553,7 @@ def tune(self, corpora, tokenize=True, debug=False, context_enabled=True):
548
553
549
554
fileutils .makedirs (mert_wd , exist_ok = True )
550
555
551
- runtime_moses_ini = os .path .join (self .engine . runtime_path , 'moses.ini' )
556
+ runtime_moses_ini = os .path .join (self ._get_runtimedir ( ensure = False ) , 'moses.ini' )
552
557
command = [self ._mert_script , source_merged_corpus , target_merged_corpus ,
553
558
self ._mert_i_script , runtime_moses_ini , '--mertdir' , os .path .join (Moses .bin_path , 'bin' ),
554
559
'--mertargs' , '\' --binary --sctype BLEU\' ' , '--working-dir' , mert_wd ,
@@ -590,15 +595,21 @@ def tune(self, corpora, tokenize=True, debug=False, context_enabled=True):
590
595
591
596
592
597
class MMTWorker (_ProcessMonitor ):
593
- def __init__ (self , engine , cluster_ports , master = None ):
594
- _ProcessMonitor .__init__ (self , os .path .join (engine .runtime_path , 'slave_pid' ))
598
+ def _get_runtimedir (self , ensure = True ):
599
+ path = os .path .join (scripts .RUNTIME_DIR , self .engine .name , 'slave' )
600
+ if ensure :
601
+ os .makedirs (path )
602
+ return path
595
603
604
+ def __init__ (self , engine , cluster_ports , master = None ):
596
605
self .engine = engine
597
606
self .cluster_ports = cluster_ports
598
607
self ._master = master
599
608
600
609
self .log_file = engine .get_logfile ('mmtslave' , ensure = False )
601
610
611
+ _ProcessMonitor .__init__ (self , os .path .join (self ._get_runtimedir (), 'process.pid' ))
612
+
602
613
def _start_process (self ):
603
614
classpath = [scripts .MMT_JAR ]
604
615
0 commit comments