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

Consider CLI for saving account #2054

Open
frankharkins opened this issue Nov 23, 2024 · 2 comments · May be fixed by #2066
Open

Consider CLI for saving account #2054

frankharkins opened this issue Nov 23, 2024 · 2 comments · May be fixed by #2066
Assignees
Labels
enhancement New feature or request

Comments

@frankharkins
Copy link
Member

frankharkins commented Nov 23, 2024

Context

We have a problem with users storing their account tokens in their source code or Jupyter notebook. We're currently writing a guide explaining that you shouldn't do this, but we could probably avoid the situation without additional documentation if we improve the user experience.

A pretty common approach to save user accounts is a CLI. Benefits to user are:

  • Less documentation reading needed; they just run a command that guides them through setting up their account
  • No temptation to leave token in source code or Jupyter notebook
  • Token isn't saved to REPL history

What is the expected feature or enhancement?

A CLI to save your account, made available on install.

Workflow would be along these lines:

  1. User runs command such as:
    $ qiskit-runtime-save-account
    
  2. CLI asks whether to use platform or cloud
  3. CLI prompts for token
  4. CLI prompts again for group and hub. If you wanted to get fancy you could work out which ones they have access to and provide them as options, but just entering the string is fine.
  5. Finally, we write this to file and explain it to the user.

The process could look something like:

$ qiskit-runtime-save-account
Would you like to use (1) ibm_quantum or (2) ibm_cloud?
Type the number and press enter (default ibm_quantum) 1
Using ibm_quantum
Please enter your IBM Quantum token, you can get this from https://quantum.ibm.com/
Please enter the instance you'd like to use (default ibm-q/open/main)
Account saved to ~/.qiskit/qiskit-ibm.json
⚠️ Note your token is saved to disk in plain text. If on a shared computer, make sure to regenerate your token when you're finished.

This CLI can easily be created using built-in Python functionality.

The original .save_account() method can still be public, we'd just recommend the CLI as a better user experience.

Acceptance criteria

Super simple CLI that guides a user through getting account information and saves it to disk. CLI should explain where the information is saved and that it's in plain text.

Nice to have:

  • Select from available options (e.g. we could show the user their available instances and have them enter the list number of the one they want)
  • Choose storing to environment variables rather than disk (if they're using a shared computer and want variables to disappear after their session).
@frankharkins
Copy link
Member Author

If accepted, I'm happy to work on this.

@kt474
Copy link
Member

kt474 commented Nov 26, 2024

If accepted, I'm happy to work on this.

Thank you! It'd be great if you could work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants