caltechlibrary / iga

IGA is the InvenioRDM GitHub Archiver, a standalone program as well as a GitHub Action that lets you automatically archive GitHub software releases in an InvenioRDM repository.
https://caltechlibrary.github.io/iga/
Other
8 stars 1 forks source link

Resolving invenio_server_name #39

Open panta-123 opened 2 weeks ago

panta-123 commented 2 weeks ago

Description

When I runiga -d -o <version>, I get:

 File "/Users/panta/invenio_github_archiver/venv/lib/python3.12/site-packages/iga/invenio.py", line 133, in invenio_server_name

This line: https://github.com/caltechlibrary/iga/blob/develop/iga/invenio.py#L130

It looks like data that my inveniordm server provides is:

 {'hits': {'hits': [], 'total': 0}, 'aggregations': {'access_status': {'buckets': [], 'label': 'Access status'}, 'file_type': {'buckets': [], 'label': 'File type'}, 'resource_type': {'buckets': [], 'label': 'Resource types'}, 'target': {'buckets': [], 'label': 'target'}, 'beam': {'buckets': [], 'label': 'beam'}, 'division': {'buckets': [], 'label': 'Division'}, 'pac_status': {'buckets': [], 'label': 'Pac Status'}, 'pac_rating': {'buckets': [], 'label': 'Pac Rating'}}, 'sortBy': 'newest', 'links': {'self': 'https://vulcan.jlab.org/api/records?page=1&size=1&sort=newest'}}

data.get('hits', {}).get('hits') is a list and is empty meaning the line : https://github.com/caltechlibrary/iga/blob/develop/iga/invenio.py#L130 gives an error.

Solution idea:

On code bolck: https://github.com/caltechlibrary/iga/blob/develop/iga/invenio.py#L130-L135

        if response := network('get', server_url + endpoint):
            log(f'we can reach {server_url} and it responds to {endpoint}')
            data = response.json()
            record = data.get('hits', {}).get('hits', [])
            if record:
                 if publisher := record[0].get('metadata', {}).get('publisher'):
                       return publisher
            else:
               return server_host

Software environment

$ iga --version iga version 1.3.0 Authors: Michael Hucka URL: https://caltechlibrary.github.io/iga License: https://github.com/caltechlibrary/iga/blob/main/LICENSE

tmorrell commented 2 weeks ago

Thanks for the report; it's because your repo has no public records. I've created a PR https://github.com/caltechlibrary/iga/pull/41 which will fix the issue, but we probably won't be able to get a release out for a few weeks.

panta-123 commented 2 weeks ago

Ah got it. I tried it on dev server after doing wipe and recreate. Thank you for quick fix.