sf.cli¶
The Strawberry Fields command line program sf
provides several utilities
including:
sf configure [--token] [--local]
: configure the connection to the cloud platformsf run INFILE [--output FILE]
: submit and execute Blackbird scripts containing quantum programs from the command linesf --ping
: verify your connection to the Xanadu cloud platform
Configure¶
Using the sf configure
command to create a configuration file on Linux:
$ sf configure --token AUTHENTICATION_TOKEN
$ cat ~/.config/strawberryfields/config.toml
[api]
authentication_token = "AUTHENTICATION_TOKEN"
hostname = "platform.strawberryfields.ai"
use_ssl = true
port = 443
Using the sf configure
command to create a configuration file on Windows:
C:\> sf configure --token AUTHENTICATION_TOKEN
C:\> type C:\Users\USERNAME\AppData\Local\Xanadu\strawberryfields\config.toml
[api]
authentication_token = "AUTHENTICATION_TOKEN"
hostname = "platform.strawberryfields.ai"
use_ssl = true
port = 443
In both the above examples, replace AUTHENTICATION_TOKEN
above with your
Xanadu cloud access token.
Flags:
--token
: the authentication token to use--local
: causes the configuration file to be created locally in the current directory
If --local
is not provided, the configuration file will be saved in the user’s configuration directory.
See also
Configuration wizard¶
For more advanced configuration options, the configuration wizard can be used.
Here we show how the interactive wizard can be used to configure each API option. Once done, we have a look at the newly created configuration file.
Example run in a Linux-based operating system:
$ sf configure
Please enter the authentication token to use when connecting: [] AUTHENTICATION_TOKEN
Please enter the hostname of the server to connect to: [platform.strawberryfields.ai] MYHOST
Should the client attempt to connect over SSL? [y] N
Please enter the port number to connect with: [443] 12345
$ cat ~/.config/strawberryfields/config.toml
[api]
authentication_token = "AUTHENTICATION_TOKEN"
hostname = "MYHOST"
use_ssl = false
port = "12345"
The same example run on a Windows operating system:
C:\> sf configure
Please enter the authentication token to use when connecting: [] AUTHENTICATION_TOKEN
Please enter the hostname of the server to connect to: [platform.strawberryfields.ai] MYHOST
Should the client attempt to connect over SSL? [y] N
Please enter the port number to connect with: [443] 12345
C:\> type C:\Users\USERNAME\AppData\Local\Xanadu\strawberryfields\config.toml
[api]
authentication_token = "AUTHENTICATION_TOKEN"
hostname = "MYHOST"
use_ssl = false
port = "12345"
Testing your connection¶
To test that your account credentials correctly authenticate against the cloud platform, the ping
flag can be used:
$ sf --ping
You have successfully authenticated to the platform!
Submitting jobs¶
To execute a Blackbird .xbb
file from the command line, the sf run
command
line program can be used:
$ sf run test.xbb --output out.txt
After executing the above command, the result will be stored in out.txt
in the current working directory.
You can also omit the --output
parameter to print the result to the screen.
Code details¶
Warning
Unless you are a Strawberry Fields developer, you likely do not need to access the functions in this module directly.
A standalone command-line interface for configuring Strawberry Fields and connecting to the Xanadu cloud platform.
Functions¶
Provides an interactive selection wizard on the command line to configure every option for the API connection. |
|
|
An auxiliary function for configuring the API connection to the Xanadu cloud platform. |
Creates a parser to process the commands and arguments passed to the command line interface. |
|
|
The Xanadu cloud platform command line interface. |
|
Run a blackbird script. |
|
Write the results of the script either to a file or to the standard output. |
Contents
Downloads