dwavesystems / dwave-cloud-client

A minimal implementation of the REST interface used to communicate with D-Wave Solver API (SAPI) servers.
https://docs.ocean.dwavesys.com/projects/cloud-client/en/stable/
Apache License 2.0
59 stars 40 forks source link

Add optional authorization to `dwave setup` #597

Closed randomir closed 1 year ago

randomir commented 1 year ago

We add --auth, --project and --oob options to dwave setup.

$ dwave setup --help
Usage: dwave setup [OPTIONS]

  Setup optional Ocean packages and configuration file(s).

  Equivalent to running `dwave install [--all]`, followed by an optional
  `dwave auth login [--oob]` and then by `dwave config create [--full]
  [--auto-token]`.

Options:
  -a, --install-all, --all  Install all non-open-source packages available and
                            accept licenses without prompting
  --auth                    Authorize Ocean to access Leap API on user's
                            behalf. Implies --auto-token during 'dwave config
                            create' and it's mutually exclusive with --full.
  --project TEXT            Leap project for which SAPI token is pulled.
                            Defaults to active project.
  --oob                     Same as '--auth', but using OAuth out-of-band
                            flow. Use when 'localhost' not available in your
                            browser.
  --full                    Configure non-essential options manually (such as
                            endpoint and solver).
  -v, --verbose             Increase output verbosity (additive, up to 4
                            times)  [default: 0]
  --help                    Show this message and exit.

We now also skip contrib package(s) install/prompt if all packages are already installed.

$ dwave setup --auth
Optionally install non-open-source packages and configure your environment.

All optional packages already installed.

Authorizing Leap access.

Valid token found, skipping authorization.

Creating the D-Wave configuration file.

Using the simplified configuration flow.
Try 'dwave config create --full' for more options.

Updating existing configuration file: /home/user/.config/dwave/dwave.conf
Available profiles: defaults, prod, test
Updating existing profile: defaults
Fetched SAPI token for project 'Project' (PROJ) from Leap API.
Configuration saved.

Close #591.

codecov[bot] commented 1 year ago

Codecov Report

Merging #597 (af768f3) into master (cf986df) will increase coverage by 1.05%. The diff coverage is 51.51%.

@@            Coverage Diff             @@
##           master     #597      +/-   ##
==========================================
+ Coverage   87.29%   88.35%   +1.05%     
==========================================
  Files          33       33              
  Lines        4314     4337      +23     
==========================================
+ Hits         3766     3832      +66     
+ Misses        548      505      -43     
Files Coverage Δ
dwave/cloud/auth/flows.py 93.75% <66.66%> (-0.51%) :arrow_down:
dwave/cloud/cli.py 67.72% <50.00%> (+7.63%) :arrow_up:

... and 1 file with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more