Commits

Srikrishna Sekhar authored 3e186222b97
CAS-14184 : Fix bug with parameter validation

Added a `return` statement in `gclean.update` so the parameter validation goes through to the GUI. `__init__` now raises a ValueError if the parameter validation fails.

casatasks/src/private/imagerhelpers/_gclean.py

Modified
145 145
146 146 if 'threshold' in msg:
147 147 self._threshold = msg['threshold']
148 148 self._threshold_to_float() # Convert str to float
149 149 if 'cyclefactor' in msg:
150 150 try:
151 151 self._cyclefactor = int(msg['cyclefactor'])
152 152 except ValueError:
153 153 pass
154 154
155 - self._validate_iteration_control_params()
155 + return self._validate_iteration_control_params()
156 156
157 157
158 158 def _validate_iteration_control_params(self):
159 159 """
160 160 Validate the iteration control parameters, and make sure that they make
161 161 sense, and are of the right types etc.
162 162 """
163 163
164 164 if not isinstance(self._niter, int):
165 165 return -1, f"niter must be an integer, not {type(self._niter)}"
304 304 # | | | | +----->>> Number of global iterations remaining for current run (niterleft)
305 305 # | | | +---------->>> Number of major cycles remaining for current run (nmajorleft)
306 306 # | | +---------------->>> major cycles done for current run (nmajordone)
307 307 # | +------------------>>> tclean stopcode
308 308 # +----------------------->>> tclean stopdescription
309 309
310 310 # Convert threshold from string to float, interpreting units.
311 311 # XXX : We should ideally use quantities, but we are trying to
312 312 # stick to "public API" funtions inside _gclean
313 313 self._threshold_to_float()
314 - self._validate_iteration_control_params()
314 + errcode, errdesc = self._validate_iteration_control_params()
315 +
316 + if errdesc != '':
317 + raise ValueError(errdesc)
315 318
316 319 def __add_per_major_items( self, tclean_ret, major_ret, chan_ret ):
317 320 '''Add meta-data about the whole major cycle, including 'cyclethreshold'
318 321 '''
319 322
320 323 if 'cyclethreshold' in tclean_ret:
321 324
322 325 rdict = dict( major=dict( cyclethreshold=[tclean_ret['cyclethreshold']] if major_ret is None else (major_ret['cyclethreshold'] + [tclean_ret['cyclethreshold']]) ),
323 326 chan=chan_ret )
324 327 else:

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut