Updated logic for importing models to catch failures in data spec definition
@@ -757,15 +757,23 @@ class Network(Layer):
# run action with dataSpec option
with sw.option_context(print_messages = False):
rt = self._retrieve_('deeplearn.dlimportmodelweights',
- message_level='NONE',
model=self.model_table,
modelWeights=dict(replace=True, name=self.model_name + '_weights'),
dataSpecs=data_spec,
formatType=format_type, weightFilePath=file_name, caslib=cas_lib_name,
);
- # if error, no dataspec support
+ # if error, may not support dataspec
if rt.severity > 1:
+
+ # check for error containing "dataSpecs"
+ data_spec_missing = False
+ for msg in rt.messages:
+ if ('ERROR' in msg) and ('dataSpecs' in msg):
+ data_spec_missing = True
+
+ if data_spec_missing:
+ with sw.option_context(print_messages = False):
rt = self._retrieve_('deeplearn.dlimportmodelweights', model=self.model_table,
modelWeights=dict(replace=True,
name=self.model_name + '_weights'),
@@ -828,7 +836,6 @@ class Network(Layer):
# run action with dataSpec option
with sw.option_context(print_messages = False):
rt = self._retrieve_('deeplearn.dlimportmodelweights',
- message_level='NONE',
model=self.model_table,
modelWeights=dict(replace=True, name=self.model_name + '_weights'),
dataSpecs=data_spec,
@@ -836,8 +843,17 @@ class Network(Layer):
labelTable=label_table,
);
- # if error, no dataspec support
+ # if error, may not support dataspec
if rt.severity > 1:
+
+ # check for error containing "dataSpecs"
+ data_spec_missing = False
+ for msg in rt.messages:
+ if ('ERROR' in msg) and ('dataSpecs' in msg):
+ data_spec_missing = True
+
+ if data_spec_missing:
+ with sw.option_context(print_messages = False):
rt = self._retrieve_('deeplearn.dlimportmodelweights', model=self.model_table,
modelWeights=dict(replace=True, name=self.model_name + '_weights'),
formatType=format_type, weightFilePath=file_name, caslib=cas_lib_name,
