dxf icon indicating copy to clipboard operation
dxf copied to clipboard

Error during token authentication: `KeyError: 'service'`

Open jvstme opened this issue 1 year ago • 0 comments

Steps to reproduce

This example uses the NVIDIA NGC registry, but the issue may be relevant for other registries too.

  1. Get an NGC API key as described here.
  2. Subscribe to the NVIDIA Developer Program by clicking "Get Container" here.
  3. Create test.py.
    import os
    from dxf import DXF
    
    def auth(dxf, response):
        dxf.authenticate('$oauthtoken', os.getenv('NGC_API_KEY'), response=response)
    
    dxf = DXF('nvcr.io', 'nim/meta/llama3-8b-instruct', auth)
    print(dxf.get_manifest('latest'))
    
  4. Run test.py
    $ NGC_API_KEY=<your-api-key> python test.py
    

Actual behavior

Traceback (most recent call last):
  File "/tmp/test/test.py", line 8, in <module>
    print(dxf.get_manifest('latest'))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/test/venv/lib64/python3.12/site-packages/dxf/__init__.py", line 684, in get_manifest
    return self._get_alias(alias, None, True, False, False, False, True, platform, True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/test/venv/lib64/python3.12/site-packages/dxf/__init__.py", line 613, in _get_alias
    manifest, r = self.get_manifest_and_response(alias)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/test/venv/lib64/python3.12/site-packages/dxf/__init__.py", line 591, in get_manifest_and_response
    r = self._request('get',
        ^^^^^^^^^^^^^^^^^^^^
  File "/tmp/test/venv/lib64/python3.12/site-packages/dxf/__init__.py", line 390, in _request
    return self._base_request(
           ^^^^^^^^^^^^^^^^^^^
  File "/tmp/test/venv/lib64/python3.12/site-packages/dxf/__init__.py", line 222, in _base_request
    self._auth(self, r)
  File "/tmp/test/test.py", line 5, in auth
    dxf.authenticate('$oauthtoken', os.getenv('NGC_API_KEY'), response=response)
  File "/tmp/test/venv/lib64/python3.12/site-packages/dxf/__init__.py", line 305, in authenticate
    query.append(('service', info['service']))
                             ~~~~^^^^^^^^^^^
KeyError: 'service'

Expected behavior

Prints the image manifest.

jvstme avatar Oct 15 '24 12:10 jvstme