Skip to content

Commit

Permalink
Merge pull request #9954 from gem/read_group
Browse files Browse the repository at this point in the history
Added `utils/read_group` to determine the memory required by a source group
  • Loading branch information
micheles authored Sep 13, 2024
2 parents a69b987 + b055a38 commit 5ffe904
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions utils/read_group
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 5ffe904

Please sign in to comment.