Skip to content

Commit

Permalink
update ingest-records to use validate_record and submit_records endpo…
Browse files Browse the repository at this point in the history
…ints
  • Loading branch information
mbthornton-lbl committed Feb 13, 2024
1 parent 0abe536 commit 1c938e1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions nmdc_automation/re_iding/scripts/re_id_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def ingest_records(ctx, reid_records_file, changesheet_only):

# Get API client(s)
config = ctx.obj["site_config"]
api_client = NmdcRuntimeApi(config)
# api_client = NmdcRuntimeApi(config)
api_user_client = NmdcRuntimeUserApi(config)

with open(reid_records_file, "r") as f:
Expand Down Expand Up @@ -438,14 +438,22 @@ def ingest_records(ctx, reid_records_file, changesheet_only):

# submit the record to the workflows endpoint
if not changesheet_only:
resp = api_client.post_objects(record)
logging.info(f"{record} posted, got response: {resp}")
# validate the record
if api_user_client.validate_record(record):
logging.info("Workflow Record validated")
# submit the record
resp = api_user_client.submit_record(record)
# No response is returned if the record already exists
if resp:
logging.info(f"Record submitted with response: {resp}")
else:
logging.info(f"Record already exists")
else:
logging.info(f"changesheet_only is True, skipping ingest")

changesheet.write_changesheet()
logging.info(f"changesheet written to {changesheet.output_filepath}")
if changesheet.validate_changesheet(api_client.config.napa_base_url):
if changesheet.validate_changesheet(api_user_client.base_url):
logging.info(f"changesheet validated")
else:
logging.info(f"changesheet validation failed")
Expand Down

0 comments on commit 1c938e1

Please sign in to comment.