Skip to content

Scix id support#109

Merged
ehenneken merged 5 commits intoadsabs:masterfrom
ehenneken:scix_id_support
Oct 10, 2025
Merged

Scix id support#109
ehenneken merged 5 commits intoadsabs:masterfrom
ehenneken:scix_id_support

Conversation

@ehenneken
Copy link
Copy Markdown
Member

This update update of the graphics_service accomplishes the following:

  • Alembic update of the database schema that adds one column to hold SciX IDs
  • Update the query logic so that backward compatibility is guaranteed (bibcodes and SciX IDs are both supported)
  • Appropriate renaming of variables to de-prioritize the bibcode

The query

        resp = session.query(GraphicsModel).filter(
             or_(GraphicsModel.scix_id == ident, GraphicsModel.bibcode == ident)).one()
        results = json.loads(json.dumps(resp, cls=AlchemyEncoder))

will fail if the scix_id column does not exsist. Since this column will be added with this new release, it seems unnecessary to require the code to be able to run against a database with the old schema.

After the new release has been deployed, the database with be provisioned with appropriate SciX ID values.

Copy link
Copy Markdown
Member

@kelockhart kelockhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly small stuff, but one more test would be good to make sure we can handle records without bibcodes. Plus a clarifying question on the source renaming.

README.md Outdated
curl http://localhost:4000/<identifier>

and you should get back graphics data
and you should get back graphics data. The identifier supplied should either be a bibcode or a SciX ID.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an example of a SciX ID - I imagine (at least at first) some confusion over whether to include the scix: part of the identifier

res = {'Error': 'Unable to get results!', 'Error Info': 'No database entry found for %s' % identifier}
except Exception as err:
res = {'Error': 'Unable to get results!', 'Error Info': 'Graphics query failed for %s: %s'%(bibcode, err)}
res = {'Error': 'Unable to get results!', 'Error Info': 'Graphics query failed for %s: %s'%(identifier, err)}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add explicit handling for MultipleResultsFound as well, just in case

output['scix_id'] = results['scix_id']
# We still include the value in the "bibcode" column in the output
# For backwards compatibility
output['bibcode'] = results['bibcode']
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be possible in the near future to have a record with a SciX ID but no bibcode - probably best to do a results.get('bibcode') (which will return None if it needs to) vs results['bibcode'] which would give a KeyError if there's no bibcode for that record

@mock.patch('graphics_service.models.execute_SQL_query', return_value=get_testdata(figures=figure_data))
def test_query(self, mock_execute_SQL_query):
def test_query_with_scixid(self, mock_execute_SQL_query):
'''Query endpoint with bibcode from stub data should
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy/paste error here - bibcode --> SciX ID

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be good to add one test where there's a GraphicsModel with a SciX ID but no bibcode, just to make sure that part works

'OUP':'Every image links to the article on <a href="https://academic.oup.com/mnras/" target="_new">Monthly Notices of the RAS</a>',
'IOP':'Every image links to the <a href="http://www.astroexplorer.org/" target="_new">AAS "Astronomy Image Explorer"</a> for more detail.',
'IOPscience':'Every image links to the article on <a href="http://iopscience.iop.org/" target="_new">IOPscience</a>',
'AAS':'Every image links to the <a href="http://www.astroexplorer.org/" target="_new">AAS "Astronomy Image Explorer"</a> for more detail.',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this renaming mean we need to update whatever is currently stored in the graphics db to match the new naming scheme?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing that changes in the graphics db is the addition of the column for the SciX ID. Everything else remains unchanged.

Copy link
Copy Markdown
Member

@kelockhart kelockhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ehenneken ehenneken merged commit ad08292 into adsabs:master Oct 10, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants