Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 15 additions & 8 deletions adsmp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,22 @@ def task_update_record(msg):
record = app.update_storage(m.bibcode, 'nonbib_data', m.toJSON())
if record:
logger.debug('Saved record from list: %s', record)
_generate_boost_request(m, type)
elif type == 'metrics_records':
for m in msg.metrics_records:
m = Msg(m, None, None)
bibcodes.append(m.bibcode)
record = app.update_storage(m.bibcode, 'metrics', m.toJSON(including_default_value_fields=True))
if record:
logger.debug('Saved record from list: %s', record)
_generate_boost_request(m, type)
elif type == 'augment':
bibcodes.append(msg.bibcode)
record = app.update_storage(msg.bibcode, 'augment',
msg.toJSON(including_default_value_fields=True))
if record:
logger.debug('Saved augment message: %s', msg)
_generate_boost_request(msg, type)
elif type == 'classify':
bibcodes.append(msg.bibcode)
logger.debug(f'message to JSON: {msg.toJSON(including_default_value_fields=True)}')
Expand All @@ -178,28 +181,32 @@ def task_update_record(msg):
record = app.update_storage(msg.bibcode, 'classify',payload)
if record:
logger.debug('Saved classify message: %s', msg)
_generate_boost_request(msg, type)
else:
# here when record has a single bibcode
bibcodes.append(msg.bibcode)
record = app.update_storage(msg.bibcode, type, msg.toJSON())
if record:
logger.debug('Saved record: %s', record)
_generate_boost_request(msg, type)
if type == 'metadata':
# with new bib data we request to augment the affiliation
# that pipeline will eventually respond with a msg to task_update_record
logger.debug('requesting affilation augmentation for %s', msg.bibcode)
app.request_aff_augment(msg.bibcode)
if record:
# Send payload to Boost pipeline
if type != 'boost' and not app._config.get('TESTING_MODE', False):
try:
task_boost_request.apply_async(args=(msg.bibcode,))
except Exception as e:
app.logger.exception('Error generating boost request message for bibcode %s: %s', msg.bibcode, e)

else:
logger.error('Received a message with unclear status: %s', msg)

def _generate_boost_request(msg, msg_type):
# Send payload to Boost pipeline
if msg_type not in app._config.get('IGNORED_BOOST_PAYLOAD_TYPES', ['boost']) and not app._config.get('TESTING_MODE', False):
try:
task_boost_request.apply_async(args=(msg.bibcode,))
except Exception as e:
app.logger.exception('Error generating boost request message for bibcode %s: %s', msg.bibcode, e)
else:
app.logger.debug("Message for bibcode %s has type: %s, Skipping.".format(msg.bibcode, msg_type))

@app.task(queue='update-scixid')
def task_update_scixid(bibcodes, flag):
"""Receives bibcodes to add scix id to the record.
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# db connection to the Boost Pipeline database where boost factors are stored
# if not present, boost factors will not be included in SOLR documents
BOOST_SQLALCHEMY_URL = None #'postgresql://boost_user:boost_pass@localhost:5432/boost_db'

IGNORED_BOOST_PAYLOAD_TYPES = ["boost"]

# Main Solr
# SOLR_URLS = ["http://localhost:9983/solr/collection1/update"]
Expand Down