Skip to content

Commit c028edd

Browse files
authored
Merge pull request #867 from hubmapconsortium/Derek-Furst/priority-project-list
Added new property priority_project_list and accompanying validator
2 parents 1e40e66 + e768eec commit c028edd

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

entity-api-spec.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,9 @@ components:
542542
type: string
543543
format: uuid
544544
description: 'List of image files previously uploaded to delete. Provide as a json array of the file_uuids of the file like: ["232934234234234234234270c0ea6c51d604a850558ef2247d0b4", "230948203482234234234a57bfe9c056d08a0f8e6cd612baa3bfa"]'
545+
rui_exemption:
546+
type: boolean
547+
description: 'Identifies Sample Blocks that are exempt from spatial registration via RUI.'
545548
Dataset:
546549
type: object
547550
properties:
@@ -809,6 +812,9 @@ components:
809812
intended_organ:
810813
type: string
811814
description: 'The organ code representing the organ type that the data contained in the upload will be registered/associated with.'
815+
priority_project_list:
816+
type: array
817+
description: 'The list of priority projects that this Dataset data will be used For'
812818
Upload:
813819
type: object
814820
properties:
@@ -909,6 +915,9 @@ components:
909915
anticipated_dataset_count:
910916
type: integer
911917
description: 'The total number of datasets that this Upload will eventually contain.'
918+
priority_project_list:
919+
type: array
920+
description: 'The list of priority projects that this Upload data will be used For'
912921
Collection:
913922
type: object
914923
properties:
@@ -1403,6 +1412,7 @@ components:
14031412
group_name: 'University TMC'
14041413
visit: 'abc123'
14051414
rui_location: object
1415+
rui_exemption: False
14061416
DatasetExample:
14071417
summary: 'An example of a Dataset response'
14081418
value:
@@ -1456,6 +1466,7 @@ components:
14561466
intended_organ: 'AO'
14571467
group_uuid: 'abcd1234-ef56-gh78-ij90-klmnop123456'
14581468
group_name: 'University TMC'
1469+
priority_project_list: ['SWAT']
14591470
UploadExample:
14601471
summary: 'An example of an upload response'
14611472
value:
@@ -1479,6 +1490,7 @@ components:
14791490
dataset_uuids_to_link: ['abcd1234-ef56-gh78-ij90-klmnop123456']
14801491
dataset_uuids_to_unlink: ['abcd1234-ef56-gh78-ij90-klmnop123456']
14811492
datasets: [dataset objects]
1493+
priority_project_list: ['SWAT']
14821494
CollectionExample:
14831495
summary: 'An example of a collection response'
14841496
value:
@@ -1633,6 +1645,7 @@ components:
16331645
intended_organ: 'AO'
16341646
group_uuid: 'abcd1234-ef56-gh78-ij90-klmnop123456'
16351647
group_name: 'University TMC'
1648+
priority_project_list: ['SWAT']
16361649
- created_timestamp: 1710243867000
16371650
created_by_user_displayname: 'JaneDoe1'
16381651
created_by_user_email: '[email protected]'
@@ -1683,6 +1696,7 @@ components:
16831696
intended_organ: 'AO'
16841697
group_uuid: 'abcd1234-ef56-gh78-ij90-klmnop123456'
16851698
group_name: 'University TMC'
1699+
priority_project_list:: ['SWAT']
16861700
SampleArrayExample:
16871701
summary: 'An example of an array of sample objects'
16881702
value:
@@ -1719,6 +1733,7 @@ components:
17191733
group_name: 'University TMC'
17201734
visit: 'abc123'
17211735
rui_location: object
1736+
rui_exemption: False
17221737
- created_timestamp: 1710243867000
17231738
created_by_user_displayname: 'JaneDoe1'
17241739
created_by_user_email: '[email protected]'
@@ -1752,6 +1767,7 @@ components:
17521767
group_name: 'University TMC'
17531768
visit: 'abc123'
17541769
rui_location: object
1770+
rui_exemption: False
17551771
CollectionArrayExample:
17561772
summary: 'An example of an array of collection objects'
17571773
value:
@@ -1814,6 +1830,7 @@ components:
18141830
dataset_uuids_to_link: ['abcd1234-ef56-gh78-ij90-klmnop123456']
18151831
dataset_uuids_to_unlink: ['abcd1234-ef56-gh78-ij90-klmnop123456']
18161832
datasets: [dataset objects]
1833+
priority_project_list: ['SWAT']
18171834
- created_timestamp: 1710243867000
18181835
created_by_user_displayname: 'JaneDoe1'
18191836
created_by_user_email: '[email protected]'
@@ -1834,6 +1851,7 @@ components:
18341851
dataset_uuids_to_link: ['abcd1234-ef56-gh78-ij90-klmnop123456']
18351852
dataset_uuids_to_unlink: ['abcd1234-ef56-gh78-ij90-klmnop123456']
18361853
datasets: [dataset objects]
1854+
priority_project_list: ['SWAT']
18371855
DatasetProvMetadata:
18381856
summary: 'An example of a dataset prov metadata response'
18391857
value:

src/schema/provenance_schema.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,16 @@ ENTITIES:
677677
- validate_in_admin_group
678678
before_property_update_validators:
679679
- validate_in_admin_group
680+
priority_project_list:
681+
type: list
682+
required: false
683+
indexted: false
684+
description: The list of priority projects that this Dataset data will be used For
685+
immutable: false
686+
before_property_update_validators:
687+
- validate_priority_project
688+
before_property_create_validators:
689+
- validate_priority_project
680690

681691
############################################# Publication #############################################
682692
Publication:
@@ -796,6 +806,7 @@ ENTITIES:
796806
ingest_task: null # This ingest_task is Dataset specific, Publication doesn't have it
797807
new_associated_multi_assay_uuid: null # Dataset-only attribute of Multi-Assay Dataset relationships
798808
superseded_associated_processed_component_uuids: null # Dataset-only attribute of Multi-Assay Dataset relationships
809+
priority_project_list: null # Dataset-only attribute
799810

800811
############################################# Donor #############################################
801812
Donor:
@@ -1344,6 +1355,16 @@ ENTITIES:
13441355
- validate_anticipated_dataset_count
13451356
before_property_update_validators:
13461357
- validate_anticipated_dataset_count
1358+
priority_project_list:
1359+
type: list
1360+
required: false
1361+
indexted: false
1362+
description: The list of priority projects that this Uploaded data will be used For
1363+
immutable: false
1364+
before_property_update_validators:
1365+
- validate_priority_project
1366+
before_property_create_validators:
1367+
- validate_priority_project
13471368

13481369
############################################# EPICollection #############################################
13491370
Epicollection:

src/schema/schema_constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class SchemaConstants(object):
2626

2727
OMITTED_FIELDS = ['ingest_metadata', 'files']
2828

29+
ALLOWED_PRIORITY_PROJECTS = ['SWAT', 'MOSDAP']
30+
2931
# Define an enumeration to classify an entity's visibility, which can be combined with
3032
# authorization info when verify operations on a request.
3133
class DataVisibilityEnum(Enum):

src/schema/schema_validators.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,31 @@ def verify_multi_assay_dataset_components(property_key, normalized_type, user_to
887887
# fall out successfully if no raise() occurred.
888888
return
889889

890+
891+
"""
892+
Validate the specified value for an Upload's priority_project_list is in a recognized value
893+
894+
Parameters
895+
----------
896+
property_key : str
897+
The target property key
898+
normalized_type : str
899+
Submission
900+
request: Flask request object
901+
The instance of Flask request passed in from application request
902+
existing_data_dict : dict
903+
A dictionary that contains all existing entity properties
904+
new_data_dict : dict
905+
The json data in request body, already after the regular validations
906+
"""
907+
def validate_priority_project(property_key, normalized_entity_type, request, existing_data_dict, new_data_dict):
908+
allowed_priority_projects = SchemaConstants.ALLOWED_PRIORITY_PROJECTS
909+
for priority_project in new_data_dict.get('priority_project_list'):
910+
if priority_project not in allowed_priority_projects:
911+
raise ValueError(f"Provided priority_project_list contains unrecognized value: {priority_project}. Allowed values are {', '.join(allowed_priority_projects)}. These are case-sensitive values.")
912+
new_data_dict['priority_project_list'] = [project.upper() for project in new_data_dict['priority_project_list']]
913+
914+
890915
####################################################################################################
891916
## Internal Functions
892917
####################################################################################################

0 commit comments

Comments
 (0)