Skip to content

Commit 091ce48

Browse files
authored
Merge pull request #195 from cgs-earth/smapcheckpointfix
Smap checkpoint fix
2 parents e6ed065 + 9bebee9 commit 091ce48

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

SMAP_ETL/src/lib.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import logging
88
import os
99
from pathlib import Path
10+
import platform
11+
import resource
1012
from zoneinfo import ZoneInfo
1113

1214
import earthaccess
@@ -293,6 +295,20 @@ def append_hd5_to_s3_zarr(
293295
}
294296
}
295297

298+
# add a check for how much memory is in use
299+
# tracemalloc.start()
300+
301+
# current, _ = tracemalloc.get_traced_memory()
302+
# print(f"Current memory in use: {current} bytes")
303+
304+
usage = resource.getrusage(resource.RUSAGE_SELF)
305+
if platform.system() == "Darwin":
306+
rss_mb = usage.ru_maxrss / 1024 / 1024 # macOS: bytes
307+
else:
308+
rss_mb = usage.ru_maxrss / 1024 # Linux: kilobytes
309+
310+
print(f"Peak RSS: {rss_mb:.1f} MB")
311+
296312
if store_exists:
297313
ds.to_zarr(
298314
store=zarr_mapper,

SMAP_ETL/src/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
get_previously_downloaded_urls,
1717
get_smap_data_list_for_arizona,
1818
get_total_size_in_gb,
19+
update_checkpoint,
1920
)
2021
import minio
2122
import s3fs
@@ -109,6 +110,11 @@ def main(
109110
LOGGER.warning("Stopping early since test mode was specified")
110111
break
111112

113+
LOGGER.info(
114+
f"Updating checkpoint file with new file {hd5_file_path[0].name}"
115+
)
116+
update_checkpoint(mc, bucket, hd5_file_path[0].name)
117+
112118
LOGGER.info("Done!")
113119

114120

0 commit comments

Comments
 (0)