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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several changes to support why.init for authenticated users #1311

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

naddeoa
Copy link
Contributor

@naddeoa naddeoa commented Jul 14, 2023

  • Add org id and default dataset id support to sessions.
  • Make sessions depend on the new api key format and update the api key validation to allow for longer api keys that include :orgId.
  • Remove explicit session type configuration and define a fallback system for selecting session type based on allow* flags, config, and env state.
  • Allow specifying default dataset directly to the session config as an alternative to env variables, which is how sessions treat api keys.
  • Add interactive prompt mode for notebook environments that gets api key and related config via input() and saves it to the new whylogs ini config.
  • Add two new files as pseudo CLIs for setting api key/default model id in the whylogs config. Without this, the only way to set the config is via interactive prompt. Supplying that info via env vars doesn't result in persisting that to the config which would be a strange side effect at best since the env is presumably still around and definitely taking priority over the config value.
  • Enable interactive log output and url generation for batch profiles, with or without authentication. This output is disabled in local mode since no uploading happens there. The output only happens when using the top level transient logger in why.log. The loggers themselves don't have any output logic at all. It wouldn't make much sense to add output of this sort to the rolling logger running in the background.
  • Add lots of docs to why.init since that's the main interface to this system for users. The goal with these docs is to make it clear what kind of session you'll be getting since the logic is a little more complicated than before. The upside to this approach is that most notebooks, scripts, and production jobs can just have why.init() and not worry about what arguments to supply, so it can truly be ubiquitous.

Reviewing

To get a sense of the UX introduced here, I recommend running the Guest Session example notebook, as well as running python -m whylogs.api.whylabs.session.why_init from the command line. The first one should be pretty representative of a typical user experience after this change and the second one is a psuedo-cli that users can use to repeat the first UX without having to spin up a notebook. The command is similar to running aws sso configure, it just gets everything it needs from a user and stores it locally in the new whylogs.ini config.

@naddeoa naddeoa force-pushed the authenticated-sessions branch 4 times, most recently from 0782060 to 2ae41f2 Compare July 14, 2023 19:57
@naddeoa naddeoa changed the title [DRAFT] Several changes to support why.init for authenticated users Several changes to support why.init for authenticated users Jul 17, 2023
@naddeoa naddeoa force-pushed the authenticated-sessions branch 3 times, most recently from 1b5f3dd to eb5126f Compare July 17, 2023 22:24
@naddeoa
Copy link
Contributor Author

naddeoa commented Jul 17, 2023

@jamie256 @andyndang Looks like there are 36 different example notebooks that included WHYLABS_API_KEY. All of those will have to be updated. I'm going to hold off on touching those until I know this PR and the new doc page look good though. I have to take an inventory of the things that need to change on the doc site as well.

@naddeoa naddeoa force-pushed the authenticated-sessions branch 2 times, most recently from 88579c8 to 11b039a Compare July 17, 2023 23:22
Copy link
Contributor

@FelipeAdachi FelipeAdachi left a comment

Choose a reason for hiding this comment

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

I just ran the Writing_Regression_Performance_Metrics_to_WhyLabs without any changes on this branch, and some things to note:

  • There are some rather spammy messages, when logging:
    • 😭 No active session found because why.init() wasn't used. Skipping reference profile upload. Start a session with why.init(session_type='whylabs_anonymous') writing profiles to whylabs...
  • and also when calling results.writer("whylabs").write():
    • Initialing session with config /home/felipeadachi/.config/whylogs/config.ini Initialing session with config /home/felipeadachi/.config/whylogs/config.ini No session is initialized. Call whylogs.init(anonymous=True) to create a guest session. No session is initialized. Call whylogs.init(anonymous=True) to create a guest session.

This feels like something wrong is happening, but I'm just logging the usual way by setting os.environ (and it works normally)

Maybe we could set this as info instead of warning?
Or is this now an unrecommended approach, and we always want to call why.init()?

Copy link
Contributor

@richard-rogers richard-rogers left a comment

Choose a reason for hiding this comment

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

LGTM

