Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6b099f8
Update the qobj schema to support pulse gate calibrations.
lcapelluto Jul 16, 2020
764f8c7
Fixup qobj classes: add docstrings, call out to super
lcapelluto Jul 20, 2020
e80e839
Merge remote-tracking branch 'upstream/master' into pulse-gates/schema
lcapelluto Jul 21, 2020
e195b3a
Move pulse library to top level. Fill in more details in qasm_qobj.py
lcapelluto Jul 31, 2020
8d7fd5c
Fix mistake in schema: the pulse_library definition already contains …
lcapelluto Aug 3, 2020
d6d0d73
Move pulse library to top level in qasm_qobj.py as well
lcapelluto Aug 4, 2020
01e8cbf
Add GateCalibration to qobj/__init__.py
lcapelluto Aug 5, 2020
d9b1c0c
Fixup some implementation errors: gates contains a list of dict items…
lcapelluto Aug 11, 2020
8ffc521
Put gate calibrations into calibrations.gates to leave room for addin…
lcapelluto Aug 11, 2020
7edf6d3
Add an example json
lcapelluto Aug 11, 2020
f6318ca
Schema version should be referenced not hardcoded a second time
lcapelluto Aug 11, 2020
4bf931f
Pretty print example file
lcapelluto Aug 11, 2020
b652f2e
Merge branch 'master' into pulse-gates/schema
lcapelluto Aug 11, 2020
636f1cc
Check if calibrations is present when doing to from dict
lcapelluto Aug 12, 2020
0bae536
Fixup qobj test
lcapelluto Aug 12, 2020
ea72add
Update the qobj schema to support pulse gate calibrations.
lcapelluto Jul 16, 2020
1033384
Fixup qobj classes: add docstrings, call out to super
lcapelluto Jul 20, 2020
f3b36c1
Move pulse library to top level. Fill in more details in qasm_qobj.py
lcapelluto Jul 31, 2020
dbf85b1
Fix mistake in schema: the pulse_library definition already contains …
lcapelluto Aug 3, 2020
7cd80d2
Move pulse library to top level in qasm_qobj.py as well
lcapelluto Aug 4, 2020
b44d018
Add GateCalibration to qobj/__init__.py
lcapelluto Aug 5, 2020
af04a34
Fixup some implementation errors: gates contains a list of dict items…
lcapelluto Aug 11, 2020
e761e1f
Put gate calibrations into calibrations.gates to leave room for addin…
lcapelluto Aug 11, 2020
e6d0a42
Add an example json
lcapelluto Aug 11, 2020
7c9e33d
Schema version should be referenced not hardcoded a second time
lcapelluto Aug 11, 2020
faf155e
Pretty print example file
lcapelluto Aug 11, 2020
158c4de
Update backend snapshots with new conf or defs (#4897)
mtreinish Aug 10, 2020
ec3997f
One reference to get_sample_pulse is raising deprecation warnings fro…
lcapelluto Aug 10, 2020
0633bf0
Check if calibrations is present when doing to from dict
lcapelluto Aug 12, 2020
6cfbdb6
Fixup qobj test
lcapelluto Aug 12, 2020
21b9366
Merge branch 'master' into pulse-gates/schema
lcapelluto Aug 12, 2020
5cdaaa6
Add qobj.config.calibrations for common cals
lcapelluto Aug 13, 2020
ed30a25
Merge branch 'pulse-gates/schema' of github.com:lcapelluto/qiskit-ter…
lcapelluto Aug 14, 2020
d75ecac
style
lcapelluto Aug 14, 2020
63f85ff
Merge remote-tracking branch 'upstream/master' into pulse-gates/schema
lcapelluto Aug 17, 2020
6e5c968
Move recent qasm qobj changes to the new qobj.common file
lcapelluto Aug 17, 2020
71e06b4
Update schema with qobj level and experiment level calibrations
lcapelluto Aug 17, 2020
4e59942
Add schema test
lcapelluto Aug 17, 2020
2d45267
Apply suggestions from code review
lcapelluto Aug 18, 2020
989f20d
Merge branch 'master' into pulse-gates/schema
lcapelluto Aug 18, 2020
6a836cf
Fix encoding for validation of new pulse library field in qasm qobj. …
lcapelluto Aug 18, 2020
58ea1ff
Merge branch 'pulse-gates/schema' of github.com:lcapelluto/qiskit-ter…
lcapelluto Aug 18, 2020
6de11b4
Merge branch 'master' into pulse-gates/schema
mergify[bot] Aug 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions qiskit/qobj/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
QasmQobjExperimentConfig
QasmQobjExperiment
QasmQobjConfig
QasmExperimentCalibrations
GateCalibration

Pulse
=====
Expand All @@ -64,6 +66,9 @@

import warnings

from qiskit.qobj.common import QobjExperimentHeader
from qiskit.qobj.common import QobjHeader
Comment thread
lcapelluto marked this conversation as resolved.

from qiskit.qobj.pulse_qobj import PulseQobj
from qiskit.qobj.pulse_qobj import PulseQobjInstruction
from qiskit.qobj.pulse_qobj import PulseQobjExperimentConfig
Expand All @@ -72,13 +77,13 @@
from qiskit.qobj.pulse_qobj import QobjMeasurementOption
from qiskit.qobj.pulse_qobj import PulseLibraryItem

from qiskit.qobj.qasm_qobj import GateCalibration
from qiskit.qobj.qasm_qobj import QasmExperimentCalibrations
from qiskit.qobj.qasm_qobj import QasmQobj
from qiskit.qobj.qasm_qobj import QasmQobjInstruction
from qiskit.qobj.qasm_qobj import QasmQobjExperiment
from qiskit.qobj.qasm_qobj import QasmQobjConfig
from qiskit.qobj.qasm_qobj import QobjExperimentHeader
from qiskit.qobj.qasm_qobj import QasmQobjExperimentConfig
from qiskit.qobj.qasm_qobj import QobjHeader

from .utils import validate_qobj_against_schema

Expand Down
83 changes: 83 additions & 0 deletions qiskit/qobj/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name

"""Module providing definitions of common Qobj classes."""
import json
import os
from types import SimpleNamespace

import fastjsonschema


path_part = 'schemas/qobj_schema.json'
path = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
path_part)
with open(path) as fd:
json_schema = json.loads(fd.read())
validator = fastjsonschema.compile(json_schema)
Comment thread
lcapelluto marked this conversation as resolved.
Comment thread
mtreinish marked this conversation as resolved.


class QobjDictField(SimpleNamespace):
"""A class used to represent a dictionary field in Qobj

Exists as a backwards compatibility shim around a dictionary for Qobjs
previously constructed using marshmallow.
"""

def __init__(self, **kwargs):
"""Instantiate a new Qobj dict field object.

Args:
kwargs: arbitrary keyword arguments that can be accessed as
attributes of the object.
"""
self.__dict__.update(kwargs)

def to_dict(self):
"""Return a dictionary format representation of the QASM Qobj.

Returns:
dict: The dictionary form of the QobjHeader.
"""
return self.__dict__

@classmethod
def from_dict(cls, data):
"""Create a new QobjHeader object from a dictionary.

Args:
data (dict): A dictionary representing the QobjHeader to create. It
will be in the same format as output by :func:`to_dict`.

Returns:
QobjDictFieldr: The QobjDictField from the input dictionary.
"""

return cls(**data)

def __eq__(self, other):
if isinstance(other, self.__class__):
if self.__dict__ == other.__dict__:
return True
return False


class QobjHeader(QobjDictField):
"""A class used to represent a dictionary header in Qobj objects."""
pass


class QobjExperimentHeader(QobjHeader):
"""A class representing a header dictionary for a Qobj Experiment."""
pass
8 changes: 4 additions & 4 deletions qiskit/qobj/pulse_qobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

import numpy

from qiskit.qobj.qasm_qobj import QobjDictField
from qiskit.qobj.qasm_qobj import QobjHeader
from qiskit.qobj.qasm_qobj import QobjExperimentHeader
from qiskit.qobj.qasm_qobj import validator
from qiskit.qobj.common import QobjDictField
from qiskit.qobj.common import QobjHeader
from qiskit.qobj.common import QobjExperimentHeader
from qiskit.qobj.common import validator


class QobjMeasurementOption:
Expand Down
Loading