Changeset fef38e8 in sasview


Ignore:
Timestamp:
Sep 13, 2017 6:24:34 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
3c8242c
Parents:
9909967
Message:

Startup time improvements - hiding expensive imports and such

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sasview/cx_setup.py

    r9909967 rfef38e8  
    7272data_files.append("test/") 
    7373data_files.append("plugin_models/") 
     74data_files.append("compiled_models/") 
    7475 
    7576def append_data(tups): 
  • src/sas/qtgui/Calculators/GenericScatteringCalculator.py

    r4d1eff2 rfef38e8  
    88from PyQt4 import QtCore 
    99from twisted.internet import threads 
    10 from mpl_toolkits.mplot3d import Axes3D 
    1110 
    1211import sas.qtgui.Utilities.GuiUtils as GuiUtils 
    13  
    1412from sas.qtgui.Utilities.GenericReader import GenReader 
    15  
    1613from sas.sascalc.dataloader.data_info import Detector 
    1714from sas.sascalc.dataloader.data_info import Source 
    1815from sas.sascalc.calculator import sas_gen 
    19  
    20 from sas.qtgui.Plotting.Arrow3D import Arrow3D 
    2116from sas.qtgui.Plotting.PlotterBase import PlotterBase 
    2217from sas.qtgui.Plotting.Plotter2D import Plotter2D 
    2318from sas.qtgui.Plotting.Plotter import Plotter 
     19 
    2420from sas.qtgui.Plotting.PlotterData import Data1D 
    2521from sas.qtgui.Plotting.PlotterData import Data2D 
     
    704700        if data is None: 
    705701            return 
     702        # This import takes forever - place it here so the main UI starts faster 
     703        from mpl_toolkits.mplot3d import Axes3D 
    706704        color_dic = {'H': 'blue', 'D': 'purple', 'N': 'orange', 
    707705                     'O': 'red', 'C': 'green', 'P': 'cyan', 'Other': 'k'} 
     
    781779        if has_arrow and len(pos_x) > 0: 
    782780            def _draw_arrow(input=None, update=None): 
     781                # import moved here for performance reasons 
     782                from sas.qtgui.Plotting.Arrow3D import Arrow3D 
    783783                """ 
    784784                draw magnetic vectors w/arrow 
  • src/sas/qtgui/MainWindow/DataExplorer.py

    r38eb433 rfef38e8  
    451451        model = self.model if plot_to_show.is_data else self.theory_model 
    452452        plots = GuiUtils.plotsFromFilename(filename, model) 
    453         _ = [self.plotData([(None, plot)]) for plot in plots] 
     453        for plot in plots: 
     454            plot_id = plot.id 
     455            if plot_id in self.active_plots.keys(): 
     456                self.active_plots[plot_id].replacePlot(plot_id, plot_to_show) 
     457            else: 
     458                self.plotData([(None, plot)]) 
    454459 
    455460    def addDataPlot2D(self, plot_set, item): 
  • src/sas/qtgui/MainWindow/GuiManager.py

    rb0c5e8c rfef38e8  
    1111 
    1212from twisted.internet import reactor 
    13  
    1413# General SAS imports 
    1514from sas.qtgui.Utilities.ConnectionProxy import ConnectionProxy 
    1615from sas.qtgui.Utilities.SasviewLogger import XStream 
    17 from sas.qtgui.Utilities.IPythonWidget import IPythonWidget 
     16 
    1817import sas.qtgui.Utilities.LocalConfig as LocalConfig 
    1918import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     19 
    2020import sas.qtgui.Utilities.ObjectLibrary as ObjectLibrary 
    21  
    2221from sas.qtgui.MainWindow.UI.AcknowledgementsUI import Ui_Acknowledgements 
    2322from sas.qtgui.MainWindow.AboutBox import AboutBox 
    2423from sas.qtgui.MainWindow.WelcomePanel import WelcomePanel 
     24 
    2525from sas.qtgui.MainWindow.DataManager import DataManager 
    2626 
     
    9696        self._helpView = QtWebKit.QWebView() 
    9797        # Needs URL like path, so no path.join() here 
     98        GuiUtils._init() 
    9899        self._helpLocation = GuiUtils.HELP_DIRECTORY_LOCATION + "/index.html" 
    99100 
     
    568569        Display the Jupyter console as a docked widget. 
    569570        """ 
     571        # Import moved here for startup performance reasons 
     572        from sas.qtgui.Utilities.IPythonWidget import IPythonWidget 
    570573        terminal = IPythonWidget() 
    571574 
  • src/sas/qtgui/Plotting/Fittings.py

    • Property mode changed from 100755 to 100644
    rdc5ef15 rfef38e8  
    1414 
    1515""" 
    16 from scipy import optimize 
    17  
    18  
    1916class Parameter(object): 
    2017    """ 
     
    8481            sum += item * item 
    8582        return sum 
    86  
     83    # This import takes a long time, which is why it's here not in the top of file 
     84    from scipy.optimize import leastsq 
    8785    p = [param() for param in pars] 
     86    #out, cov_x, info, mesg, success = optimize.leastsq(f, p, full_output=1) 
    8887    out, cov_x, info, mesg, success = optimize.leastsq(f, p, full_output=1) 
    8988    # Calculate chi squared 
  • src/sas/qtgui/Plotting/Plotter.py

    rdc5ef15 rfef38e8  
    33import functools 
    44import copy 
    5  
    65import matplotlib.pyplot as plt 
    76from matplotlib.font_manager import FontProperties 
    8  
    97from sas.qtgui.Plotting.PlotterData import Data1D 
    10  
    118from sas.qtgui.Plotting.PlotterBase import PlotterBase 
    129from sas.qtgui.Plotting.AddText import AddText 
     
    390387        Deletes the selected plot from the chart 
    391388        """ 
    392         if id not in self.plot_dict: 
     389        if id not in self.plot_dict.keys(): 
    393390            return 
    394391 
  • src/sas/qtgui/Utilities/GuiUtils.py

    r38eb433 rfef38e8  
    1818 
    1919from periodictable import formula as Formula 
    20  
    2120from sas.qtgui.Plotting import DataTransform 
    2221from sas.qtgui.Plotting.ConvertUnits import convertUnit 
    23  
    2422from sas.qtgui.Plotting.PlotterData import Data1D 
    2523from sas.qtgui.Plotting.PlotterData import Data2D 
    26  
    2724from sas.sascalc.dataloader.loader import Loader 
    2825from sas.qtgui.Utilities import CustomDir 
    2926 
     27## TODO: CHANGE FOR SHIPPED PATH IN RELEASE 
     28if os.path.splitext(sys.argv[0])[1].lower() != ".py": 
     29        HELP_DIRECTORY_LOCATION = "doc" 
     30else: 
     31        HELP_DIRECTORY_LOCATION = "docs/sphinx-docs/build/html" 
     32IMAGES_DIRECTORY_LOCATION = HELP_DIRECTORY_LOCATION + "/_images" 
    3033 
    3134def get_app_dir(): 
     
    9194    return config_module 
    9295 
    93 # Get APP folder 
    94 PATH_APP = get_app_dir() 
    95 DATAPATH = PATH_APP 
    96  
    97 ## TODO: CHANGE FOR SHIPPED PATH IN RELEASE 
    98 if os.path.splitext(sys.argv[0])[1].lower() != ".py": 
    99      HELP_DIRECTORY_LOCATION = "doc" 
    100 else: 
    101      HELP_DIRECTORY_LOCATION = "docs/sphinx-docs/build/html" 
    102 IMAGES_DIRECTORY_LOCATION = HELP_DIRECTORY_LOCATION + "/_images" 
    103  
    104 # GUI always starts from the App folder 
    105 #os.chdir(PATH_APP) 
    106 # Read in the local config, which can either be with the main 
    107 # application or in the installation directory 
    108 config = _find_local_config('local_config', PATH_APP) 
    109  
    110 if config is None: 
    111     config = _find_local_config('local_config', os.getcwd()) 
    112     #if config is None: 
    113     #    # Didn't find local config, load the default 
    114     #    import sas.sasgui.guiframe.config as config 
    115     #    #logging.info("using default local_config") 
    116     #else: 
    117     #    pass 
    118     #    #logging.info("found local_config in %s", os.getcwd()) 
    119 else: 
    120     pass 
    121     #logging.info("found local_config in %s", PATH_APP) 
    122  
    123 c_conf_dir = CustomDir.setup_conf_dir(PATH_APP) 
    124  
    125 custom_config = _find_local_config('custom_config', c_conf_dir) 
    126 if custom_config is None: 
    127     custom_config = _find_local_config('custom_config', os.getcwd()) 
    128     if custom_config is None: 
    129         msgConfig = "Custom_config file was not imported" 
    130         #logging.info(msgConfig) 
     96def _init(): 
     97    # Get APP folder 
     98    PATH_APP = get_app_dir() 
     99    DATAPATH = PATH_APP 
     100 
     101    # Read in the local config, which can either be with the main 
     102    # application or in the installation directory 
     103    config = _find_local_config('local_config', PATH_APP) 
     104 
     105    if config is None: 
     106        config = _find_local_config('local_config', os.getcwd()) 
    131107    else: 
    132108        pass 
    133         #logging.info("using custom_config in %s", os.getcwd()) 
    134 else: 
    135     pass 
    136     #logging.info("using custom_config from %s", c_conf_dir) 
    137  
    138 #read some constants from config 
    139 APPLICATION_STATE_EXTENSION = config.APPLICATION_STATE_EXTENSION 
    140 APPLICATION_NAME = config.__appname__ 
    141 SPLASH_SCREEN_PATH = config.SPLASH_SCREEN_PATH 
    142 WELCOME_PANEL_ON = config.WELCOME_PANEL_ON 
    143 SPLASH_SCREEN_WIDTH = config.SPLASH_SCREEN_WIDTH 
    144 SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 
    145 SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 
    146 if not WELCOME_PANEL_ON: 
    147     WELCOME_PANEL_SHOW = False 
    148 else: 
    149     WELCOME_PANEL_SHOW = True 
    150 try: 
    151     DATALOADER_SHOW = custom_config.DATALOADER_SHOW 
    152     TOOLBAR_SHOW = custom_config.TOOLBAR_SHOW 
    153     FIXED_PANEL = custom_config.FIXED_PANEL 
    154     if WELCOME_PANEL_ON: 
    155         WELCOME_PANEL_SHOW = custom_config.WELCOME_PANEL_SHOW 
    156     PLOPANEL_WIDTH = custom_config.PLOPANEL_WIDTH 
    157     DATAPANEL_WIDTH = custom_config.DATAPANEL_WIDTH 
    158     GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH 
    159     GUIFRAME_HEIGHT = custom_config.GUIFRAME_HEIGHT 
    160     CONTROL_WIDTH = custom_config.CONTROL_WIDTH 
    161     CONTROL_HEIGHT = custom_config.CONTROL_HEIGHT 
    162     DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE 
    163     CLEANUP_PLOT = custom_config.CLEANUP_PLOT 
    164     # custom open_path 
    165     open_folder = custom_config.DEFAULT_OPEN_FOLDER 
    166     if open_folder != None and os.path.isdir(open_folder): 
    167         DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 
     109 
     110    c_conf_dir = CustomDir.setup_conf_dir(PATH_APP) 
     111 
     112    custom_config = _find_local_config('custom_config', c_conf_dir) 
     113    if custom_config is None: 
     114        custom_config = _find_local_config('custom_config', os.getcwd()) 
     115        if custom_config is None: 
     116            msgConfig = "Custom_config file was not imported" 
     117 
     118    #read some constants from config 
     119    APPLICATION_STATE_EXTENSION = config.APPLICATION_STATE_EXTENSION 
     120    APPLICATION_NAME = config.__appname__ 
     121    SPLASH_SCREEN_PATH = config.SPLASH_SCREEN_PATH 
     122    WELCOME_PANEL_ON = config.WELCOME_PANEL_ON 
     123    SPLASH_SCREEN_WIDTH = config.SPLASH_SCREEN_WIDTH 
     124    SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 
     125    SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 
     126    if not WELCOME_PANEL_ON: 
     127        WELCOME_PANEL_SHOW = False 
    168128    else: 
     129        WELCOME_PANEL_SHOW = True 
     130    try: 
     131        DATALOADER_SHOW = custom_config.DATALOADER_SHOW 
     132        TOOLBAR_SHOW = custom_config.TOOLBAR_SHOW 
     133        FIXED_PANEL = custom_config.FIXED_PANEL 
     134        if WELCOME_PANEL_ON: 
     135            WELCOME_PANEL_SHOW = custom_config.WELCOME_PANEL_SHOW 
     136        PLOPANEL_WIDTH = custom_config.PLOPANEL_WIDTH 
     137        DATAPANEL_WIDTH = custom_config.DATAPANEL_WIDTH 
     138        GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH 
     139        GUIFRAME_HEIGHT = custom_config.GUIFRAME_HEIGHT 
     140        CONTROL_WIDTH = custom_config.CONTROL_WIDTH 
     141        CONTROL_HEIGHT = custom_config.CONTROL_HEIGHT 
     142        DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE 
     143        CLEANUP_PLOT = custom_config.CLEANUP_PLOT 
     144        # custom open_path 
     145        open_folder = custom_config.DEFAULT_OPEN_FOLDER 
     146        if open_folder != None and os.path.isdir(open_folder): 
     147            DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 
     148        else: 
     149            DEFAULT_OPEN_FOLDER = PATH_APP 
     150    except AttributeError: 
     151        DATALOADER_SHOW = True 
     152        TOOLBAR_SHOW = True 
     153        FIXED_PANEL = True 
     154        WELCOME_PANEL_SHOW = False 
     155        PLOPANEL_WIDTH = config.PLOPANEL_WIDTH 
     156        DATAPANEL_WIDTH = config.DATAPANEL_WIDTH 
     157        GUIFRAME_WIDTH = config.GUIFRAME_WIDTH 
     158        GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT 
     159        CONTROL_WIDTH = -1 
     160        CONTROL_HEIGHT = -1 
     161        DEFAULT_PERSPECTIVE = None 
     162        CLEANUP_PLOT = False 
    169163        DEFAULT_OPEN_FOLDER = PATH_APP 
    170 except AttributeError: 
    171     DATALOADER_SHOW = True 
    172     TOOLBAR_SHOW = True 
    173     FIXED_PANEL = True 
    174     WELCOME_PANEL_SHOW = False 
    175     PLOPANEL_WIDTH = config.PLOPANEL_WIDTH 
    176     DATAPANEL_WIDTH = config.DATAPANEL_WIDTH 
    177     GUIFRAME_WIDTH = config.GUIFRAME_WIDTH 
    178     GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT 
    179     CONTROL_WIDTH = -1 
    180     CONTROL_HEIGHT = -1 
    181     DEFAULT_PERSPECTIVE = None 
    182     CLEANUP_PLOT = False 
    183     DEFAULT_OPEN_FOLDER = PATH_APP 
    184  
    185 #DEFAULT_STYLE = config.DEFAULT_STYLE 
    186  
    187 PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS 
    188 OPEN_SAVE_MENU = config.OPEN_SAVE_PROJECT_MENU 
    189 VIEW_MENU = config.VIEW_MENU 
    190 EDIT_MENU = config.EDIT_MENU 
    191 extension_list = [] 
    192 if APPLICATION_STATE_EXTENSION is not None: 
    193     extension_list.append(APPLICATION_STATE_EXTENSION) 
    194 EXTENSIONS = PLUGIN_STATE_EXTENSIONS + extension_list 
    195 try: 
    196     PLUGINS_WLIST = '|'.join(config.PLUGINS_WLIST) 
    197 except AttributeError: 
    198     PLUGINS_WLIST = '' 
    199 APPLICATION_WLIST = config.APPLICATION_WLIST 
    200 IS_WIN = True 
    201 IS_LINUX = False 
    202 CLOSE_SHOW = True 
    203 TIME_FACTOR = 2 
    204 NOT_SO_GRAPH_LIST = ["BoxSum"] 
     164 
     165    #DEFAULT_STYLE = config.DEFAULT_STYLE 
     166 
     167    PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS 
     168    OPEN_SAVE_MENU = config.OPEN_SAVE_PROJECT_MENU 
     169    VIEW_MENU = config.VIEW_MENU 
     170    EDIT_MENU = config.EDIT_MENU 
     171    extension_list = [] 
     172    if APPLICATION_STATE_EXTENSION is not None: 
     173        extension_list.append(APPLICATION_STATE_EXTENSION) 
     174    EXTENSIONS = PLUGIN_STATE_EXTENSIONS + extension_list 
     175    try: 
     176        PLUGINS_WLIST = '|'.join(config.PLUGINS_WLIST) 
     177    except AttributeError: 
     178        PLUGINS_WLIST = '' 
     179    APPLICATION_WLIST = config.APPLICATION_WLIST 
     180    IS_WIN = True 
     181    IS_LINUX = False 
     182    CLOSE_SHOW = True 
     183    TIME_FACTOR = 2 
     184    NOT_SO_GRAPH_LIST = ["BoxSum"] 
    205185 
    206186class Communicate(QtCore.QObject): 
  • src/sas/qtgui/Utilities/IPythonWidget.py

    r985ad94 rfef38e8  
     1from PyQt4 import QtCore, QtGui, QtSvg 
     2 
    13def new_load_qt(api_options): 
    2     from PyQt4 import QtCore, QtGui, QtSvg 
    34    return QtCore, QtGui, QtSvg, 'pyqt' 
    45 
    56def qtconsole_new_load_qt(api_options): 
    6     from PyQt4 import QtCore, QtGui, QtSvg 
    7  
    87    # Alias PyQt-specific functions for PySide compatibility. 
    98    QtCore.Signal = QtCore.pyqtSignal 
     
    1110    return QtCore, QtGui, QtSvg, 'pyqt' 
    1211 
     12from IPython.external import  qt_loaders 
     13from qtconsole import qt_loaders as qtconsole_qt_loaders 
    1314# Do some monkey patching to satisfy pyinstaller complaining 
    1415# about pyside/pyqt confusion 
    15 from IPython.external import  qt_loaders 
    1616qt_loaders.load_qt = new_load_qt 
    17  
    18 from qtconsole import qt_loaders as qtconsole_qt_loaders 
    1917qtconsole_qt_loaders.load_qt = qtconsole_new_load_qt 
    2018 
    21  
    2219from qtconsole.rich_jupyter_widget import RichJupyterWidget 
    23 from qtconsole.inprocess import QtInProcessKernelManager 
    24 from IPython.lib import guisupport 
    2520 
    2621MODULES_TO_IMPORT = [ 
     
    3227    def __init__(self, parent=None, **kwargs): 
    3328        super(self.__class__, self).__init__(parent) 
     29        from qtconsole.inprocess import QtInProcessKernelManager 
     30        from IPython.lib import guisupport 
    3431        app = guisupport.get_app_qt4() 
    3532 
    36        # Create an in-process kernel 
     33        # Create an in-process kernel 
    3734        kernel_manager = QtInProcessKernelManager() 
    3835        kernel_manager.start_kernel() 
Note: See TracChangeset for help on using the changeset viewer.