Commit 7cca2257 authored by eric pellegrini's avatar eric pellegrini

Bug fix when running multiproc run from the GUI on Windows

Added a specific logfile for each launched job
Improved the JobControllerPanel
Removed the global logfile toolbar button
Removed the 'info' JobStatus entry
Removed unused Plugin.has_parent method
Bug fixes
parent 925b4b4b
......@@ -36,6 +36,7 @@ import wx.aui as wxaui
from MDANSE.Externals.pubsub import pub as Publisher
from MDANSE.App.GUI.Icons import ICONS
from MDANSE.App.GUI.Framework import has_parent
from MDANSE.App.GUI.Framework.Plugins.ComponentPlugin import ComponentPlugin
class AnimationPlugin(ComponentPlugin):
......@@ -154,7 +155,7 @@ class AnimationPlugin(ComponentPlugin):
mv = message
if not self.has_parent(mv):
if not has_parent(self,mv):
return
frame = mv.current_frame
......@@ -177,8 +178,10 @@ class AnimationPlugin(ComponentPlugin):
def on_update_animation_icon(self, message):
mv = message
if not self.has_parent(mv):
if not has_parent(self,mv):
return
if mv.animation_loop:
......@@ -187,7 +190,9 @@ class AnimationPlugin(ComponentPlugin):
self.playPause.SetBitmapLabel(ICONS["play",32,32])
def on_set_up_frame_slider(self, message):
mv = message
if not self.has_parent(mv):
if not has_parent(self,mv):
return
self.frameSlider.SetRange(0,self._parent.n_frames-1)
\ No newline at end of file
......@@ -99,9 +99,6 @@ class DataPlugin(IPlugin):
plugin.plug()
plugin.SetFocus()
def has_parent(self, window):
return False
def on_changing_pane(self, event):
......
......@@ -106,12 +106,8 @@ class JobPlugin(ComponentPlugin):
t = tempfile.mkstemp(prefix = "MDANSE_%s_" % self._job.type, text = True)
os.close(t[0])
self._job.save_job(t[1], parameters)
self._job.configuration.set_parameters(parameters)
self._job.configuration.configure()
self._job.save(t[1], parameters)
if PLATFORM.name == "windows":
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
......@@ -119,7 +115,7 @@ class JobPlugin(ComponentPlugin):
else:
startupinfo = None
subprocess.Popen([sys.executable, t[1]], startupinfo=startupinfo)
subprocess.Popen([sys.executable, t[1]], startupinfo=startupinfo, stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(1)
......@@ -145,7 +141,7 @@ class JobPlugin(ComponentPlugin):
if os.path.splitext(path)[1] != ".py":
path += ".py"
self._job.save_job(path, parameters)
self._job.save(path, parameters)
def plug(self):
......
......@@ -35,7 +35,6 @@ import abc
import wx
from MDANSE import REGISTRY
from MDANSE.App.GUI.Framework.Plugins.IPlugin import IPlugin, plugin_parent
class IWidget(wx.Panel):
......@@ -89,16 +88,6 @@ class IWidget(wx.Panel):
def add_widgets(self):
pass
def has_parent(self, target):
if self == target:
return True
if self.TopLevelParent == self:
return False
return self.has_parent(self.Parent, target)
def build_panel(self):
self._staticBox = wx.StaticBox(self, wx.ID_ANY, label=self.label)
......
......@@ -38,6 +38,7 @@ from MDANSE.Externals.pubsub import pub
from MDANSE.Framework.Configurable import ConfigurationError
from MDANSE.App.GUI import DATA_CONTROLLER
from MDANSE.App.GUI.Framework import has_parent
from MDANSE.App.GUI.Framework.Widgets.IWidget import IWidget
class MMTKTrajectoryWidget(IWidget):
......@@ -71,7 +72,7 @@ class MMTKTrajectoryWidget(IWidget):
window, filename = message
if not self.has_parent(window):
if not has_parent(self,window):
return
data = DATA_CONTROLLER[filename].data
......
......@@ -38,6 +38,7 @@ from MDANSE.Externals.pubsub import pub
from MDANSE.Framework.Configurable import ConfigurationError
from MDANSE.App.GUI import DATA_CONTROLLER
from MDANSE.App.GUI.Framework import has_parent
from MDANSE.App.GUI.Framework.Widgets.IWidget import IWidget
class NetCDFInputWidget(IWidget):
......@@ -77,7 +78,7 @@ class NetCDFInputWidget(IWidget):
window, filename = message
if not self.has_parent(window):
if not has_parent(self,window):
return
self._netcdf = DATA_CONTROLLER[filename].netcdf
......
def has_parent(window, target):
if window == target:
return True
else:
return has_parent(window.Parent, target)
This diff is collapsed.
......@@ -38,10 +38,12 @@ from MDANSE import PLATFORM
class LogfileFrame(wx.Frame):
def __init__(self,parent,*args,**kwargs):
def __init__(self,parent,jobName,*args,**kwargs):
wx.Frame.__init__(self,parent,size=(800,500),*args,**kwargs)
self._logfile = os.path.join(PLATFORM.logfiles_directory(),jobName)+'.txt'
panel = wx.Panel(self,wx.ID_ANY)
sizer = wx.BoxSizer(wx.VERTICAL)
......@@ -61,12 +63,12 @@ class LogfileFrame(wx.Frame):
def update(self):
logfile = os.path.join(PLATFORM.application_directory(),"mdanse.log")
if os.path.exists(logfile):
with open(logfile,"r") as f:
self._logFileContents.SetValue(f.read())
try:
f = open(self._logfile,"r")
except IOError:
self._logFileContents.SetValue("Error opening %r file." % self._logfile)
else:
self._logFileContents.SetValue(f.read())
def on_update(self,event):
......
......@@ -145,7 +145,6 @@ class MainFrame(wx.Frame):
plotButton = self._toolbar.AddSimpleTool(wx.ID_ANY,ICONS["plot",32,32], 'Open MDANSE plotter')
udButton = self._toolbar.AddSimpleTool(wx.ID_ANY,ICONS["user",32,32], 'Edit the user definitions')
preferencesButton = self._toolbar.AddSimpleTool(wx.ID_ANY, ICONS["preferences",32,32], 'Edit the preferences')
logfileButton = self._toolbar.AddSimpleTool(wx.ID_ANY, ICONS["logfile",32,32], 'Display MDANSE log file')
registryButton = self._toolbar.AddSimpleTool(wx.ID_ANY, ICONS["registry",32,32], 'Inspect MDANSE classes registry')
helpButton = self._toolbar.AddSimpleTool(wx.ID_ANY, ICONS["help",32,32], 'Help')
websiteButton = self._toolbar.AddSimpleTool(wx.ID_ANY, ICONS["web",32,32], 'Open MDANSE website')
......@@ -162,7 +161,6 @@ class MainFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.on_open_mdanse_elements_database, databaseButton)
self.Bind(wx.EVT_MENU, self.on_start_plotter, plotButton)
self.Bind(wx.EVT_MENU, self.on_set_preferences, preferencesButton)
self.Bind(wx.EVT_MENU, self.on_display_logfile, logfileButton)
self.Bind(wx.EVT_MENU, self.on_open_user_definitions, udButton)
self.Bind(wx.EVT_MENU, self.on_open_classes_registry, registryButton)
self.Bind(wx.EVT_MENU, self.on_about, aboutButton)
......@@ -220,14 +218,6 @@ or directly to the MDANSE mailing list:
d.ShowModal()
d.Destroy()
def on_display_logfile(self,event):
from MDANSE.App.GUI.LogfileFrame import LogfileFrame
f = LogfileFrame(self)
f.Show()
def on_open_classes_registry(self,event):
from MDANSE.App.GUI.Framework.Plugins.RegistryViewerPlugin import RegistryViewerFrame
......
......@@ -288,6 +288,20 @@ class Platform(object):
'''
pass
def logfiles_directory(self):
'''
Returns the path of the directory where the MDANSE job logfiles are stored.
:return: the path of the directory where the MDANSE job logfiles are stored..
:rtype: str
'''
path = os.path.join(self.application_directory(), 'logfiles')
self.create_directory(path)
return path
def temporary_files_directory(self):
'''
Returns the path of the directory where the temporary MDANSE job status files are stored.
......
......@@ -81,6 +81,8 @@ import Pyro.naming
from Scientific.DistributedComputing.TaskManager import TaskManager, TaskManagerTermination
from MDANSE import PLATFORM
debug = False
class MasterProcessError(Exception):
......@@ -559,7 +561,7 @@ from %s import *
MDANSE.DistributedComputing.MasterSlave.startSlaveProcess()
"""
process.task_manager.storeData(slave_code = source,
cwd = os.getcwd())
cwd = PLATFORM.home_directory())
if debug:
print "Slave source code:"
print 50*'-'
......
......@@ -36,9 +36,9 @@ from MDANSE import PLATFORM
import Pyro
Pyro.config.PYRO_STORAGE = PLATFORM.home_directory()
Pyro.config.PYRO_NS_URIFILE = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_NS_URI')
Pyro.config.PYRO_LOGFILE = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_NS_URI')
Pyro.config.PYRO_USER_LOGFILE = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_NS_URI')
Pyro.config.PYROSSL_CERTDIR = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_NS_URI')
Pyro.config.PYRO_LOGFILE = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_log')
Pyro.config.PYRO_USER_LOGFILE = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_userlog')
Pyro.config.PYROSSL_CERTDIR = os.path.join(Pyro.config.PYRO_STORAGE,'certs')
# Define (or import) all the task handlers.
def do_run_step(job, step):
......
......@@ -75,12 +75,11 @@ class RunningModeConfigurator(IConfigurator):
import Pyro
Pyro.config.PYRO_STORAGE = PLATFORM.home_directory()
Pyro.config.PYRO_STORAGE = PLATFORM.home_directory()
Pyro.config.PYRO_NS_URIFILE = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_NS_URI')
Pyro.config.PYRO_LOGFILE = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_NS_URI')
Pyro.config.PYRO_USER_LOGFILE = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_NS_URI')
Pyro.config.PYROSSL_CERTDIR = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_NS_URI')
Pyro.config.PYRO_LOGFILE = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_log')
Pyro.config.PYRO_USER_LOGFILE = os.path.join(Pyro.config.PYRO_STORAGE,'Pyro_userlog')
Pyro.config.PYROSSL_CERTDIR = os.path.join(Pyro.config.PYRO_STORAGE,'certs')
slots = int(value[1])
......
......@@ -27,7 +27,7 @@
'''
Created on Mar 30, 2015
@author: pellegrini
@author: Eric C. Pellegrini
'''
import abc
......@@ -38,6 +38,7 @@ import stat
import string
import subprocess
import sys
import traceback
from MDANSE import LOGGER, PLATFORM, REGISTRY
from MDANSE.Core.Error import Error
......@@ -58,14 +59,26 @@ class JobError(Error):
:type job: IJob derived object
'''
trace = []
tback = traceback.extract_stack()
for tb in tback:
trace.append(' -- '.join([str(t) for t in tb]))
if message is None:
message = sys.exc_info()[1]
self._message = str(message)
trace.append("\n%s" % self._message)
trace = '\n'.join(trace)
LOGGER(trace,'error',[job._name])
if job._status is not None:
job._status._state["state"] = "crashed"
job._status._state["info"] += "ERROR: %s" % self._message
job._status._state["state"] = "aborted"
job._status.update(force=True)
def __str__(self):
......@@ -121,10 +134,12 @@ class IJob(Configurable):
"""
Configurable.__init__(self)
self._outputData = OutputData()
self._name = IJob.set_name()
LOGGER.add_handler(self._name, REGISTRY['handler']['logfile'](os.path.join(PLATFORM.logfiles_directory(),self._name)+'.txt'), level="info")
self._outputData = OutputData()
self._info = ""
......@@ -441,14 +456,14 @@ class IJob(Configurable):
try:
self.setup(parameters)
self.initialize()
self._info = 'Information about %s job.\n' % self._name
self._info += str(self)
LOGGER(self._info)
LOGGER(self._info,'info',[self._name])
if getattr(self,'numberOfSteps', 0) <= 0:
raise JobError(self,"Invalid number of steps for job %s" % self._name)
......
......@@ -27,7 +27,6 @@ class JobStatus(Status):
self._state['state'] = "running"
self._state['name'] = job.name
self._state['temporary_file'] = os.path.join(PLATFORM.temporary_files_directory(), self._state['name'])
self._state['info']=""
self.save_status()
......@@ -46,7 +45,7 @@ class JobStatus(Status):
return self._state
def cleanup(self):
try:
os.unlink(self._state['temporary_file'])
except:
......
......@@ -117,7 +117,7 @@ class MeanSquareDisplacement(IJob):
series = self.configuration['projection']["projector"](series)
msd = mean_square_displacement(series)
return index, msd
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment