Changeset 839fd68 in sasmodels
- Timestamp:
- Sep 17, 2018 2:33:16 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 91bd550
- Parents:
- 2c12061
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/custom/__init__.py
r0f48f1e r839fd68 37 37 return module 38 38 39 _MODULE_CACHE = {} 39 40 def load_custom_kernel_module(path): 40 41 """load SAS kernel from *path* as *sasmodels.custom.modelname*""" 41 42 # Pull off the last .ext if it exists; there may be others 42 43 name = basename(splitext(path)[0]) 43 # Placing the model in the 'sasmodels.custom' name space. 44 kernel_module = load_module_from_path('sasmodels.custom.'+name, 45 os.path.expanduser(path)) 46 return kernel_module 44 path = os.path.expanduser(path) 45 timestamp = os.path.getmtime(path) 46 module, cache_time = _MODULE_CACHE.get(path, (None, -1)) 47 if cache_time < timestamp: 48 # Placing the model in the 'sasmodels.custom' name space. 49 module = load_module_from_path('sasmodels.custom.'+name, path) 50 _MODULE_CACHE[path] = module, timestamp 51 52 return module -
sasmodels/sasview_model.py
rd533590 r839fd68 62 62 #: set of defined models (standard and custom) 63 63 MODELS = {} # type: Dict[str, SasviewModelType] 64 # TODO: remove unused MODEL_BY_PATH cache once sasview no longer references it 64 65 #: custom model {path: model} mapping so we can check timestamps 65 66 MODEL_BY_PATH = {} # type: Dict[str, SasviewModelType] … … 106 107 Load a custom model given the model path. 107 108 """ 108 model = MODEL_BY_PATH.get(path, None)109 if model is not None and model.timestamp == getmtime(path):110 #logger.info("Model already loaded %s", path)111 return model112 113 109 #logger.info("Loading model %s", path) 114 110 kernel_module = custom.load_custom_kernel_module(path) … … 127 123 model_info = modelinfo.make_model_info(kernel_module) 128 124 model = make_model_from_info(model_info) 129 model.timestamp = getmtime(path)130 125 131 126 # If a model name already exists and we are loading a different model, … … 144 139 145 140 MODELS[model.name] = model 146 MODEL_BY_PATH[path] = model147 141 return model 148 142
Note: See TracChangeset
for help on using the changeset viewer.