From 3342f9a811b753a04d5f9e7f451abb03c80227ad Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Fri, 13 Sep 2024 09:28:13 +0200 Subject: [PATCH 1/2] Added utils/read_group to determine the memory required by a source group --- openquake/calculators/preclassical.py | 1 + utils/read_group | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 utils/read_group diff --git a/openquake/calculators/preclassical.py b/openquake/calculators/preclassical.py index 2a1d15b4c389..075e0aa7ffbd 100644 --- a/openquake/calculators/preclassical.py +++ b/openquake/calculators/preclassical.py @@ -151,6 +151,7 @@ def preclassical(srcs, sites, cmaker, secparams, monitor): else: cnt = 0 for msr, block in groupby(splits, msr_name).items(): + print('---------------------------------', msr) dic = grid_point_sources(block, spacing, msr, cnt, monitor) cnt = dic.pop('cnt') for src in dic[grp_id]: diff --git a/utils/read_group b/utils/read_group new file mode 100755 index 000000000000..20644e7c2036 --- /dev/null +++ b/utils/read_group @@ -0,0 +1,25 @@ +#!/usr/bin/env python +import zlib +import pickle +from openquake.baselib import sap, performance +from openquake.commonlib import datastore + + +def main(grp_id: int, calc_id: int=-1): + """ + Determine how much memory is needed to read a source group. + To be run after a (pre)classical calculation. + """ + dstore = datastore.read(115049) + with performance.Monitor(measuremem=True) as mon: + arr = dstore.getitem('_csm')[grp_id] + grp = pickle.loads(zlib.decompress(arr.tobytes())) + print(grp) + print(mon) + +main.grp_id = 'source group ID' +main.calc_id = 'calculation ID' + + +if __name__ == '__main__': + sap.run(main) From b055a386961ecfc85a6dcdc1c3460b657677c435 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Fri, 13 Sep 2024 09:31:41 +0200 Subject: [PATCH 2/2] Removed debug print [ci skip] --- openquake/calculators/preclassical.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openquake/calculators/preclassical.py b/openquake/calculators/preclassical.py index 075e0aa7ffbd..2a1d15b4c389 100644 --- a/openquake/calculators/preclassical.py +++ b/openquake/calculators/preclassical.py @@ -151,7 +151,6 @@ def preclassical(srcs, sites, cmaker, secparams, monitor): else: cnt = 0 for msr, block in groupby(splits, msr_name).items(): - print('---------------------------------', msr) dic = grid_point_sources(block, spacing, msr, cnt, monitor) cnt = dic.pop('cnt') for src in dic[grp_id]: