Skip to content

Commit

Permalink
Merge pull request #53 from spacemansteve/master
Browse files Browse the repository at this point in the history
updated aff protobuf to match current plans
  • Loading branch information
spacemansteve authored Dec 3, 2018
2 parents dcb6f6d + 8ef739c commit 5760034
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 94 deletions.
77 changes: 42 additions & 35 deletions adsmsg/protobuf/augmentrecord_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

122 changes: 74 additions & 48 deletions adsmsg/tests/test_affiliation_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,82 +13,108 @@ def tearDown(self):
unittest.TestCase.tearDown(self)

def test_affiliation_request(self):
d = {'bibcode': '2003ASPC..295..361M',
'status': 2,
'affiliation': 'University of Deleware',
'author': 'Stephen McDonald',
'sequence': '1/2'}
d = {'bibcode': '1983ESASP.201...47K',
'status': 2,
'aff': [
"Harvard-Smithsonian Center for Astrophysics, Cambridge, MA."
],
"author": [
"Kurtz, M. J."
]}
a = AugmentAffiliationRequestRecord(**d)
self.assertEqual(a.bibcode, d['bibcode'])
self.assertEqual(a.status, d['status'])
self.assertEqual(a.affiliation, d['affiliation'])
self.assertEqual(a.aff, d['aff'])
self.assertEqual(a.author, d['author'])
self.assertEqual(a.sequence, d['sequence'])


def test_affiliation_request_list(self):
d_list = [{'bibcode': '2003ASPC..295..361M',
'status': 2,
'affiliation': 'University of Deleware',
'author': 'Stephen McDonald',
'sequence': '1/2'},
{'bibcode': '2003ASPC..295..361Z',
'status': 2,
'affiliation': 'University of Zeleware',
'author': 'Ztephen McDonald',
'sequence': '2/2'}]
d_list = [{'bibcode': '1983ESASP.201...47K',
'status': 2,
'aff': [
"Harvard-Smithsonian Center for Astrophysics, Cambridge, MA."
],
"author": [
"Kurtz, M. J."
]}]
m = AugmentAffiliationRequestRecordList()
m.status = 2
for r in d_list:
m.affiliation_requests.add(**r)
for i in range(len(d_list)):
self.assertEqual(m.affiliation_requests[i].bibcode, d_list[i]['bibcode'])
self.assertEqual(m.affiliation_requests[i].status, d_list[i]['status'])
self.assertEqual(m.affiliation_requests[i].affiliation, d_list[i]['affiliation'])
self.assertEqual(m.affiliation_requests[i].aff, d_list[i]['aff'])
self.assertEqual(m.affiliation_requests[i].author, d_list[i]['author'])
self.assertEqual(m.affiliation_requests[i].sequence, d_list[i]['sequence'])


def test_affiliation_response(self):
d = {'bibcode': '2003ASPC..295..361M',
d = {'bibcode': '1983ESASP.201...47K',
'status': 2,
'affiliation': 'University of Deleware',
'author': 'Stephen McDonald',
'sequence': '1/2',
'canonical_affiliation': 'U of D',
'canonical_affiliation_id': '1'}
'aff': [
"Harvard-Smithsonian Center for Astrophysics, Cambridge, MA."
],
"author": [
"Kurtz, M. J."
],
"aff_abbrev": [
"CfA"
],
"aff_canonical": [
"Harvard Smithsonian Center for Astrophysics"
],
"aff_facet_hier": [
"0/Harvard U",
"1/Harvard U/CfA",
"0/SI",
"1/SI/CfA"
],
"aff_id": ['placeholder']
}
a = AugmentAffiliationResponseRecord(**d)
self.assertEqual(a.bibcode, d['bibcode'])
self.assertEqual(a.status, d['status'])
self.assertEqual(a.affiliation, d['affiliation'])
self.assertEqual(a.aff, d['aff'])
self.assertEqual(a.author, d['author'])
self.assertEqual(a.sequence, d['sequence'])
self.assertEqual(a.canonical_affiliation, d['canonical_affiliation'])
self.assertEqual(a.canonical_affiliation_id, d['canonical_affiliation_id'])
self.assertEqual(a.aff_abbrev, d['aff_abbrev'])
self.assertEqual(a.aff_canonical, d['aff_canonical'])
self.assertEqual(a.aff_facet_hier, d['aff_facet_hier'])
self.assertEqual(a.aff_id, d['aff_id'])

def test_affiliation_response_list(self):
d_list = [{'bibcode': '2003ASPC..295..361M',
'status': 2,
'affiliation': 'University of Deleware',
'author': 'Stephen McDonald',
'sequence': '1/2',
'canonical_affiliation': 'U of D',
'canonical_affiliation_id': '1'},
{'bibcode': '2003ASPC..295..361Z',
'status': 2,
'affiliation': 'University of Zeleware',
'author': 'Ztephen McDonald',
'sequence': '2/2',
'canonical_affiliation': 'U of Z',
'canonical_affiliation_id': '2'}]
d = {'bibcode': '1983ESASP.201...47K',
'status': 2,
'aff': [
"Harvard-Smithsonian Center for Astrophysics, Cambridge, MA."
],
"author": [
"Kurtz, M. J."
],
"aff_abbrev": [
"CfA"
],
"aff_canonical": [
"Harvard Smithsonian Center for Astrophysics"
],
"aff_facet_hier": [
"0/Harvard U",
"1/Harvard U/CfA",
"0/SI",
"1/SI/CfA"
],
"aff_id": ['placeholder']
}
d_list = [d]
m = AugmentAffiliationResponseRecordList()
m.status = 2
for r in d_list:
m.affiliation_responses.add(**r)
for i in range(len(d_list)):
self.assertEqual(m.affiliation_responses[i].bibcode, d_list[i]['bibcode'])
self.assertEqual(m.affiliation_responses[i].status, d_list[i]['status'])
self.assertEqual(m.affiliation_responses[i].affiliation, d_list[i]['affiliation'])
self.assertEqual(m.affiliation_responses[i].aff, d_list[i]['aff'])
self.assertEqual(m.affiliation_responses[i].author, d_list[i]['author'])
self.assertEqual(m.affiliation_responses[i].sequence, d_list[i]['sequence'])
self.assertEqual(m.affiliation_responses[i].canonical_affiliation, d_list[i]['canonical_affiliation'])
self.assertEqual(m.affiliation_responses[i].canonical_affiliation_id, d_list[i]['canonical_affiliation_id'])
self.assertEqual(m.affiliation_responses[i].aff_abbrev, d_list[i]['aff_abbrev'])
self.assertEqual(m.affiliation_responses[i].aff_canonical, d_list[i]['aff_canonical'])
self.assertEqual(m.affiliation_responses[i].aff_facet_hier, d_list[i]['aff_facet_hier'])
self.assertEqual(m.affiliation_responses[i].aff_id, d_list[i]['aff_id'])

26 changes: 15 additions & 11 deletions specs/augmentrecord.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ syntax = "proto3";
import "status.proto";
package adsmsg;

// all fields required in the data frame that are sent to the classifier
// send this to augmentation_pipeline to augment a single affiliation
// all fields required in the data frame that are sent to aff augmentation
// send this to augmentation_pipeline to augment all authors for a bibcode
message AugmentAffiliationRequestRecord {
string bibcode = 1;
Status status = 2;
string affiliation = 3;
string author = 4;
string sequence = 5;
repeated string aff = 3;
repeated string author = 4;
}

// also support lists of the above
Expand All @@ -18,15 +17,20 @@ message AugmentAffiliationRequestRecordList {
Status status = 2;
}

// after running classifier, this record is sent on to master
// the aff augmentation eventually sends this record to master
message AugmentAffiliationResponseRecord {
// data sent for augmentation
string bibcode = 1;
Status status = 2;
string affiliation = 3;
string author = 4;
string sequence = 5;
string canonical_affiliation = 6;
string canonical_affiliation_id = 7;
repeated string aff = 3;
repeated string author = 4;

// calculated values for solr fields
repeated string aff_abbrev = 5;
repeated string aff_canonical = 6;
repeated string aff_facet = 7;
repeated string aff_facet_hier = 8;
repeated string aff_id = 9;
}

// also support lists of the above
Expand Down

0 comments on commit 5760034

Please sign in to comment.