@naddeoa naddeoa force-pushed the authenticated-sessions branch 3 times, most recently from b0087ef to 722a509 Compare August 1, 2023 19:22
@naddeoa
Copy link
Contributor Author

naddeoa commented Aug 1, 2023

I just ran the Writing_Regression_Performance_Metrics_to_WhyLabs without any changes on this branch, and some things to note:

* There are some rather spammy messages, when logging:
  
  * `😭 No active session found because why.init() wasn't used. Skipping reference profile upload. Start a session with why.init(session_type='whylabs_anonymous') writing profiles to whylabs...`

* and also when calling `results.writer("whylabs").write()`:
  
  * `Initialing session with config /home/felipeadachi/.config/whylogs/config.ini Initialing session with config /home/felipeadachi/.config/whylogs/config.ini No session is initialized. Call whylogs.init(anonymous=True) to create a guest session. No session is initialized. Call whylogs.init(anonymous=True) to create a guest session.`

This feels like something wrong is happening, but I'm just logging the usual way by setting os.environ (and it works normally)

Maybe we could set this as info instead of warning? Or is this now an unrecommended approach, and we always want to call why.init()?

This has been fixed. You'll now only see the warning one time and you won't see any other output unless you actually have a session, so if people run that notebook before we update it with our latest whylogs then they'll just see a warning that they don't have a session set up.

@naddeoa naddeoa force-pushed the authenticated-sessions branch 3 times, most recently from 3ceaf9d to 6ba7aed Compare August 1, 2023 21:47
Copy link
Contributor

@jamie256 jamie256 left a comment

Choose a reason for hiding this comment

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

Looks close, left two questions.

@naddeoa naddeoa force-pushed the authenticated-sessions branch 2 times, most recently from bc3c303 to ad88919 Compare August 8, 2023 21:23
- Add org id and default dataset id support to sessions.
- Make sessions depend on the new api key format and update the api key
  validation to allow for longer api keys that include `:orgId`.
- Remove explicit session type configuration and define a fallback
  system for selecting session type based on `allow*` flags, config, and
  env state.
- Allow specifying default dataset directly to the session config as an
  alternative to env variables, which is how sessions treat api keys.
- Add interactive prompt mode for notebook environments that gets api
  key and related config via `input()` and saves it to the new whylogs
  ini config.
- Add new why_init as pseudo CLIs for setting api key/default model id
  in the whylogs config. Without this, the only way to set the config is
  via interactive prompt. Supplying that info via env vars doesn't
  result in persisting that to the config which would be a strange side
  effect at best since the env is presumably still around and definitely
  taking priority over the config value. This can be run on the cli via
  `python -m whylogs.api.whylabs.session.why_init` from an environment
  with whylogs installed.
- Enable interactive log output and url generation for batch profiles,
  with or without authentication. This output is disabled in local mode
  since no uploading happens there. The output only happens when using
  the top level transient logger in `why.log`. The loggers themselves
  don't have any output logic at all. It wouldn't make much sense to add
  output of this sort to the rolling logger running in the background.
- Add lots of docs to `why.init` since that's the main interface to this
  system for users. The goal with these docs is to make it clear what
  kind of session you'll be getting since the logic is a little more
  complicated than before. The upside to this approach is that most
  notebooks, scripts, and production jobs can just have `why.init()` and
  not worry about what arguments to supply, so it can truly be
  ubiquitous.
Copy link
Contributor

@jamie256 jamie256 left a comment

Choose a reason for hiding this comment

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

LGTM!

@jamie256 jamie256 merged commit 945d325 into mainline Aug 9, 2023
19 checks passed
@jamie256 jamie256 deleted the authenticated-sessions branch August 9, 2023 15:40
jamie256 pushed a commit that referenced this pull request Oct 3, 2023
… validation function (#1391)

## Description

Bug fix: removing reference to `_validate_org_and_dataset` in
`tag_custom_performance_metric`, which was removed in
#1311.

- [x] I have reviewed the [Guidelines for Contributing](CONTRIBUTING.md)
and the [Code of Conduct](CODE_OF_CONDUCT.md).

Co-authored-by: felipe207 <felipe@whylabs.ai>
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.

None yet

5 participants