Shortcuts

qiskit.providers.ibmq.experiment.ExperimentService

class ExperimentService(provider, access_token)[source]

Provides experiment related services.

This class is the main interface to invoke IBM Quantum Experience experiment services, which allow you to create, delete, update, query, and retrieve experiments, experiment plots, and analysis results. The experiment attribute of AccountProvider is an instance of this class, and the main syntax for using the services is provider.experiment.<action>. For example:

from qiskit import IBMQ
provider = IBMQ.load_account()

# Retrieve all experiments.
experiments = provider.experiment.experiments()

# Retrieve experiments with filtering.
experiment_filtered = provider.experiment.experiments(backend_name='foo')

# Retrieve a specific experiment using its ID.
experiment = provider.experiment.retrieve_experiment(EXPERIMENT_ID)

# Upload a new experiment.
from qiskit.providers.ibmq.experiment import Experiment
new_exp = Experiment(
    provider=provider,
    backend_name=backend_name,
    experiment_type='test',
    tags=['qiskit-test']
)
provider.experiment.upload_experiment(new_exp)

# Update an experiment.
new_exp.end_datetime = datetime.now()
provider.experiment.update_experiment(new_exp)

# Delete an experiment.
provider.experiment.delete_experiment(EXPERIMENT_ID)

Similar syntax applies to analysis results and experiment plots. Classes Experiment and AnalysisResult encapsulate data of an experiment and an analysis result, respectively.

IBMQBackendService constructor.

Parameters
  • provider (AccountProvider) – IBM Quantum Experience account provider.

  • access_token (str) – IBM Quantum Experience access token.

__init__(provider, access_token)[source]

IBMQBackendService constructor.

Parameters
  • provider (AccountProvider) – IBM Quantum Experience account provider.

  • access_token (str) – IBM Quantum Experience access token.

Methods

__init__(provider, access_token)

IBMQBackendService constructor.

analysis_results([limit, backend_name, …])

Retrieve all analysis results, with optional filtering.

backends()

Return a list of backends.

delete_analysis_result(result)

Delete an analysis result.

delete_experiment(experiment)

Delete an experiment.

delete_plot(experiment, plot_name)

Delete an experiment plot.

device_components([backend_name])

Return the device components.

experiments([limit, backend_name, type, …])

Retrieve all experiments, with optional filtering.

retrieve_analysis_result(result_id)

Retrieve an analysis result.

retrieve_experiment(experiment_id)

Retrieve an experiment.

retrieve_plot(experiment, plot_name[, file_name])

Retrieve an experiment plot.

update_analysis_result(result)

Update an analysis result.

update_experiment(experiment)

Update an experiment.

update_plot(experiment, plot, plot_name)

Update an experiment plot.

upload_analysis_result(result)

Upload an analysis result.

upload_experiment(experiment)

Upload a new experiment.

upload_plot(experiment, plot[, plot_name])

Upload an experiment plot.

analysis_results(limit=10, backend_name=None, device_components=None, experiment_id=None, result_type=None, quality=None)[source]

Retrieve all analysis results, with optional filtering.

Parameters
  • limit (Optional[int]) – Number of analysis results to retrieve.

  • backend_name (Optional[str]) – Backend name used for filtering.

  • device_components (Optional[List[str]]) – Filter by device components. An analysis result’s device components must match this list exactly for it to be included.

  • experiment_id (Optional[str]) – Experiment ID used for filtering.

  • result_type (Optional[str]) – Analysis result type used for filtering.

  • quality (Optional[List[Tuple[str, Union[str, ResultQuality]]]]) – Quality value used for filtering. Each element in this list is a tuple of an operator and a value. The operator is one of lt, le, gt, ge, and eq. The value is one of the ResultQuality values. For example, analysis_results(quality=[('ge', 'Computer Bad'), ('lt', 'Computer Good')]) will return all analysis results with a quality of Computer Bad and No Information.

Return type

List[AnalysisResult]

Returns

A list of analysis results.

Raises

ValueError – If an invalid parameter value is specified.

backends()[source]

Return a list of backends.

Return type

List[Dict]

Returns

A list of backends.

delete_analysis_result(result)[source]

Delete an analysis result.

Parameters

result (Union[AnalysisResult, str]) – The AnalysisResult object or the analysis result UUID.

Note

This method prompts for confirmation and requires a response before proceeding.

Return type

Optional[AnalysisResult]

Returns

The deleted analysis result.

delete_experiment(experiment)[source]

Delete an experiment.

Parameters

experiment (Union[Experiment, str]) – The Experiment object or the experiment ID.

Note

This method prompts for confirmation and requires a response before proceeding.

Return type

Optional[Experiment]

Returns

Deleted experiment.

delete_plot(experiment, plot_name)[source]

Delete an experiment plot.

Note

This method prompts for confirmation and requires a response before proceeding.

Parameters
  • experiment (Union[Experiment, str]) – The Experiment object or the experiment UUID.

  • plot_name (str) – Name of the plot.

Return type

None

device_components(backend_name=None)[source]

Return the device components.

Parameters

backend_name (Optional[str]) – Name of the backend whose components are to be retrieved.

Return type

List[DeviceComponent]

Returns

A list of device components.

experiments(limit=10, backend_name=None, type=None, start_datetime=None, end_datetime=None, device_components=None, tags=None, tags_operator='OR')[source]

Retrieve all experiments, with optional filtering.

Parameters
  • limit (Optional[int]) – Number of experiments to retrieve. None indicates no limit.

  • backend_name (Optional[str]) – Backend name used for filtering.

  • type (Optional[str]) – Experiment type used for filtering.

  • start_datetime (Optional[datetime]) – Filter by the given start timestamp, in local time. This is used to find experiments whose start date/time is after (greater than or equal to) this local timestamp.

  • end_datetime (Optional[datetime]) – Filter by the given end timestamp, in local time. This is used to find experiments whose start date/time is before (less than or equal to) this local timestamp.

  • device_components (Optional[List[str]]) – Filter by device components. An experiment must have analysis results with device components matching the given list exactly to be included.

  • tags (Optional[List[str]]) – Filter by tags assigned to experiments.

  • tags_operator (Optional[str]) –

    Logical operator to use when filtering by job tags. Valid values are “AND” and “OR”:

    • If “AND” is specified, then an experiment must have all of the tags specified in tags to be included.

    • If “OR” is specified, then an experiment only needs to have any of the tags specified in tags to be included.

Return type

List[Experiment]

Returns

A list of experiments.

Raises

ValueError – If an invalid parameter value is specified.

retrieve_analysis_result(result_id)[source]

Retrieve an analysis result.

Parameters

result_id (str) – Analysis result UUID.

Return type

AnalysisResult

Returns

Retrieved analysis result.

Raises
  • AnalysisResultNotFoundError – If the analysis result is not found.

  • RequestsApiError – If an unexpected error occurred when retrieving analysis result from the server.

retrieve_experiment(experiment_id)[source]

Retrieve an experiment.

Parameters

experiment_id (str) – Experiment uuid.

Return type

Experiment

Returns

Retrieved experiment.

Raises
  • ExperimentNotFoundError – If the experiment is not found.

  • RequestsApiError – If an unexpected error occurred when retrieving experiment from the server.

retrieve_plot(experiment, plot_name, file_name=None)[source]

Retrieve an experiment plot.

Parameters
  • experiment (Union[Experiment, str]) – The Experiment object or the experiment UUID.

  • plot_name (str) – Name of the plot.

  • file_name (Optional[str]) – Name of the local file to save the plot to. If None, the content of the plot is returned instead.

Return type

Union[int, bytes]

Returns

The size of the plot if file_name is specified. Otherwise the content of the plot in bytes.

Raises
  • PlotNotFoundError – If the plot is not found.

  • RequestsApiError – If an unexpected error occurred when retrieving plot from the server.

update_analysis_result(result)[source]

Update an analysis result.

Parameters

result (AnalysisResult) – The analysis result to upload.

Return type

None

update_experiment(experiment)[source]

Update an experiment.

Note

Only the following experiment attributes can be updated:

  • end_datetime

Parameters

experiment (Experiment) – Experiment to be updated.

Return type

None

update_plot(experiment, plot, plot_name)[source]

Update an experiment plot.

Parameters
  • experiment (Union[Experiment, str]) – The Experiment object or the experiment UUID.

  • plot (Union[str, bytes]) – Name of the plot file or plot data to upload.

  • plot_name (str) – Name of the plot to update.

Return type

Dict

Returns

A dictionary with name and size of the uploaded plot.

upload_analysis_result(result)[source]

Upload an analysis result.

Parameters

result (AnalysisResult) – The analysis result to upload.

Return type

None

upload_experiment(experiment)[source]

Upload a new experiment.

Parameters

experiment (Experiment) – The experiment to upload.

Return type

None

upload_plot(experiment, plot, plot_name=None)[source]

Upload an experiment plot.

Parameters
  • experiment (Union[Experiment, str]) – The Experiment object or the experiment UUID.

  • plot (Union[str, bytes]) – Name of the plot file or plot data to upload.

  • plot_name (Optional[str]) – Name of the plot. If None, the plot file name, if given, or a generated name is used.

Return type

Dict

Returns

A dictionary with name and size of the uploaded plot.

You are viewing lang: English
Languages
English
Japanese
German
Korean