Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete large objects and data structs after use #329

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions nmdc_automation/run_process/run_import.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import click
import csv
import gc
import importlib.resources
from functools import lru_cache
import logging
Expand Down Expand Up @@ -70,6 +71,8 @@ def import_projects(import_file, import_yaml, site_configuration, iteration):
# validate the database
logger.info("Validating imported data")
db_dict = yaml.safe_load(yaml_dumper.dumps(db))
del db # free up memory
del do_mapping # free up memory
validation_report = linkml.validator.validate(db_dict, nmdc_materialized)
if validation_report.results:
logger.error(f"Validation Failed")
Expand All @@ -93,10 +96,13 @@ def import_projects(import_file, import_yaml, site_configuration, iteration):
logger.info("Posting data to the API")
try:
runtime.post_objects(db_dict)
del db_dict # free up memory
except Exception as e:
logger.error(f"Error posting data to the API: {e}")
raise e

gc.collect()




Expand Down
Loading