Skip to content

Commit

Permalink
Small fixes for remote ingest
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed Sep 21, 2023
1 parent 88068ef commit f8d4d15
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/dev-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@ jobs:
DATABASE_URL: postgres://user:password@localhost:5432/readux
DJANGO_ENV: test
run: |
pytest apps/iiif/ --cov-report html --cov-report term --cov=./apps/iiif
pytest apps/export/ --cov-report html --cov-report term --cov=./apps/export
pytest apps/ingest/ --cov-report html --cov-report term --cov=./apps/ingest
pytest apps/readux/ --cov-report html --cov-report term --cov=./apps/readux
pytest apps/users/ --cov-report html --cov-report term --cov=./apps/users
pytest apps/iiif/
pytest apps/ingest/
pytest apps/readux/
pytest apps/users/
- name: Test Webpack build
run: |
Expand Down
6 changes: 4 additions & 2 deletions apps/ingest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ def create_canvases(self):
task_id=ocr_task_id,
task_result=ocr_task_result,
task_creator=self.creator,
filename=canvas.ocr_file_path
filename=canvas.ocr_file_path,
associated_manifest=self.manifest
)

# Request the thumbnail so a cached version is created on IIIF server.
Expand Down Expand Up @@ -624,7 +625,8 @@ def create_canvases_for(self, pid):
task_id=ocr_task_id,
task_result=ocr_task_result,
task_creator=self.creator,
filename=canvas.ocr_file_path
filename=canvas.ocr_file_path,
associated_manifest=manifest
)

# Request the thumbnail so a cached version is created on IIIF server.
Expand Down
12 changes: 11 additions & 1 deletion apps/ingest/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,34 @@


def clean_metadata(metadata):
print(metadata)
"""Remove keys that do not align with Manifest fields.
:param metadata:
:type metadata: tablib.Dataset
:return: Dictionary with keys matching Manifest fields
:rtype: dict
"""
metadata = {k.casefold().replace(' ', '_'): v for k, v in metadata.items()}
metadata = {key.casefold().replace(' ', '_'): value for key, value in metadata.items()}
fields = [f.name for f in Manifest._meta.get_fields()]
invalid_keys = []

for key in metadata.keys():
if key != 'metadata' and isinstance(metadata[key], list):
if isinstance(metadata[key][0], dict):
for meta_key in metadata[key][0].keys():
if 'value' in meta_key:
metadata[key] = metadata[key][0][meta_key]
else:
metadata[key] = ', '.join(metadata[key])
if key not in fields:
invalid_keys.append(key)

for invalid_key in invalid_keys:
metadata.pop(invalid_key)



return metadata

def create_manifest(ingest):
Expand Down
1 change: 1 addition & 0 deletions apps/ingest/tests/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def test_heidelberg_manifest(self):
assert remote.metadata['summary'] == "Nvovi Disegni Dell' Architettvre, E Piante De Palazzi Di Roma De Piv Celebri Architetti; Universitätsbibliothek Heidelberg, C 6426-2-10 GROSS RES"
assert remote.metadata['viewingdirection'] == 'left-to-right'
assert remote.metadata['logo_url'] == 'https://www.ub.uni-heidelberg.de/nav4/grafik/layout/ub_logo2.gif'
assert remote.metadata['author'] == 'Ferrerio, Pietro; Rossi, Giovanni Giacomo de [Editor]'
assert isinstance(remote.metadata['metadata'], list)

remote.create_canvases()
Expand Down

0 comments on commit f8d4d15

Please sign in to comment.