Skip to content

Commit

Permalink
post without parent-relationship if parent
Browse files Browse the repository at this point in the history
  • Loading branch information
contrick64 committed Dec 17, 2024
1 parent 721911e commit df44bd2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,25 @@ def ingest_files(

params["mods"] = json.dumps({"xml_data": mods_file_obj})

if parent_relationship:
(parent_pid, rel_type) = parent_relationship
if rel_type not in ['isPartOf', 'isTranslationOf', 'isTranscriptOf']:
raise ValueError(f"Invalid relationship type: {rel_type}")
# Read params['rels'] into a dict
temp_rels = json.loads(params["rels"])
if not parent_relationship:
pid = perform_post(api_url=env_vars["api_url"], params=params)
return pid

# Set the parent pid and page number
temp_rels[rel_type] = parent_pid
(parent_pid, rel_type) = parent_relationship
if rel_type not in ['isPartOf', 'isTranslationOf', 'isTranscriptOf']:
raise ValueError(f"Invalid relationship type: {rel_type}")
# Read params['rels'] into a dict
temp_rels = json.loads(params["rels"])

# Convert params['rels'] back to a string
params["rels"] = json.dumps(temp_rels)
# Set the parent pid and page number
temp_rels[rel_type] = parent_pid


pid = perform_post(api_url=env_vars["api_url"], params=params)
return pid
# Convert params['rels'] back to a string
params["rels"] = json.dumps(temp_rels)

if not file_path:
logging.warning(f"While ingesting, there's no file path for {mods_path.name}")
raise TypeError
logging.debug(f"ingesting {file_path}")

file = Path(file_path)
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def ingest_data(data, mods_dir):
# pid = '12345'
logging.info(f'ingested. {pid=}')

for child in row['children']:
for child in parent['children']:
if not child:
continue
logging.info(f'Ingesting {child["filename"]} with parent {pid}')
Expand Down

0 comments on commit df44bd2

Please sign in to comment.