From a823dc3b15b23e95b8e5cb3e1cf43e6294756515 Mon Sep 17 00:00:00 2001 From: Hillel Arnold Date: Mon, 21 Oct 2024 16:10:33 -0400 Subject: [PATCH 1/2] add case for tiffs in master dir --- create_derivatives/routines.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/create_derivatives/routines.py b/create_derivatives/routines.py index 3f6c162..e5e2554 100644 --- a/create_derivatives/routines.py +++ b/create_derivatives/routines.py @@ -158,8 +158,11 @@ def get_tiff_file_paths(self, bag_path): tiff_files (list of pathlib.Paths): absolute filepaths for TIFF files. """ service_dir = Path(bag_path, "data", "service") - if service_dir.is_dir() and any(service_dir.iterdir()): - tiff_files_dir = Path(bag_path, "data", "service") + master_dir = Path(bag_path, "data", "master") + for tiff_dir in service_dir, master_dir: + if tiff_dir.is_dir() and any(tiff_dir.iterdir()): + tiff_files_dir = tiff_dir + break else: tiff_files_dir = Path(bag_path, "data") return matching_files(tiff_files_dir, prepend=True) From 0c1ae96554fbff83416eb8e785a93a46f803b275 Mon Sep 17 00:00:00 2001 From: Hillel Arnold Date: Mon, 21 Oct 2024 16:11:02 -0400 Subject: [PATCH 2/2] update tests and fixtures --- .../3aai9usY3AZzCSFkB3RSQ9/bag-info.txt | 17 +++++++++++++++++ .../3aai9usY3AZzCSFkB3RSQ9/bagit.txt | 2 ++ .../master}/file_example_TIFF_10MB_001.tif | Bin .../data/master}/file_example_TIFF_1MB_001.tif | Bin .../data/master}/file_example_TIFF_5MB_001.tif | Bin .../3aai9usY3AZzCSFkB3RSQ9/manifest-md5.txt | 1 + .../3aai9usY3AZzCSFkB3RSQ9/tagmanifest-md5.txt | 3 +++ create_derivatives/tests.py | 12 +++++++----- 8 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/bag-info.txt create mode 100644 create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/bagit.txt rename create_derivatives/fixtures/{unpacked_bag_with_tiff_service/3aai9usY3AZzCSFkB3RSQ9/data => unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/data/master}/file_example_TIFF_10MB_001.tif (100%) rename create_derivatives/fixtures/{unpacked_bag_with_tiff_service/3aai9usY3AZzCSFkB3RSQ9/data => unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/data/master}/file_example_TIFF_1MB_001.tif (100%) rename create_derivatives/fixtures/{unpacked_bag_with_tiff_service/3aai9usY3AZzCSFkB3RSQ9/data => unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/data/master}/file_example_TIFF_5MB_001.tif (100%) create mode 100644 create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/manifest-md5.txt create mode 100644 create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/tagmanifest-md5.txt diff --git a/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/bag-info.txt b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/bag-info.txt new file mode 100644 index 0000000..1d52e86 --- /dev/null +++ b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/bag-info.txt @@ -0,0 +1,17 @@ +ArchivesSpace-URI: /repositories/2/archival_objects/1234 +Bag-Software-Agent: bagit.py +BagIt-Profile-Identifier: http://localhost:8000/api/bagit_profiles/1/ +Bagging-Date: 2017-12-11T20:10:28.813474 +Date-End: 1999-06-22 +Date-Start: 1994-05-14 +External-Identifier: records-2017-12-11T20:10:28.813474 +Internal-Sender-Description: Grant awarded to the Village Green Preservation Society for the purpose of "preserving the old ways from being abused, protecting the new ways for me and for you" +Language: eng +Origin: digitization +Payload-Oxum: 1131930.1 +Record-Creators: Custard Pie Appreciation Consortium +Record-Creators: Desperate Dan Appreciation Society +Record-Type: grant records +Restrictions: Records open only to Mrs. Mopp and good old Mother Riley +Source-Organization: Test Organization +Title: Grant to the Village Green Preservation Society diff --git a/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/bagit.txt b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/bagit.txt new file mode 100644 index 0000000..c4aebb4 --- /dev/null +++ b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/bagit.txt @@ -0,0 +1,2 @@ +BagIt-Version: 0.97 +Tag-File-Character-Encoding: UTF-8 diff --git a/create_derivatives/fixtures/unpacked_bag_with_tiff_service/3aai9usY3AZzCSFkB3RSQ9/data/file_example_TIFF_10MB_001.tif b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/data/master/file_example_TIFF_10MB_001.tif similarity index 100% rename from create_derivatives/fixtures/unpacked_bag_with_tiff_service/3aai9usY3AZzCSFkB3RSQ9/data/file_example_TIFF_10MB_001.tif rename to create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/data/master/file_example_TIFF_10MB_001.tif diff --git a/create_derivatives/fixtures/unpacked_bag_with_tiff_service/3aai9usY3AZzCSFkB3RSQ9/data/file_example_TIFF_1MB_001.tif b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/data/master/file_example_TIFF_1MB_001.tif similarity index 100% rename from create_derivatives/fixtures/unpacked_bag_with_tiff_service/3aai9usY3AZzCSFkB3RSQ9/data/file_example_TIFF_1MB_001.tif rename to create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/data/master/file_example_TIFF_1MB_001.tif diff --git a/create_derivatives/fixtures/unpacked_bag_with_tiff_service/3aai9usY3AZzCSFkB3RSQ9/data/file_example_TIFF_5MB_001.tif b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/data/master/file_example_TIFF_5MB_001.tif similarity index 100% rename from create_derivatives/fixtures/unpacked_bag_with_tiff_service/3aai9usY3AZzCSFkB3RSQ9/data/file_example_TIFF_5MB_001.tif rename to create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/data/master/file_example_TIFF_5MB_001.tif diff --git a/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/manifest-md5.txt b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/manifest-md5.txt new file mode 100644 index 0000000..8f08e59 --- /dev/null +++ b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/manifest-md5.txt @@ -0,0 +1 @@ +df87217e2c181ae6674898dff27e5a56 data/file_example_TIFF_1MB.tiff diff --git a/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/tagmanifest-md5.txt b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/tagmanifest-md5.txt new file mode 100644 index 0000000..72dc7c4 --- /dev/null +++ b/create_derivatives/fixtures/unpacked_bag_with_tiff_master/3aai9usY3AZzCSFkB3RSQ9/tagmanifest-md5.txt @@ -0,0 +1,3 @@ +9e5ad981e0d29adc278f6a294b8c2aca bagit.txt +387c1c0bfc4c7a4e75e17358029e4bdc bag-info.txt +53c3a2ca7138cdd8bf4b622e80dec9cd manifest-md5.txt diff --git a/create_derivatives/tests.py b/create_derivatives/tests.py index 5ab7e0b..6df783c 100644 --- a/create_derivatives/tests.py +++ b/create_derivatives/tests.py @@ -244,16 +244,18 @@ def test_tiff_file_paths(self): Files in a service directory should be returned if present, otherwise TIFFs in the data directory should be returned. """ - for fixture_path, expected in [ - ("unpacked_bag_with_tiff", False), - ("unpacked_bag_with_tiff_empty_service", False), - ("unpacked_bag_with_tiff_service", True)]: + for fixture_path, expected_service, expected_master in [ + ("unpacked_bag_with_tiff", False, False), + ("unpacked_bag_with_tiff_empty_service", False, False), + ("unpacked_bag_with_tiff_master", False, True), + ("unpacked_bag_with_tiff_service", True, False)]: set_up_bag(settings.TMP_DIR, fixture_path, self.bag_id) bag = Bag.objects.last() tiffs = JP2Maker().get_tiff_file_paths(bag.bag_path) for path in tiffs: self.assertTrue("data" in str(path)) - self.assertEqual("service" in str(path), expected) + self.assertEqual("service" in str(path), expected_service) + self.assertEqual("master" in str(path), expected_master) shutil.rmtree(bag.bag_path) def tearDown(self):