Commit c56042ed authored by abuddenberg's avatar abuddenberg
Browse files

Support for all Health Assessment figures

parent 5e9c7ebe
This diff is collapsed.
...@@ -108,7 +108,7 @@ class GcisClient(object): ...@@ -108,7 +108,7 @@ class GcisClient(object):
self.s.headers.update({'Accept': 'application/json'}) self.s.headers.update({'Accept': 'application/json'})
@http_resp @http_resp
def create_figure(self, report_id, chapter_id, figure, skip_images=False): def create_figure(self, report_id, chapter_id, figure, skip_images=False, skip_upload=False):
if figure.identifier in (None, ''): if figure.identifier in (None, ''):
raise Exception('Invalid figure identifier', figure.identifier) raise Exception('Invalid figure identifier', figure.identifier)
...@@ -124,7 +124,7 @@ class GcisClient(object): ...@@ -124,7 +124,7 @@ class GcisClient(object):
if resp.status_code != 200: if resp.status_code != 200:
return resp return resp
if figure.local_path is not None: if not skip_upload and figure.local_path is not None:
self.upload_figure_file(report_id, chapter_id, figure.identifier, figure.local_path) self.upload_figure_file(report_id, chapter_id, figure.identifier, figure.local_path)
if skip_images is False: if skip_images is False:
......
...@@ -6,6 +6,7 @@ import requests ...@@ -6,6 +6,7 @@ import requests
import re import re
from os.path import join, basename from os.path import join, basename
import sys import sys
import traceback
from gcis_clients.domain import Figure, Image, Dataset, Parent, Contributor, Person, Organization, Activity, Role from gcis_clients.domain import Figure, Image, Dataset, Parent, Contributor, Person, Organization, Activity, Role
import survey_transforms as trans import survey_transforms as trans
...@@ -25,7 +26,7 @@ def get_credentials(): ...@@ -25,7 +26,7 @@ def get_credentials():
def parse_title(graphic_title): def parse_title(graphic_title):
match = re.search('\d+\.\d+', graphic_title) match = re.search('\w+\.\d+', graphic_title)
if match: if match:
return match.group(0), graphic_title[match.end(0):].strip() return match.group(0), graphic_title[match.end(0):].strip()
else: else:
...@@ -35,7 +36,20 @@ def parse_title(graphic_title): ...@@ -35,7 +36,20 @@ def parse_title(graphic_title):
def populate_figure(fig_json): def populate_figure(fig_json):
f = Figure({}) f = Figure({})
try: try:
f.figure_num, f.title = parse_title(fig_json['graphics_title']) if fig_json['graphics_title'].startswith('ES'):
title_fields = fig_json['graphics_title'].split('. ')
title = ' '.join(title_fields[1:])
f.ordinal = re.search('\d+', title_fields[0]).group(0)
else:
figure_num, title = parse_title(fig_json['graphics_title'])
if figure_num and figure_num.startswith('TSD'):
f.ordinal = figure_num.split('.')[1]
else:
f.figure_num = figure_num if figure_num else None
f.title = title
f.identifier = fig_json['figure_id'] if fig_json['figure_id'] else re.sub('\W', '_', f.title).lower() f.identifier = fig_json['figure_id'] if fig_json['figure_id'] else re.sub('\W', '_', f.title).lower()
f.create_dt = fig_json['graphics_create_date'].strip() f.create_dt = fig_json['graphics_create_date'].strip()
if any(fig_json['period_record']): if any(fig_json['period_record']):
...@@ -43,7 +57,7 @@ def populate_figure(fig_json): ...@@ -43,7 +57,7 @@ def populate_figure(fig_json):
f.lat_min, f.lat_max, f.lon_min, f.lon_max = fig_json['spatial_extent'] f.lat_min, f.lat_max, f.lon_min, f.lon_max = fig_json['spatial_extent']
except Exception, e: except Exception, e:
warning('Figure exception: ', e) warning('Figure exception: ', e)
traceback.print_exc()
return f return f
......
...@@ -47,21 +47,29 @@ PARENT_SEARCH_HINTS = { ...@@ -47,21 +47,29 @@ PARENT_SEARCH_HINTS = {
'report': { 'report': {
'Climate Change Impacts in the United States: The Third National Climate Assessment': 'nca3', 'Climate Change Impacts in the United States: The Third National Climate Assessment': 'nca3',
'Third National Climate Assessment': 'nca3', 'Third National Climate Assessment': 'nca3',
'A conceptual framework for action on the social determinants of health': 'conceptual-framework-for-action-on-the-social-determinants-of-health' 'A conceptual framework for action on the social determinants of health': 'conceptual-framework-for-action-on-the-social-determinants-of-health',
'Regional Surface Climate Conditions in CMIP3 and CMIP5 for the United States: Differences, Similarities, and Implications for the U.S. National Climate Assessment.': 'noaa-techreport-nesdis-144',
'2012 Census of Agriculture': 'census-agriculture-2012'
}, },
'dataset': { 'dataset': {
'Global Historical Climatology Network - Daily': 'noaa-ncdc-ghcn-daily' 'Global Historical Climatology Network - Daily': 'noaa-ncdc-ghcn-daily'
}, },
'article': { 'article': {
'Projections of future temperature-attributable deaths in 209 U.S. cities using a cluster based Poisson approach': 'projections-of-future-temperature-attributable-deaths-in-209-us-cities', 'Projections of future temperature-attributable deaths in 209 U.S. cities using a cluster based Poisson approach': '10.1186/s12940-015-0071-2',
'Projections of future temperature-attributable deaths in 209 U.S. cities 1 using a cluster-based Poisson approach': '10.1186/s12940-015-0071-2',
'A framework for examining climate driven changes to the seasonality and geographic range of coastal pathogens': '10.1016/j.crm.2015.03.002', 'A framework for examining climate driven changes to the seasonality and geographic range of coastal pathogens': '10.1016/j.crm.2015.03.002',
'Effects of Ocean Warming on Growth and Distribution of Five Ciguatera-Associated Dinoflagellates in the Caribbean and Implications for Ciguatera Fish Poisoning': 'potential-effects-of-climate-change-on-growth-and-distribution-of-five-caribbean-gambierdiscus-species', 'Effects of Ocean Warming on Growth and Distribution of Five Ciguatera-Associated Dinoflagellates in the Caribbean and Implications for Ciguatera Fish Poisoning': 'potential-effects-of-climate-change-on-growth-and-distribution-of-five-caribbean-gambierdiscus-species',
'Effects of elevated CO2 on the protein concentration of food crops: a meta-analysis': '10.1111/j.1365-2486.2007.01511.x', 'Effects of elevated CO2 on the protein concentration of food crops: a meta-analysis': '10.1111/j.1365-2486.2007.01511.x',
'A new scenario framework for climate change research: the concept of shared socio-economic pathways': '10.1007/s10584-013-0905-2', 'A new scenario framework for climate change research: the concept of shared socio-economic pathways': '10.1007/s10584-013-0905-2',
'Climate Change influences on the annual onset of Lyme disease in the United States': '10.1016/j.ttbdis.2015.05.005' 'Climate Change influences on the annual onset of Lyme disease in the United States': '10.1016/j.ttbdis.2015.05.005',
'The roads ahead: Narratives for shared socioeconomic pathways describing world futures in the 21st century': '10.1016/j.gloenvcha.2015.01.004'
}, },
'webpage': { 'webpage': {
'Screenshot of: Social Vulnerability Index (SVI) Mapping Dashboard': '6d0ccc19-cdcc-4d56-acb7-d62f12611333' 'Screenshot of: Social Vulnerability Index (SVI) Mapping Dashboard': '6d0ccc19-cdcc-4d56-acb7-d62f12611333',
'Lyme Disease: Data and Statistics: Maps': '7206f315-04be-4536-9e10-70155edfada0',
'Risk of very large fires could increase sixfold by mid-century in the US': 'af962cb2-dd38-44f6-9b4e-7bef8577b92c',
'Flickr account: User: TeamSaintLouis. Album: Low Water on the Mississippi River': '9853a51e-b7c2-42c5-a201-d2f5c8527f52',
'USDA Biological Control of Pests Research Unit': '950835c0-2088-4f06-a61a-a809387d4930'
}, },
'book': { 'book': {
'Assessing Health Vulnerability to Climate Change: A Guide for Health Departments': ('report', 'assessing-health-vulnerability-to-climate-change-a-guide-for-health-departments') 'Assessing Health Vulnerability to Climate Change: A Guide for Health Departments': ('report', 'assessing-health-vulnerability-to-climate-change-a-guide-for-health-departments')
...@@ -130,18 +138,28 @@ ORG_IDS = { ...@@ -130,18 +138,28 @@ ORG_IDS = {
# contributing_agency # contributing_agency
PERSON_TRANSLATIONS = { PERSON_TRANSLATIONS = {
'Alexis Juliana': Person({'first_name': 'Alexis', 'last_name': 'St. Juliana'}), 'Alexis St. Juliana': Person({'id': 9934, 'first_name': 'Alexis', 'last_name': 'St. Juliana'}),
'Alexis Juliana': Person({'id': 9934, 'first_name': 'Alexis', 'last_name': 'St. Juliana'}),
'Pat Dolwick': Person({'first_name': 'Patrick', 'last_name': 'Dolwick'}), 'Pat Dolwick': Person({'first_name': 'Patrick', 'last_name': 'Dolwick'}),
'Alan Joyner': Person({'first_name': 'Alan', 'last_name': 'Joyner'}), 'Alan Joyner': Person({'first_name': 'Alan', 'last_name': 'Joyner'}),
'Juli Trtanj': Person({'first_name': 'Juli M.', 'last_name': 'Trtanj'}), 'Juli Trtanj': Person({'id': 1264, 'first_name': 'Juli M.', 'last_name': 'Trtanj'}),
'Stephanie Moore': Person({'first_name': 'Stephanie K.', 'last_name': 'Moore'}), 'Juli M. Trtanj': Person({'id': 1264, 'first_name': 'Juli M.', 'last_name': 'Trtanj'}),
'Stephanie Moore': Person({'id': 9889, 'first_name': 'Stephanie K.', 'last_name': 'Moore'}),
'Stephanie K. Moore': Person({'id': 9889, 'first_name': 'Stephanie', 'last_name': 'Moore'}),
'Steve Kibler': Person({'first_name': 'Steven R.', 'last_name': 'Kibler'}), 'Steve Kibler': Person({'first_name': 'Steven R.', 'last_name': 'Kibler'}),
'Jesse Bell': Person({'first_name': 'Jesse E.', 'last_name': 'Bell'}), 'Jesse Bell': Person({'first_name': 'Jesse E.', 'last_name': 'Bell'}),
'Dave Mills': Person({'first_name': 'David M.', 'last_name': 'Mills'}), 'Dave Mills': Person({'first_name': 'David M.', 'last_name': 'Mills'}),
'David Mills': Person({'first_name': 'David M.', 'last_name': 'Mills'}), 'David Mills': Person({'first_name': 'David M.', 'last_name': 'Mills'}),
'Lesley Crimmins)': Person({'first_name': 'Lesley', 'last_name': 'Jantarasami'}), 'Lesley Crimmins)': Person({'first_name': 'Lesley', 'last_name': 'Jantarasami'}),
'Allison Jantarasami)': Person({'first_name': 'Allison', 'last_name': 'Crimmins'}), 'Allison Jantarasami)': Person({'first_name': 'Allison', 'last_name': 'Crimmins'}),
'Lewis Ziska': Person({'first_name': 'Lewis H.', 'last_name': 'Ziska'}), 'Lewis Ziska': Person({'id': 923, 'first_name': 'Lewis', 'last_name': 'Ziska'}),
'Jada Garofalo': Person({'id': 9885, 'first_name': 'Jada', 'last_name': 'F. Garofalo'}),
'Micah Hahn': Person({'id': 9886, 'first_name': 'Micah', 'last_name': 'Hahn'}),
'Jeanette Thurston': Person({'id': 9892, 'first_name': 'Jeanette', 'last_name': 'Thurston'}),
'Daniel Dodgen': Person({'id': 9908, 'first_name': 'Daniel', 'last_name': 'Dodgen'}),
'John Jacobs': Person({'id': 9888, 'first_name': 'John', 'last_name': 'Jacobs'}),
'Stephanie Herring': Person({'id': 8333, 'first_name': 'Stephanie', 'last_name': 'Herring'}),
'Tom Maycock': Person({'id': 10926, 'first_name': 'Tom', 'last_name': 'Maycock'})
} }
CONTRIB_ROLES = { CONTRIB_ROLES = {
...@@ -153,6 +171,7 @@ CONTRIB_ROLES = { ...@@ -153,6 +171,7 @@ CONTRIB_ROLES = {
'Dave Mills': ('stratus-consulting', 'analyst'), 'Dave Mills': ('stratus-consulting', 'analyst'),
'David Mills': ('stratus-consulting', 'analyst'), 'David Mills': ('stratus-consulting', 'analyst'),
'Alexis Juliana': ('stratus-consulting', 'analyst'), 'Alexis Juliana': ('stratus-consulting', 'analyst'),
'Alexis St. Juliana': ('stratus-consulting', 'analyst'),
'Neal Fann': ('us-environmental-protection-agency', 'analyst'), 'Neal Fann': ('us-environmental-protection-agency', 'analyst'),
'Pat Dolwick': ('us-environmental-protection-agency', 'scientist'), 'Pat Dolwick': ('us-environmental-protection-agency', 'scientist'),
'Lewis Ziska': ('us-department-agriculture', 'scientist'), 'Lewis Ziska': ('us-department-agriculture', 'scientist'),
...@@ -167,5 +186,8 @@ CONTRIB_ROLES = { ...@@ -167,5 +186,8 @@ CONTRIB_ROLES = {
'Daniel Dodgen': ('us-department-health-human-services', 'point_of_contact'), 'Daniel Dodgen': ('us-department-health-human-services', 'point_of_contact'),
'Andrea Maguire': ('us-environmental-protection-agency', 'point_of_contact'), 'Andrea Maguire': ('us-environmental-protection-agency', 'point_of_contact'),
'Lesley Crimmins)': ('us-environmental-protection-agency', 'analyst'), 'Lesley Crimmins)': ('us-environmental-protection-agency', 'analyst'),
'Allison Jantarasami)': ('us-environmental-protection-agency', 'point_of_contact') 'Allison Jantarasami)': ('us-environmental-protection-agency', 'point_of_contact'),
'John Jacobs': ('national-oceanic-atmospheric-administration', 'scientist'),
'Stephanie Herring': ('national-oceanic-atmospheric-administration', 'scientist'),
'Tom Maycock': ('cooperative-institute-climate-satellites-nc', 'point_of_contact'),
} }
...@@ -38,14 +38,15 @@ def realize_contributors(gcis_client, contributors): ...@@ -38,14 +38,15 @@ def realize_contributors(gcis_client, contributors):
person = cont.person person = cont.person
org = cont.organization org = cont.organization
name_matches = gcis_client.lookup_person(person.first_name + ' ' + person.last_name) if not person.id:
if len(name_matches) == 1: name_matches = gcis_client.lookup_person(person.first_name + ' ' + person.last_name)
person.id = name_matches[0][0] if len(name_matches) == 1:
elif len(name_matches) == 0: person.id = name_matches[0][0]
warning('No ID found for ' + person.first_name + ' ' + person.last_name) elif len(name_matches) == 0:
else: warning('No ID found for ' + person.first_name + ' ' + person.last_name)
warning('Ambiguous results for ' + person.first_name + ' ' + person.last_name) else:
warning(name_matches) warning('Ambiguous results for ' + person.first_name + ' ' + person.last_name)
warning(name_matches)
if org and org.identifier in (None, '') and org.name not in (None, ''): if org and org.identifier in (None, '') and org.name not in (None, ''):
warning('No ID found for ' + org.name) warning('No ID found for ' + org.name)
......
...@@ -19,7 +19,7 @@ class PyTest(TestCommand): ...@@ -19,7 +19,7 @@ class PyTest(TestCommand):
setup( setup(
name='GcisPyClient', name='GcisPyClient',
version='1.1', version='1.1.1',
author='Andrew Buddenberg', author='Andrew Buddenberg',
author_email='andrew.buddenberg@noaa.gov', author_email='andrew.buddenberg@noaa.gov',
packages=find_packages(), packages=find_packages(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment