From ad70512b3e40b65788b775c7560335d300ff02ac Mon Sep 17 00:00:00 2001 From: Sam Gillingham Date: Thu, 4 Jul 2024 22:48:08 +0000 Subject: [PATCH] fixes and tidy --- .../awsbatch/template/template.yaml | 4 ++-- pyshepseg/tilingstats.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/parallel_examples/awsbatch/template/template.yaml b/parallel_examples/awsbatch/template/template.yaml index 92d8873..50e9f78 100644 --- a/parallel_examples/awsbatch/template/template.yaml +++ b/parallel_examples/awsbatch/template/template.yaml @@ -190,8 +190,8 @@ Resources: JobDefinitionName: PyShepSegBatchJobDefinitionStitch ContainerProperties: Image: !Join ['', [!GetAtt BatchRepository.RepositoryUri, ":latest"]] - Vcpus: 2 - Memory: 24000 + Vcpus: 4 + Memory: 12000 RetryStrategy: Attempts: 1 BatchProcessingJobQueue: diff --git a/pyshepseg/tilingstats.py b/pyshepseg/tilingstats.py index 5910e1e..72f867b 100644 --- a/pyshepseg/tilingstats.py +++ b/pyshepseg/tilingstats.py @@ -286,7 +286,9 @@ def calcPerSegmentStatsTiledRIOS(imgfile, imgbandnum, segfile, del imgds controls = applier.ApplierControls() - controls.selectInputImageLayers([imgbandnum], imgfile) + controls.selectInputImageLayers([imgbandnum], 'imgfile') + # RIOS default is 256x256. This leads to too many incomplete + # segments and increases memory use dramatically. controls.setWindowSize(tiling.TILESIZE, tiling.TILESIZE) # now create a new temporary file for saving the new columns too @@ -329,8 +331,9 @@ def calcPerSegmentStatsTiledRIOS(imgfile, imgbandnum, segfile, otherArgs.numIntCols = numIntCols otherArgs.numFloatCols = numFloatCols - applier.apply(rioscalcPerSegmentStatsTiled, inputs, outputs, + rtn = applier.apply(rioscalcPerSegmentStatsTiled, inputs, outputs, controls=controls, otherArgs=otherArgs) + print(rtn.timings.formatReport()) del tempKEAAttrTbl del tempKEABand @@ -341,7 +344,6 @@ def calcPerSegmentStatsTiledRIOS(imgfile, imgbandnum, segfile, raise PyShepSegStatsError('Not all pixels found during processing') # now merge the stats from the tempfile band info segfile - print('copying RAT') ratapplier.copyRAT(tempKEA, segfile) @@ -1418,7 +1420,9 @@ def calcPerSegmentSpatialStatsTiledRIOS(imgfile, imgbandnum, segfile, del imgds controls = applier.ApplierControls() - controls.selectInputImageLayers([imgbandnum], imgfile) + controls.selectInputImageLayers([imgbandnum], 'imgfile') + # RIOS default is 256x256. This leads to too many incomplete + # segments and increases memory use dramatically. controls.setWindowSize(tiling.TILESIZE, tiling.TILESIZE) # now create a new temporary file for saving the new columns too @@ -1463,8 +1467,9 @@ def calcPerSegmentSpatialStatsTiledRIOS(imgfile, imgbandnum, segfile, otherArgs.userFunc = userFunc otherArgs.userParam = userParam - applier.apply(rioscalcPerSegmentSpatialStatsTiled, inputs, outputs, + rtn = applier.apply(rioscalcPerSegmentSpatialStatsTiled, inputs, outputs, controls=controls, otherArgs=otherArgs) + print(rtn.timings.formatReport()) del tempKEAAttrTbl del tempKEABand @@ -1475,7 +1480,6 @@ def calcPerSegmentSpatialStatsTiledRIOS(imgfile, imgbandnum, segfile, raise PyShepSegStatsError('Not all pixels found during processing') # now merge the stats from the tempfile band info segfile - print('copying RAT') ratapplier.copyRAT(tempKEA, segfile)