Skip to content

Commit

Permalink
Add --client option to dwave solvers to fix --all
Browse files Browse the repository at this point in the history
Until now `--all` would not reset the `client`, but would use the
client type setting from config file/env. Hence, possibly not listing
all solvers.

Close #457.
  • Loading branch information
randomir committed Feb 11, 2021
1 parent 9460a79 commit 51301bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dwave/cloud/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,24 +337,29 @@ def flush():
@click.option('--config-file', '-c', default=None,
type=click.Path(exists=True, dir_okay=False), help='Configuration file path')
@click.option('--profile', '-p', default=None, help='Connection profile name')
@click.option('--client', 'client_type', default=None,
type=click.Choice(['base', 'qpu', 'sw', 'hybrid'], case_sensitive=False),
help='Client type used (default: from config)')
@click.option('--solver', '-s', 'solver_def', default=None,
help='Feature-based solver filter (default: from config)')
@click.option('--list', '-l', 'list_solvers', default=False, is_flag=True,
help='Print filtered list of solver names, one per line')
@click.option('--all', '-a', 'list_all', default=False, is_flag=True,
help='Ignore solver filter (list/print all solvers)')
def solvers(config_file, profile, solver_def, list_solvers, list_all):
def solvers(config_file, profile, client_type, solver_def, list_solvers, list_all):
"""Get solver details.
Solver filter is inherited from environment or the specified configuration
file and profile.
"""

if list_all:
client_type = 'base'
solver_def = '{}'

with Client.from_config(
config_file=config_file, profile=profile, solver=solver_def) as client:
config_file=config_file, profile=profile,
client=client_type, solver=solver_def) as client:

try:
solvers = client.get_solvers(**client.default_solver)
Expand Down

0 comments on commit 51301bb

Please sign in to comment.