From 363b91bcb9bb7ff0edd5dee7759cceb4e16e3acb Mon Sep 17 00:00:00 2001 From: Hannes Schmidt Date: Tue, 2 Apr 2024 16:43:43 -0700 Subject: [PATCH] [A 2/2] Derive manifest config for AnVIL from field mapping (#6110) Name special fields in camel case on AnVIL. This repairs the IT. --- lambdas/service/app.py | 2 +- lambdas/service/openapi.json | 2 +- src/azul/plugins/metadata/anvil/__init__.py | 8 +-- test/service/test_manifest.py | 8 +-- test/service/test_response_anvil.py | 66 ++++++++++----------- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/lambdas/service/app.py b/lambdas/service/app.py index f070a5b81e..42bbdbb1ee 100644 --- a/lambdas/service/app.py +++ b/lambdas/service/app.py @@ -228,7 +228,7 @@ # changes and reset the minor version to zero. Otherwise, increment only # the minor version for backwards compatible changes. A backwards # compatible change is one that does not require updates to clients. - 'version': '5.1' + 'version': '6.1' }, 'tags': [ { diff --git a/lambdas/service/openapi.json b/lambdas/service/openapi.json index eee73fa83d..0f241331f3 100644 --- a/lambdas/service/openapi.json +++ b/lambdas/service/openapi.json @@ -3,7 +3,7 @@ "info": { "title": "azul_service", "description": "\n# Overview\n\nAzul is a REST web service for querying metadata associated with\nboth experimental and analysis data from a data repository. In order\nto deliver response times that make it suitable for interactive use\ncases, the set of metadata properties that it exposes for sorting,\nfiltering, and aggregation is limited. Azul provides a uniform view\nof the metadata over a range of diverse schemas, effectively\nshielding clients from changes in the schemas as they occur over\ntime. It does so, however, at the expense of detail in the set of\nmetadata properties it exposes and in the accuracy with which it\naggregates them.\n\nAzul denormalizes and aggregates metadata into several different\nindices for selected entity types. Metadata entities can be queried\nusing the [Index](#operations-tag-Index) endpoints.\n\nA set of indices forms a catalog. There is a default catalog called\n`dcp2` which will be used unless a\ndifferent catalog name is specified using the `catalog` query\nparameter. Metadata from different catalogs is completely\nindependent: a response obtained by querying one catalog does not\nnecessarily correlate to a response obtained by querying another\none. Two catalogs can contain metadata from the same sources or\ndifferent sources. It is only guaranteed that the body of a\nresponse by any given endpoint adheres to one schema,\nindependently of which catalog was specified in the request.\n\nAzul provides the ability to download data and metadata via the\n[Manifests](#operations-tag-Manifests) endpoints. The\n`curl` format manifests can be used to\ndownload data files. Other formats provide various views of the\nmetadata. Manifests can be generated for a selection of files using\nfilters. These filters are interchangeable with the filters used by\nthe [Index](#operations-tag-Index) endpoints.\n\nAzul also provides a [summary](#operations-Index-get_index_summary)\nview of indexed data.\n\n## Data model\n\nAny index, when queried, returns a JSON array of hits. Each hit\nrepresents a metadata entity. Nested in each hit is a summary of the\nproperties of entities associated with the hit. An entity is\nassociated either by a direct edge in the original metadata graph,\nor indirectly as a series of edges. The nested properties are\ngrouped by the type of the associated entity. The properties of all\ndata files associated with a particular sample, for example, are\nlisted under `hits[*].files` in a `/index/samples` response. It is\nimportant to note that while each _hit_ represents a discrete\nentity, the properties nested within that hit are the result of an\naggregation over potentially many associated entities.\n\nTo illustrate this, consider a data file that is part of two\nprojects (a project is a group of related experiments, typically by\none laboratory, institution or consortium). Querying the `files`\nindex for this file yields a hit looking something like:\n\n```\n{\n \"projects\": [\n {\n \"projectTitle\": \"Project One\"\n \"laboratory\": ...,\n ...\n },\n {\n \"projectTitle\": \"Project Two\"\n \"laboratory\": ...,\n ...\n }\n ],\n \"files\": [\n {\n \"format\": \"pdf\",\n \"name\": \"Team description.pdf\",\n ...\n }\n ]\n}\n```\n\nThis example hit contains two kinds of nested entities (a hit in an\nactual Azul response will contain more): There are the two projects\nentities, and the file itself. These nested entities contain\nselected metadata properties extracted in a consistent way. This\nmakes filtering and sorting simple.\n\nAlso notice that there is only one file. When querying a particular\nindex, the corresponding entity will always be a singleton like\nthis.\n", - "version": "5.1" + "version": "6.1" }, "tags": [ { diff --git a/src/azul/plugins/metadata/anvil/__init__.py b/src/azul/plugins/metadata/anvil/__init__.py index 078a8c0aaa..032983ee47 100644 --- a/src/azul/plugins/metadata/anvil/__init__.py +++ b/src/azul/plugins/metadata/anvil/__init__.py @@ -226,10 +226,10 @@ def _field_mapping(self) -> MetadataPlugin._FieldMapping: @property def special_fields(self) -> SpecialFields: - return SpecialFields(source_id='sourceId', - source_spec='sourceSpec', - bundle_uuid='bundleUuid', - bundle_version='bundleVersion') + return SpecialFields(source_id='source_id', + source_spec='source_spec', + bundle_uuid='bundle_uuid', + bundle_version='bundle_version') @property def implicit_hub_type(self) -> str: diff --git a/test/service/test_manifest.py b/test/service/test_manifest.py index 7f1fd8e0fa..26ec389435 100644 --- a/test/service/test_manifest.py +++ b/test/service/test_manifest.py @@ -1654,25 +1654,25 @@ def test_compact_manifest(self): self.assertEqual(200, response.status_code) expected = [ ( - 'bundleUuid', + 'bundle_uuid', '6b0f6c0f-5d80-a242-accb-840921351cd5', '826dea02-e274-affe-aabc-eb3db63ad068', '826dea02-e274-affe-aabc-eb3db63ad068' ), ( - 'bundleVersion', + 'bundle_version', '2022-06-01T00:00:00.000000Z', '2022-06-01T00:00:00.000000Z', '2022-06-01T00:00:00.000000Z' ), ( - 'sourceId', + 'source_id', 'cafebabe-feed-4bad-dead-beaf8badf00d', 'cafebabe-feed-4bad-dead-beaf8badf00d', 'cafebabe-feed-4bad-dead-beaf8badf00d' ), ( - 'sourceSpec', + 'source_spec', 'tdr:test_project:snapshot/snapshot:/2', 'tdr:test_project:snapshot/snapshot:/2', 'tdr:test_project:snapshot/snapshot:/2' diff --git a/test/service/test_response_anvil.py b/test/service/test_response_anvil.py index 34cdd11501..c0d1b307ae 100644 --- a/test/service/test_response_anvil.py +++ b/test/service/test_response_anvil.py @@ -48,14 +48,14 @@ def test_entity_indices(self): 'entryId': '1509ef40-d1ba-440d-b298-16b7c173dcd4', 'sources': [ { - 'sourceSpec': 'tdr:test_project:snapshot/snapshot:/2', - 'sourceId': 'cafebabe-feed-4bad-dead-beaf8badf00d' + 'source_spec': 'tdr:test_project:snapshot/snapshot:/2', + 'source_id': 'cafebabe-feed-4bad-dead-beaf8badf00d' } ], 'bundles': [ { - 'bundleUuid': '826dea02-e274-affe-aabc-eb3db63ad068', - 'bundleVersion': '' + 'bundle_uuid': '826dea02-e274-affe-aabc-eb3db63ad068', + 'bundle_version': '' } ], 'activities': [ @@ -170,14 +170,14 @@ def test_entity_indices(self): 'entryId': '816e364e-1193-4e5b-a91a-14e4b009157c', 'sources': [ { - 'sourceSpec': 'tdr:test_project:snapshot/snapshot:/2', - 'sourceId': 'cafebabe-feed-4bad-dead-beaf8badf00d' + 'source_spec': 'tdr:test_project:snapshot/snapshot:/2', + 'source_id': 'cafebabe-feed-4bad-dead-beaf8badf00d' } ], 'bundles': [ { - 'bundleUuid': '826dea02-e274-affe-aabc-eb3db63ad068', - 'bundleVersion': '' + 'bundle_uuid': '826dea02-e274-affe-aabc-eb3db63ad068', + 'bundle_version': '' } ], 'activities': [ @@ -526,14 +526,14 @@ def test_entity_indices(self): 'entryId': '826dea02-e274-4ffe-aabc-eb3db63ad068', 'sources': [ { - 'sourceSpec': 'tdr:test_project:snapshot/snapshot:/2', - 'sourceId': 'cafebabe-feed-4bad-dead-beaf8badf00d' + 'source_spec': 'tdr:test_project:snapshot/snapshot:/2', + 'source_id': 'cafebabe-feed-4bad-dead-beaf8badf00d' } ], 'bundles': [ { - 'bundleUuid': '826dea02-e274-affe-aabc-eb3db63ad068', - 'bundleVersion': '' + 'bundle_uuid': '826dea02-e274-affe-aabc-eb3db63ad068', + 'bundle_version': '' } ], 'activities': [ @@ -906,8 +906,8 @@ def test_entity_indices(self): 'bundles': [ { 'accessible': True, - 'bundleUuid': '826dea02-e274-affe-aabc-eb3db63ad068', - 'bundleVersion': '' + 'bundle_uuid': '826dea02-e274-affe-aabc-eb3db63ad068', + 'bundle_version': '' } ], 'datasets': [ @@ -954,8 +954,8 @@ def test_entity_indices(self): 'reference_assembly': [None]}], 'sources': [ { - 'sourceId': 'cafebabe-feed-4bad-dead-beaf8badf00d', - 'sourceSpec': 'tdr:test_project:snapshot/snapshot:/2' + 'source_id': 'cafebabe-feed-4bad-dead-beaf8badf00d', + 'source_spec': 'tdr:test_project:snapshot/snapshot:/2' } ] } @@ -967,7 +967,7 @@ def test_entity_indices(self): 'pages': 1, 'previous': None, 'size': 10, - 'sort': 'bundleUuid', + 'sort': 'bundle_uuid', 'total': 1 }, 'termFacets': { @@ -1090,14 +1090,14 @@ def test_entity_indices(self): 'entryId': '2370f948-2783-4eb6-afea-e022897f4dcf', 'sources': [ { - 'sourceSpec': 'tdr:test_project:snapshot/snapshot:/2', - 'sourceId': 'cafebabe-feed-4bad-dead-beaf8badf00d' + 'source_spec': 'tdr:test_project:snapshot/snapshot:/2', + 'source_id': 'cafebabe-feed-4bad-dead-beaf8badf00d' } ], 'bundles': [ { - 'bundleUuid': '826dea02-e274-affe-aabc-eb3db63ad068', - 'bundleVersion': '' + 'bundle_uuid': '826dea02-e274-affe-aabc-eb3db63ad068', + 'bundle_version': '' } ], 'activities': [ @@ -1471,14 +1471,14 @@ def test_entity_indices(self): 'entryId': 'bfd991f2-2797-4083-972a-da7c6d7f1b2e', 'sources': [ { - 'sourceSpec': 'tdr:test_project:snapshot/snapshot:/2', - 'sourceId': 'cafebabe-feed-4bad-dead-beaf8badf00d' + 'source_spec': 'tdr:test_project:snapshot/snapshot:/2', + 'source_id': 'cafebabe-feed-4bad-dead-beaf8badf00d' } ], 'bundles': [ { - 'bundleUuid': '826dea02-e274-affe-aabc-eb3db63ad068', - 'bundleVersion': '' + 'bundle_uuid': '826dea02-e274-affe-aabc-eb3db63ad068', + 'bundle_version': '' } ], 'activities': [ @@ -1847,14 +1847,14 @@ def test_entity_indices(self): 'entryId': '15b76f9c-6b46-433f-851d-34e89f1b9ba6', 'sources': [ { - 'sourceSpec': 'tdr:test_project:snapshot/snapshot:/2', - 'sourceId': 'cafebabe-feed-4bad-dead-beaf8badf00d' + 'source_spec': 'tdr:test_project:snapshot/snapshot:/2', + 'source_id': 'cafebabe-feed-4bad-dead-beaf8badf00d' } ], 'bundles': [ { - 'bundleUuid': '826dea02-e274-affe-aabc-eb3db63ad068', - 'bundleVersion': '' + 'bundle_uuid': '826dea02-e274-affe-aabc-eb3db63ad068', + 'bundle_version': '' } ], 'activities': [ @@ -1976,14 +1976,14 @@ def test_entity_indices(self): 'entryId': '3b17377b-16b1-431c-9967-e5d01fc5923f', 'sources': [ { - 'sourceSpec': 'tdr:test_project:snapshot/snapshot:/2', - 'sourceId': 'cafebabe-feed-4bad-dead-beaf8badf00d' + 'source_spec': 'tdr:test_project:snapshot/snapshot:/2', + 'source_id': 'cafebabe-feed-4bad-dead-beaf8badf00d' } ], 'bundles': [ { - 'bundleUuid': '826dea02-e274-affe-aabc-eb3db63ad068', - 'bundleVersion': '' + 'bundle_uuid': '826dea02-e274-affe-aabc-eb3db63ad068', + 'bundle_version': '' } ], 'activities': [