Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSK-2782] Allow GiskardClient to read api key from env #1809

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

vjern
Copy link
Contributor

@vjern vjern commented Feb 20, 2024

Description

There exists an env var called GSK_API_KEY used to auto-provide the API key in the giskard worker CLI. It makes sense to reuse the name here.

We may want to also delete it from the environment once it's loaded to prevent leaks as done in the CLI.

I'm worried though that it may destroy the env var in the kernel itself, which would need to be restarted to properly instantiate a new client (or if the user was to reload the same cell where the client gets created).

Todo

  • Update client instantiation documentation to include (or update) a section on setting environment variables so they get picked up by GiskardClient.

Testing Checklist

  • Spin up a notebook with previously set env vars among which GSK_API_KEY
  • Spin up a client without key kwarg and connect to the hub
  • Destroy env var (del os.environ['GSK_API_KEY']) and attempt to re-instantiate client
    • This operation should ideally be idempotent. We could store the env var value as a class field or another property that will not get uploaded with the test code.

Related Issue

Type of Change

  • 馃摎 Examples / docs / tutorials / dependencies update
  • 馃敡 Bug fix (non-breaking change which fixes an issue)
  • 馃 Improvement (non-breaking change which improves an existing feature)
  • 馃殌 New feature (non-breaking change which adds functionality)
  • 馃挜 Breaking change (fix or feature that would cause existing functionality to change)
  • 馃攼 Security fix

Checklist

  • I've read the CODE_OF_CONDUCT.md document.
  • I've read the CONTRIBUTING.md guide.
  • I've updated the code style using make codestyle.
  • I've written tests for all new methods and classes that I created.
  • I've written the docstring in Google format for all the methods and classes that I used.

Copy link

linear bot commented Feb 20, 2024

@@ -138,6 +138,9 @@ def __init__(self, url: str, key: str, hf_token: str = None):

self._session.mount(url, adapter)

if self.key is None:
Copy link
Member

Choose a reason for hiding this comment

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

Nitpicking here, but could you put this check earlier ? like line 133

It's good practice to validate as soon as you can, then do the logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants