@@ -44,6 +44,12 @@ def run_with_logging(dockercall, cmd, logger, printlog=True):
44
44
# save command to log
45
45
logger .info ("++ " + cmdstr + "\n " )
46
46
pipe = subprocess .Popen (shlex .split (cmdstr ), stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
47
+
48
+ # Maximum number of seconds to wait for "docker run" to finish after
49
+ # its child process exits. The observed times have been < 1 ms.
50
+ # Use a relatively large number to flag a possible problem with Docker.
51
+ timeout = 10
52
+
47
53
with pipe .stdout :
48
54
for line in iter (pipe .stdout .readline , b'' ): # b'\n'-separated lines
49
55
decoded = line .decode ("utf-8" )
@@ -52,6 +58,9 @@ def run_with_logging(dockercall, cmd, logger, printlog=True):
52
58
decoded = decoded [:- 1 ]
53
59
logger .info (decoded )
54
60
ret = pipe .poll ()
61
+ if ret is None :
62
+ ret = pipe .wait (timeout = timeout )
63
+ # ret will be None if exception TimeoutExpired was raised and caught.
55
64
if ret != 0 :
56
65
raise subprocess .CalledProcessError (ret , cmdstr )
57
66
@@ -223,8 +232,8 @@ def makedistrib(self):
223
232
224
233
def makedistrib_nisar (self ):
225
234
"""
226
- Install package to redistributable isce3 docker image with nisar qa and
227
- noise estimator caltool
235
+ Install package to redistributable isce3 docker image with nisar qa,
236
+ noise estimator caltool, and Soil Moisture applications
228
237
"""
229
238
230
239
build_args = f"--build-arg distrib_img={ self .imgname ()} \
@@ -327,7 +336,7 @@ def distribrun(self, testdir, cmd, logfile=None, dataname=None, nisarimg=False,
327
336
328
337
def workflowtest (self , wfname , testname , dataname , pyname , suf = "" , description = "" , arg = "" ):
329
338
"""
330
- Run the specified workflow test using the distrib image.
339
+ Run the specified workflow test using either the distrib or the nisar image.
331
340
332
341
Parameters
333
342
-------------
@@ -370,10 +379,21 @@ def workflowtest(self, wfname, testname, dataname, pyname, suf="", description="
370
379
shutil .copyfile (pjoin (runconfigdir , inputrunconfig ),
371
380
pjoin (testdir , f"runconfig_{ wfname } { suf } .yaml" ))
372
381
log = pjoin (testdir , f"output_{ wfname } { suf } " , "stdouterr.log" )
373
- cmd = [f"time python3 -m { pyname } { arg } runconfig_{ wfname } { suf } .yaml" ]
382
+
383
+ if not testname .startswith ("sm" ):
384
+ cmd = [f"time python3 -m { pyname } { arg } runconfig_{ wfname } { suf } .yaml" ]
385
+ else :
386
+ executable = pyname
387
+ cmd = [f"time { executable } runconfig_{ wfname } { suf } .yaml" ]
388
+
374
389
try :
375
- self .distribrun (testdir , cmd , logfile = log , dataname = dataname ,
376
- loghdlrname = f'wftest.{ os .path .basename (testdir )} ' )
390
+ if not testname .startswith ("sm" ):
391
+ self .distribrun (testdir , cmd , logfile = log , dataname = dataname ,
392
+ loghdlrname = f'wftest.{ os .path .basename (testdir )} ' )
393
+ else :
394
+ # Currently, the SM executables are in the nisar image.
395
+ self .distribrun (testdir , cmd , logfile = log , dataname = dataname , nisarimg = True ,
396
+ loghdlrname = f"wftest.{ os .path .basename (testdir )} " )
377
397
except subprocess .CalledProcessError as e :
378
398
raise RuntimeError (f"Workflow test { testname } failed" ) from e
379
399
@@ -481,6 +501,25 @@ def beamformtest(self, tests=None):
481
501
except subprocess .CalledProcessError as e :
482
502
raise RuntimeError (f"CalTool beamformer tool test { testname } failed" ) from e
483
503
504
+ def smtest (self , tests = None ):
505
+ if tests is None :
506
+ tests = workflowtests ['sm' ].items ()
507
+ for testname , dataname in tests :
508
+ # Note: we will eventually have multiple SM executables, each
509
+ # of which implements a different algorithm. These executables
510
+ # will run the same input test data. It's TBD whether they'll
511
+ # be able to share the same runconfig. The output files should
512
+ # be either written to different directories by executable or
513
+ # should be named to indicate which executable was used, or both.
514
+ #
515
+ # Also, the current plan is for two of the SM executables to be
516
+ # Fortran 90 binaries and the other two to be Python modules.
517
+ sm_bindir = '/opt/conda/envs/SoilMoisture/bin'
518
+ executables = [ 'NISAR_SM_DISAGG_SAS' ]
519
+ cmd = [ ]
520
+ for executable in executables :
521
+ self .workflowtest ("sm" , testname , dataname , f"{ sm_bindir } /{ executable } " )
522
+
484
523
def mintests (self ):
485
524
"""
486
525
Only run first test from each workflow
0 commit comments