Commit 21fdef44 authored by abuddenberg's avatar abuddenberg
Browse files

Update project to version 1.1

Documentation, such as it is, has been updated to reflect changes
to the domain model and client functionality.  These changes also
break the nca3-specific sync_figures and problems scripts, which
are now deprecated.  There was also a bug in the test suite.
parent 7c913438
...@@ -93,3 +93,27 @@ Let's see about the images: ...@@ -93,3 +93,27 @@ Let's see about the images:
How about the whole Image?: How about the whole Image?:
print gcis.get_image('69da6d93-4426-4061-a2a1-7b3d01f2dc1c').as_json(indent=4) print gcis.get_image('69da6d93-4426-4061-a2a1-7b3d01f2dc1c').as_json(indent=4)
Want to find the lineage of a publication?
fig2_1 = gcis.get_figure('nca3', 'ten-indicators-of-a-warming-world')
print fig2_1.parents
Add a parent to a figure directly...
cmip3 = gcis.get_dataset('nca3-cmip3-r201205')
gcis.associate_figure_with_parent('nca3', 'ten-indicators-of-a-warming-world', Parent.from_obj(cmip3))
...or as part of an update
fig2_1.add_parent(Parent.from_obj(cmip3))
gcis.update_figure('nca3', 'our-changing-climate', fig2_1)
**NOTE:** GcisClient will disassociate and then reassociate Parents as part of an update. Adding a new Parent during an
update will cause "Parent dissociation failed" messages to appear--these can be safely ignored.
**ALSO:** Updates do NOT, presently, remove parents you have not included on the Figure object.
Remove a parent from a figure
gcis.delete_figure_parent_assoc('nca3', 'ten-indicators-of-a-warming-world', Parent.from_obj(cmip3))
...@@ -170,4 +170,6 @@ def sort_webform_list(report_id): ...@@ -170,4 +170,6 @@ def sort_webform_list(report_id):
if __name__ == '__main__': if __name__ == '__main__':
main() print 'The problems script is no longer maintained (and was a bad idea in the first place).'
# Think really hard about uncommenting this, then don't.
# main()
...@@ -445,4 +445,6 @@ def cleanup_after_replace(): ...@@ -445,4 +445,6 @@ def cleanup_after_replace():
print gcis.associate_image_with_figure(image_id, 'nca3', figure_id) print gcis.associate_image_with_figure(image_id, 'nca3', figure_id)
if __name__ == '__main__': if __name__ == '__main__':
main() print 'The sync_figures script is no longer maintained and is for reference only.'
# Uncomment at your own risk.
# main()
#!/usr/bin/env python #!/usr/bin/env python
from gcis_clients import GcisClient, gcis_dev_auth from gcis_clients import GcisClient, gcis_dev_auth
from gcis_clients.domain import Parent
base_url = 'http://data.globalchange.gov' base_url = 'http://data.globalchange.gov'
...@@ -38,9 +39,17 @@ for image in fig2_7.images: ...@@ -38,9 +39,17 @@ for image in fig2_7.images:
#How about the whole Image? #How about the whole Image?
print gcis.get_image('69da6d93-4426-4061-a2a1-7b3d01f2dc1c').as_json(indent=4) print gcis.get_image('69da6d93-4426-4061-a2a1-7b3d01f2dc1c').as_json(indent=4)
#Let's assign some GCMD keywords (The first 4 from the list) #Want to find the lineage of a publication?
# keyword_ids = [k['identifier'] for k in gcis.get_keyword_listing()[0:4]] fig2_1 = gcis.get_figure('nca3', 'ten-indicators-of-a-warming-world')
print fig2_1.parents
# for keyword_id in keyword_ids: #Add a parent to a figure directly...
# resp = gcis.associate_keyword_with_figure(keyword_id, 'nca3draft', 'observed-us-temperature-change') cmip3 = gcis.get_dataset('nca3-cmip3-r201205')
# print resp.status_code, resp.text gcis.associate_figure_with_parent('nca3', 'ten-indicators-of-a-warming-world', Parent.from_obj(cmip3))
#...or as part of an update
fig2_1.add_parent(Parent.from_obj(cmip3))
gcis.update_figure('nca3', 'our-changing-climate', fig2_1)
#Remove a parent from a figure
gcis.delete_figure_parent_assoc('nca3', 'ten-indicators-of-a-warming-world', Parent.from_obj(cmip3))
...@@ -293,7 +293,7 @@ class Dataset(GcisObject): ...@@ -293,7 +293,7 @@ class Dataset(GcisObject):
@publication_year.setter @publication_year.setter
def publication_year(self, value): def publication_year(self, value):
match = re.search('\d{4}', value) if value else None match = re.search('\d{4}', str(value)) if value else None
if match: if match:
self._publication_year = match.group() self._publication_year = match.group()
else: else:
......
...@@ -32,7 +32,6 @@ def test_gcis_client_init_modes(monkeypatch, capsys): ...@@ -32,7 +32,6 @@ def test_gcis_client_init_modes(monkeypatch, capsys):
gcis = GcisClient() gcis = GcisClient()
out, err = capsys.readouterr() out, err = capsys.readouterr()
assert out == 'Using http://data.globalchange.gov\n'
assert gcis.base_url == 'http://data.globalchange.gov' assert gcis.base_url == 'http://data.globalchange.gov'
assert gcis.s.auth == (test_user, test_apikey) assert gcis.s.auth == (test_user, test_apikey)
......
...@@ -19,11 +19,11 @@ class PyTest(TestCommand): ...@@ -19,11 +19,11 @@ class PyTest(TestCommand):
setup( setup(
name='GcisPyClient', name='GcisPyClient',
version='1.0', version='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(),
scripts=['bin/example', 'bin/problems', 'bin/sync_figures'], scripts=['bin/example', 'bin/sync_surveys'],
url='http://data.globalchange.gov', url='http://data.globalchange.gov',
description='Client for GCIS webservices', description='Client for GCIS webservices',
long_description=open('README.md').read(), long_description=open('README.md').read(),
......
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