Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derek furst/exclude results #738

Merged
merged 12 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.21
2.3.22
2 changes: 0 additions & 2 deletions docker/docker-compose.deployment.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.7"

services:

entity-api:
Expand Down
2 changes: 0 additions & 2 deletions docker/docker-compose.development.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.7"

services:

entity-api:
Expand Down
3 changes: 0 additions & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
version: "3.7"

# Will use the hostname when talking between services on the same network
services:

entity-api:
Expand Down
6 changes: 3 additions & 3 deletions docker/docker-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ else
echo

if [ "$1" = "start" ]; then
docker-compose -f docker-compose.yml -f docker-compose.deployment.yml -p entity-api up -d
docker compose -f docker-compose.yml -f docker-compose.deployment.yml -p entity-api up -d
elif [ "$1" = "stop" ]; then
docker-compose -f docker-compose.yml -f docker-compose.deployment.yml -p entity-api stop
docker compose -f docker-compose.yml -f docker-compose.deployment.yml -p entity-api stop
elif [ "$1" = "down" ]; then
docker-compose -f docker-compose.yml -f docker-compose.deployment.yml -p entity-api down
docker compose -f docker-compose.yml -f docker-compose.deployment.yml -p entity-api down
fi
fi

8 changes: 4 additions & 4 deletions docker/docker-development.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ else
cp ../VERSION entity-api
cp ../BUILD entity-api

docker-compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api build
docker compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api build
elif [ "$1" = "start" ]; then
docker-compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api up -d
docker compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api up -d
elif [ "$1" = "stop" ]; then
docker-compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api stop
docker compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api stop
elif [ "$1" = "down" ]; then
docker-compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api down
docker compose -f docker-compose.yml -f docker-compose.development.yml -p entity-api down
fi
fi

2 changes: 1 addition & 1 deletion docker/entity-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Parent image
FROM hubmap/api-base-image:1.0.0
FROM hubmap/api-base-image:1.1.0

LABEL description="HuBMAP Entity API Service"

Expand Down
4 changes: 2 additions & 2 deletions docker/entity-api/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ chown -R hive:hive /var/run/nginx.pid
chown -R hive:hive /var/cache/nginx
chown -R hive:hive /var/log/nginx

# Lastly we use gosu to execute our process "$@" as that user
# Lastly we use su-exec to execute our process "$@" as that user
# Remember CMD from a Dockerfile of child image gets passed to the entrypoint.sh as command line arguments
# "$@" is a shell variable that means "all the arguments"
exec /usr/local/bin/gosu hive "$@"
exec /usr/local/bin/su-exec hive "$@"
154 changes: 134 additions & 20 deletions src/app.py

Large diffs are not rendered by default.

32 changes: 14 additions & 18 deletions src/schema/provenance_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,14 @@ doi_properties: &doi_properties
before_property_update_validators:
- verify_DOI_pair
- halt_update_if_DOI_exists
# Currently creators and contacts are only available for public Collections
creators:
contributors:
type: list
indexed: true
description: "A list of the people who created the entity with full name, email, ORCID iD, institution, etc.. This is analogous to the author list on a publication."
contacts:
type: list
indexed: true
description: "A list of the people who are the main contacts to get information about the entity."
# To-DO
# creator_ids:
# type: list
# immutable: true
# description: "A list of ids (will need to decide on uuid or orcid id) referencing the people who created the entity"
# contact_ids:
# type: list
# description: "A list of ids (will need to decide on uuid or orcid id) referencing the people who are the main contacts about this entity"

shared_entity_properties: &shared_entity_properties
###### Last Modified Properties #######
Expand Down Expand Up @@ -210,9 +201,7 @@ ENTITIES:
<<: *shared_properties
<<: *shared_entity_properties
# Because Collection-specific validation is needed for some
# DOI fields, all validations from
# <<: *doi_properties
# are merged into this section
# DOI fields, we don't use the shared <<: *doi_properties here
###### DOI properties with entity-specific validations + copies of validations in doi_properties ######
registered_doi:
type: string
Expand Down Expand Up @@ -311,6 +300,11 @@ ENTITIES:
# Only allowed applications can create new Dataset via POST
before_entity_create_validator: validate_application_header_before_entity_create
# Dataset can be either derivation source or target
excluded_properties_from_public_response:
- lab_dataset_id
- ingest_metadata:
metadata:
- lab_id
derivation:
source: true
target: true
Expand Down Expand Up @@ -416,10 +410,6 @@ ENTITIES:
description: "The Upload that this dataset is associated with. Will be returned in response"
on_read_trigger: get_dataset_upload
# No on_index_trigger to include upload in the OpenSearch document for a Dataset
contributors:
type: list
indexed: true
description: "A list of people who contributed to the creation of this dataset. Returned as an array of contributor where the structure of a contributor is"
direct_ancestor_uuids:
required_on_create: true # Only required for create via POST, not update via PUT
type: list
Expand Down Expand Up @@ -748,6 +738,9 @@ ENTITIES:
derivation:
source: false
target: true
excluded_properties_from_public_response:
- lab_donor_id
- submission_id
properties:
<<: *shared_properties
<<: *shared_entity_properties
Expand Down Expand Up @@ -866,6 +859,9 @@ ENTITIES:
derivation:
source: true
target: true
excluded_properties_from_public_response:
- lab_tissue_sample_id
- submission_id
properties:
<<: *shared_properties
<<: *shared_entity_properties
Expand Down Expand Up @@ -1205,4 +1201,4 @@ ENTITIES:
source: false
target: false
properties:
<<: *shared_collection_properties
<<: *shared_collection_properties
37 changes: 37 additions & 0 deletions src/schema/schema_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,43 @@ def entity_instanceof(entity_uuid: str, entity_class: str) -> bool:
return entity_type_instanceof(entity_type, entity_class)


def get_fields_to_exclude(normalized_class=None):
# Determine the schema section based on class
excluded_fields = []
if normalized_class == 'Activity':
schema_section = _schema['ACTIVITIES']
else:
schema_section = _schema['ENTITIES']
exclude_list = schema_section[normalized_class].get('excluded_properties_from_public_response')
if exclude_list:
excluded_fields.extend(exclude_list)
return excluded_fields


def exclude_properties_from_response(excluded_fields, json_body):
output_json = json_body.copy()

def delete_nested_field(data, nested_path):
if isinstance(nested_path, dict):
for key, value in nested_path.items():
if key in data:
if isinstance(value, list):
for nested_field in value:
if isinstance(nested_field, dict):
delete_nested_field(data[key], nested_field)
elif nested_field in data[key]:
del data[key][nested_field]
elif isinstance(value, dict):
delete_nested_field(data[key], value)
elif nested_path in data:
del data[nested_path]

for field in excluded_fields:
delete_nested_field(output_json, field)

return output_json


"""
Generating triggered data based on the target events and methods

Expand Down
1 change: 1 addition & 0 deletions src/schema/schema_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,7 @@ def commit_thumbnail_file(property_key, normalized_type, user_token, existing_da
raise



"""
Trigger event method for removing the thumbnail file from a dataset during update

Expand Down
Loading