Setup optional Ocean packages and configuration file(s). Equivalent to running `dwave install [--all]`, followed by an optional `dwave auth login --skip-valid [--oob]` and then by `dwave config create [--full] [--auto-token]`.
(install_all, auth, project, oob, ask_full, verbose, output)
| 953 | help='Increase output verbosity (additive, up to 4 times)') |
| 954 | @standardized_output |
| 955 | def setup(install_all, auth, project, oob, ask_full, verbose, output): |
| 956 | """Setup optional Ocean packages and configuration file(s). |
| 957 | |
| 958 | Equivalent to running `dwave install [--all]`, followed by |
| 959 | an optional `dwave auth login --skip-valid [--oob]` and then by |
| 960 | `dwave config create [--full] [--auto-token]`. |
| 961 | """ |
| 962 | |
| 963 | contrib = get_contrib_packages() |
| 964 | packages = list(contrib) |
| 965 | |
| 966 | if not packages: |
| 967 | install = False |
| 968 | elif install_all: |
| 969 | click.echo("Installing all optional non-open-source packages.\n") |
| 970 | install = True |
| 971 | else: |
| 972 | # The default flow: SDK installed, so some contrib packages registered |
| 973 | # and `dwave setup` ran without `--all` flag. |
| 974 | click.echo("Optionally install non-open-source packages and " |
| 975 | "configure your environment.\n") |
| 976 | |
| 977 | # Skip the prompt if all contrib packages already installed |
| 978 | if all(_contrib_package_maybe_installed(name) for name in contrib): |
| 979 | click.echo("All optional packages already installed.") |
| 980 | install = False |
| 981 | else: |
| 982 | prompt = "Do you want to select non-open-source packages to install (y/n)?" |
| 983 | val = default_text_input(prompt, default='y') |
| 984 | install = val.lower() == 'y' |
| 985 | click.echo() |
| 986 | |
| 987 | if install: |
| 988 | for pkg in packages: |
| 989 | _install_contrib_package(pkg, verbose=verbose, prompt=not install_all) |
| 990 | |
| 991 | auto_token = False |
| 992 | if auth or oob: |
| 993 | click.echo("Authorizing Leap access.\n") |
| 994 | _login(config_file=None, profile=None, oob=oob, skip_valid=True, output=output) |
| 995 | click.echo() |
| 996 | auto_token = True |
| 997 | ask_full = False |
| 998 | |
| 999 | click.echo("Creating the D-Wave configuration file.\n") |
| 1000 | return _config_create(config_file=None, profile=None, ask_full=ask_full, |
| 1001 | auto_token=auto_token, project=project) |
| 1002 | |
| 1003 | |
| 1004 | @cli.group() |
no test coverage detected