From a6e33c7ee6952ca332a7fb20607c991c9b21fe1a Mon Sep 17 00:00:00 2001 From: "S. Paquette" Date: Thu, 20 Feb 2020 19:48:43 -0800 Subject: [PATCH] -> Re-enable seed-pull --- idc/metadata_utils.py | 1 - idc/views.py | 3 ++- scripts/database_bootstrap.py | 22 +++++++++++----------- shell/database-refresh.sh | 2 +- shell/python-su.sh | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/idc/metadata_utils.py b/idc/metadata_utils.py index dbdbbf044..a31aa8737 100644 --- a/idc/metadata_utils.py +++ b/idc/metadata_utils.py @@ -72,7 +72,6 @@ def get_collex_metadata(filters, fields, with_docs=True, record_limit=10, counts 'query_string': "*:*", 'facets': solr_facets, 'limit': record_limit if with_docs else 0, - # what is with_docs supposed to do?? 'limit': 10 if with_docs else 0, 'collapse_on': 'SeriesInstanceUID', 'counts_only': counts_only }) diff --git a/idc/views.py b/idc/views.py index fc258ef36..0003facec 100644 --- a/idc/views.py +++ b/idc/views.py @@ -124,7 +124,7 @@ def explore_data(request): context = {} try: # These are example filters; typically they will be reconstituted from the request - filters = {"vital_status": ["Alive", "Dead"], "age_at_diagnosis_btw": [15,40], "bmi": "underweight"} + filters = {"vital_status": ["Alive", "Dead"], "age_at_diagnosis_btw": [15,40], "bmi": "underweight", "race": "BLACK OR AFRICAN AMERICAN"} # These are the actual data fields to display in the expanding table; again this is just an example # set that should be properly supplied in the reuqest fields = ["BodyPartExamined", "Modality", "StudyDescription", "StudyInstanceUID", "SeriesInstanceUID"] @@ -139,6 +139,7 @@ def explore_data(request): 'cross_collex_attr_counts': facets_and_lists['facets']['cross_collex'], 'listings': facets_and_lists['docs'] } + except Exception as e: logger.error("[ERROR] In explore_data:") logger.exception(e) diff --git a/scripts/database_bootstrap.py b/scripts/database_bootstrap.py index 25320cf3d..66f4322ab 100644 --- a/scripts/database_bootstrap.py +++ b/scripts/database_bootstrap.py @@ -38,7 +38,7 @@ import django django.setup() -from idc_collections.models import Program, Collection, Attribute, Attribute_Display_Values, SolrCollection, BigQueryTable, DataVersion +from idc_collections.models import Program, Collection, Attribute, Attribute_Ranges, Attribute_Display_Values, SolrCollection, BigQueryTable, DataVersion from django.contrib.auth.models import User idc_superuser = User.objects.get(username="idc") @@ -165,6 +165,10 @@ def add_attributes(attr_set): preformatted_values=True if 'preformatted_values' in attr else False, is_cross_collex=True if 'cross_collex' in attr else False ) + if 'range' in attr: + Attribute_Ranges.objects.update_or_create( + attribute=obj + ) if 'display_vals' in attr: for dv in attr['display_vals']: Attribute_Display_Values.objects.update_or_create( @@ -288,6 +292,9 @@ def main(): else: attr['display_vals'] = display_vals[attr['name']]['vals'] + if attr['name'] == "age_at_diagnosis": + attr['range'] = True + attr_set.append(attr) attr_file.close() @@ -299,23 +306,16 @@ def main(): line = line.strip() line_split = line.split(",") - attr_set.append({ + attr = { 'name': line_split[0], "display_name": line_split[0].replace("_", " ").title() if re.search(r'_', line_split[1]) else line_split[1], "type": Attribute.CATEGORICAL if line_split[2] == 'CATEGORICAL STRING' else Attribute.STRING if line_split[2] == "STRING" else Attribute.CONTINUOUS_NUMERIC, 'cross_collex': True, 'solr_collex': ['tcia_images'], 'bq_tables': ["idc-dev-etl.tcia.dicom_metadata"] - }) + } - attr_set.append({ - 'name': 'collection_id', - 'display_name': "Collection", - "type": Attribute.CATEGORICAL, - "cross_collex": True, - 'solr_collex': ['tcia_images'], - 'bq_tables': ["idc-dev-etl.tcia.dicom_metadata"] - }) + attr_set.append(attr) add_attributes(attr_set) diff --git a/shell/database-refresh.sh b/shell/database-refresh.sh index 9ee5c0ecf..7e9f49663 100755 --- a/shell/database-refresh.sh +++ b/shell/database-refresh.sh @@ -8,7 +8,7 @@ else exit 1 fi # Doublecheck where we're running this... - if [ $DATABASE_HOST != "localhost" ]; then + if [ "${DATABASE_HOST}" != "localhost" ]; then echo "[ERROR] Possible remote database detected! This script IS ONLY intended for use on local developer builds!" echo "[ERROR] Host seen: ${DATABASE_HOST}" exit 1 diff --git a/shell/python-su.sh b/shell/python-su.sh index 9042ac8f1..79022a76e 100755 --- a/shell/python-su.sh +++ b/shell/python-su.sh @@ -1,2 +1,2 @@ #!/bin/bash -sudo PYTHONPATH="$PYTHONPATH" SECURE_LOCAL_PATH="$SECURE_LOCAL_PATH" /usr/bin/python3 "$@" \ No newline at end of file +sudo PYTHONPATH="$VM_PYTHONPATH" SECURE_LOCAL_PATH="$SECURE_LOCAL_PATH" /usr/bin/python3 "$@" \ No newline at end of file