We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Empty circuits from transpiler fail qobj validation
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: master
- **Python version**:
- **Operating system**:

### What is the current behavior?
The compiler removes all the gates from this circuit and leaves an empty circuit that fails validation.

```
qr = QuantumRegister(2, 'qr')
circuit = QuantumCircuit(qr)
circuit.h(qr[0])
circuit.h(qr[0])
circuit.cx(qr[0], qr[1])
circuit.cx(qr[0], qr[1])
circuit.cx(qr[0], qr[1])
circuit.cx(qr[0], qr[1])

coupling_map = [[0, 1]]
basis_gates = ['u1', 'u2', 'u3', 'cx', 'id']

backend = BasicAer.get_backend('qasm_simulator')

qobj = compile(circuit, backend=backend, coupling_map=coupling_map, basis_gates=basis_gates)
```

```
ModelValidationError: {'instructions': ['Shorter than minimum length 1.']}
```
### Steps to reproduce the problem



### What is the expected behavior?
I believe that a valid circuit returned by the transpiler, in this case an empty circuit, should result in a valid qobj.

### Suggested solutions




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `qiskit/qobj/models/base.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # Copyright 2019, IBM.
4 #
5 # This source code is licensed under the Apache License, Version 2.0 found in
6 # the LICENSE.txt file in the root directory of this source tree.
7 
8 """The generic qobj models."""
9 
10 from marshmallow.validate import Length, Range
11 
12 from qiskit.validation import BaseSchema, bind_schema, BaseModel
13 from qiskit.validation.fields import String, Nested, Integer
14 
15 
16 class QobjInstructionSchema(BaseSchema):
17     """Base Schema for QobjInstruction."""
18 
19     # Required properties
20     name = String(required=True)
21 
22 
23 class QobjExperimentHeaderSchema(BaseSchema):
24     """Base Schema for QobjExperimentHeader."""
25     pass
26 
27 
28 class QobjExperimentConfigSchema(BaseSchema):
29     """Base Schema for QobjExperimentConfig."""
30     pass
31 
32 
33 class QobjExperimentSchema(BaseSchema):
34     """Base Schema for QobjExperiment."""
35 
36     # Required properties.
37     instructions = Nested(QobjInstructionSchema, required=True, many=True,
38                           validate=Length(min=1))
39 
40     # Optional properties.
41     header = Nested(QobjExperimentHeaderSchema)
42     config = Nested(QobjExperimentConfigSchema)
43 
44 
45 class QobjConfigSchema(BaseSchema):
46     """Base Schema for QobjConfig."""
47 
48     # Optional properties.
49     max_credits = Integer()
50     seed = Integer()
51     memory_slots = Integer(validate=Range(min=0))
52     shots = Integer(validate=Range(min=1))
53 
54 
55 class QobjHeaderSchema(BaseSchema):
56     """Base Schema for QobjHeader."""
57 
58     # Optional properties.
59     backend_name = String()
60     backend_version = String()
61 
62 
63 @bind_schema(QobjInstructionSchema)
64 class QobjInstruction(BaseModel):
65     """Model for QobjInstruction.
66 
67     Please note that this class only describes the required fields. For the
68     full description of the model, please check ``QobjInstructionSchema``.
69 
70     Attributes:
71         name (str): name of the instruction
72     """
73     def __init__(self, name, **kwargs):
74         self.name = name
75 
76         super().__init__(**kwargs)
77 
78 
79 @bind_schema(QobjExperimentHeaderSchema)
80 class QobjExperimentHeader(BaseModel):
81     """Model for QobjExperimentHeader.
82 
83     Please note that this class only describes the required fields. For the
84     full description of the model, please check ``QobjExperimentHeaderSchema``.
85     """
86     pass
87 
88 
89 @bind_schema(QobjExperimentConfigSchema)
90 class QobjExperimentConfig(BaseModel):
91     """Model for QobjExperimentConfig.
92 
93     Please note that this class only describes the required fields. For the
94     full description of the model, please check ``QobjExperimentConfigSchema``.
95     """
96     pass
97 
98 
99 @bind_schema(QobjExperimentSchema)
100 class QobjExperiment(BaseModel):
101     """Model for QobjExperiment.
102 
103     Please note that this class only describes the required fields. For the
104     full description of the model, please check ``QobjExperimentSchema``.
105 
106     Attributes:
107         instructions (list[QobjInstruction]): list of instructions.
108     """
109     def __init__(self, instructions, **kwargs):
110         self.instructions = instructions
111 
112         super().__init__(**kwargs)
113 
114 
115 @bind_schema(QobjConfigSchema)
116 class QobjConfig(BaseModel):
117     """Model for QobjConfig.
118 
119     Please note that this class only describes the required fields. For the
120     full description of the model, please check ``QobjConfigSchema``.
121     """
122     pass
123 
124 
125 @bind_schema(QobjHeaderSchema)
126 class QobjHeader(BaseModel):
127     """Model for QobjHeader.
128 
129     Please note that this class only describes the required fields. For the
130     full description of the model, please check ``QobjHeaderSchema``.
131     """
132     pass
133
```

Path: `qiskit/qobj/models/qasm.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # Copyright 2019, IBM.
4 #
5 # This source code is licensed under the Apache License, Version 2.0 found in
6 # the LICENSE.txt file in the root directory of this source tree.
7 
8 """The qasm qobj models."""
9 
10 from marshmallow.validate import Range, Length, Regexp
11 
12 from qiskit.validation import bind_schema, BaseSchema, BaseModel
13 from qiskit.validation.fields import List, Integer, InstructionParameter, Nested, String
14 from .base import (QobjInstructionSchema, QobjExperimentConfigSchema, QobjExperimentSchema,
15                    QobjConfigSchema, QobjInstruction, QobjExperimentConfig,
16                    QobjExperiment, QobjConfig)
17 
18 
19 class QobjConditionalSchema(BaseSchema):
20     """Schema for QobjConditional."""
21 
22     # Required properties.
23     mask = String(required=True, validate=Regexp('^0x([0-9A-Fa-f])+$'))
24     type = String(required=True)
25     val = String(required=True, validate=Regexp('^0x([0-9A-Fa-f])+$'))
26 
27 
28 class QasmQobjInstructionSchema(QobjInstructionSchema):
29     """Schema for QasmQobjInstruction."""
30 
31     # Optional properties.
32     qubits = List(Integer(validate=Range(min=0)),
33                   validate=Length(min=1))
34     params = List(InstructionParameter())
35     memory = List(Integer(validate=Range(min=0)),
36                   validate=Length(min=1))
37     conditional = Nested(QobjConditionalSchema)
38 
39 
40 class QasmQobjExperimentConfigSchema(QobjExperimentConfigSchema):
41     """Schema for QasmQobjExperimentConfig."""
42 
43     # Optional properties.
44     memory_slots = Integer(validate=Range(min=0))
45     n_qubits = Integer(validate=Range(min=1))
46 
47 
48 class QasmQobjExperimentSchema(QobjExperimentSchema):
49     """Schema for QasmQobjExperiment."""
50 
51     # Required properties.
52     instructions = Nested(QasmQobjInstructionSchema, required=True, many=True,
53                           validate=Length(min=1))
54 
55     # Optional properties.
56     config = Nested(QasmQobjExperimentConfigSchema)
57 
58 
59 class QasmQobjConfigSchema(QobjConfigSchema):
60     """Schema for QasmQobjConfig."""
61 
62     # Optional properties.
63     n_qubits = Integer(validate=Range(min=1))
64 
65 
66 @bind_schema(QobjConditionalSchema)
67 class QobjConditional(BaseModel):
68     """Model for QobjConditional.
69 
70     Please note that this class only describes the required fields. For the
71     full description of the model, please check ``QobjConditionalSchema``.
72 
73     Attributes:
74         mask (str): hexadecimal mask of the conditional
75         type (str): type of the conditional
76         val (str): hexadecimal value of the conditional
77     """
78     def __init__(self, mask, type, val, **kwargs):
79         # pylint: disable=redefined-builtin
80         self.mask = mask
81         self.type = type
82         self.val = val
83 
84         super().__init__(**kwargs)
85 
86 
87 @bind_schema(QasmQobjInstructionSchema)
88 class QasmQobjInstruction(QobjInstruction):
89     """Model for QasmQobjInstruction inherit from QobjInstruction.
90 
91     Please note that this class only describes the required fields. For the
92     full description of the model, please check ``QasmQobjInstructionSchema``.
93 
94     Attributes:
95         name (str): name of the instruction
96     """
97     def __init__(self, name, **kwargs):
98         super().__init__(name=name,
99                          **kwargs)
100 
101 
102 @bind_schema(QasmQobjExperimentConfigSchema)
103 class QasmQobjExperimentConfig(QobjExperimentConfig):
104     """Model for QasmQobjExperimentConfig inherit from QobjExperimentConfig.
105 
106     Please note that this class only describes the required fields. For the
107     full description of the model, please check ``QasmQobjExperimentConfigSchema``.
108     """
109     pass
110 
111 
112 @bind_schema(QasmQobjExperimentSchema)
113 class QasmQobjExperiment(QobjExperiment):
114     """Model for QasmQobjExperiment inherit from QobjExperiment.
115 
116     Please note that this class only describes the required fields. For the
117     full description of the model, please check ``QasmQobjExperimentSchema``.
118 
119     Attributes:
120         instructions (list[QasmQobjInstruction]): list of instructions.
121     """
122     def __init__(self, instructions, **kwargs):
123         super().__init__(instructions=instructions,
124                          **kwargs)
125 
126 
127 @bind_schema(QasmQobjConfigSchema)
128 class QasmQobjConfig(QobjConfig):
129     """Model for QasmQobjConfig inherit from QobjConfig.
130 
131     Please note that this class only describes the required fields. For the
132     full description of the model, please check ``QasmQobjConfigSchema``.
133     """
134     pass
135
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/qiskit/qobj/models/base.py b/qiskit/qobj/models/base.py
--- a/qiskit/qobj/models/base.py
+++ b/qiskit/qobj/models/base.py
@@ -7,7 +7,7 @@
 
 """The generic qobj models."""
 
-from marshmallow.validate import Length, Range
+from marshmallow.validate import Range
 
 from qiskit.validation import BaseSchema, bind_schema, BaseModel
 from qiskit.validation.fields import String, Nested, Integer
@@ -34,8 +34,7 @@
     """Base Schema for QobjExperiment."""
 
     # Required properties.
-    instructions = Nested(QobjInstructionSchema, required=True, many=True,
-                          validate=Length(min=1))
+    instructions = Nested(QobjInstructionSchema, required=True, many=True)
 
     # Optional properties.
     header = Nested(QobjExperimentHeaderSchema)
diff --git a/qiskit/qobj/models/qasm.py b/qiskit/qobj/models/qasm.py
--- a/qiskit/qobj/models/qasm.py
+++ b/qiskit/qobj/models/qasm.py
@@ -49,8 +49,7 @@
     """Schema for QasmQobjExperiment."""
 
     # Required properties.
-    instructions = Nested(QasmQobjInstructionSchema, required=True, many=True,
-                          validate=Length(min=1))
+    instructions = Nested(QasmQobjInstructionSchema, required=True, many=True)
 
     # Optional properties.
     config = Nested(QasmQobjExperimentConfigSchema)

{"golden_diff": "diff --git a/qiskit/qobj/models/base.py b/qiskit/qobj/models/base.py\n--- a/qiskit/qobj/models/base.py\n+++ b/qiskit/qobj/models/base.py\n@@ -7,7 +7,7 @@\n \n \"\"\"The generic qobj models.\"\"\"\n \n-from marshmallow.validate import Length, Range\n+from marshmallow.validate import Range\n \n from qiskit.validation import BaseSchema, bind_schema, BaseModel\n from qiskit.validation.fields import String, Nested, Integer\n@@ -34,8 +34,7 @@\n     \"\"\"Base Schema for QobjExperiment.\"\"\"\n \n     # Required properties.\n-    instructions = Nested(QobjInstructionSchema, required=True, many=True,\n-                          validate=Length(min=1))\n+    instructions = Nested(QobjInstructionSchema, required=True, many=True)\n \n     # Optional properties.\n     header = Nested(QobjExperimentHeaderSchema)\ndiff --git a/qiskit/qobj/models/qasm.py b/qiskit/qobj/models/qasm.py\n--- a/qiskit/qobj/models/qasm.py\n+++ b/qiskit/qobj/models/qasm.py\n@@ -49,8 +49,7 @@\n     \"\"\"Schema for QasmQobjExperiment.\"\"\"\n \n     # Required properties.\n-    instructions = Nested(QasmQobjInstructionSchema, required=True, many=True,\n-                          validate=Length(min=1))\n+    instructions = Nested(QasmQobjInstructionSchema, required=True, many=True)\n \n     # Optional properties.\n     config = Nested(QasmQobjExperimentConfigSchema)\n", "issue": "Empty circuits from transpiler fail qobj validation\n<!-- \u26a0\ufe0f If you do not respect this template, your issue will be closed -->\r\n<!-- \u26a0\ufe0f Make sure to browse the opened and closed issues -->\r\n\r\n### Information\r\n\r\n- **Qiskit Terra version**: master\r\n- **Python version**:\r\n- **Operating system**:\r\n\r\n### What is the current behavior?\r\nThe compiler removes all the gates from this circuit and leaves an empty circuit that fails validation.\r\n\r\n```\r\nqr = QuantumRegister(2, 'qr')\r\ncircuit = QuantumCircuit(qr)\r\ncircuit.h(qr[0])\r\ncircuit.h(qr[0])\r\ncircuit.cx(qr[0], qr[1])\r\ncircuit.cx(qr[0], qr[1])\r\ncircuit.cx(qr[0], qr[1])\r\ncircuit.cx(qr[0], qr[1])\r\n\r\ncoupling_map = [[0, 1]]\r\nbasis_gates = ['u1', 'u2', 'u3', 'cx', 'id']\r\n\r\nbackend = BasicAer.get_backend('qasm_simulator')\r\n\r\nqobj = compile(circuit, backend=backend, coupling_map=coupling_map, basis_gates=basis_gates)\r\n```\r\n\r\n```\r\nModelValidationError: {'instructions': ['Shorter than minimum length 1.']}\r\n```\r\n### Steps to reproduce the problem\r\n\r\n\r\n\r\n### What is the expected behavior?\r\nI believe that a valid circuit returned by the transpiler, in this case an empty circuit, should result in a valid qobj.\r\n\r\n### Suggested solutions\r\n\r\n\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright 2019, IBM.\n#\n# This source code is licensed under the Apache License, Version 2.0 found in\n# the LICENSE.txt file in the root directory of this source tree.\n\n\"\"\"The generic qobj models.\"\"\"\n\nfrom marshmallow.validate import Length, Range\n\nfrom qiskit.validation import BaseSchema, bind_schema, BaseModel\nfrom qiskit.validation.fields import String, Nested, Integer\n\n\nclass QobjInstructionSchema(BaseSchema):\n    \"\"\"Base Schema for QobjInstruction.\"\"\"\n\n    # Required properties\n    name = String(required=True)\n\n\nclass QobjExperimentHeaderSchema(BaseSchema):\n    \"\"\"Base Schema for QobjExperimentHeader.\"\"\"\n    pass\n\n\nclass QobjExperimentConfigSchema(BaseSchema):\n    \"\"\"Base Schema for QobjExperimentConfig.\"\"\"\n    pass\n\n\nclass QobjExperimentSchema(BaseSchema):\n    \"\"\"Base Schema for QobjExperiment.\"\"\"\n\n    # Required properties.\n    instructions = Nested(QobjInstructionSchema, required=True, many=True,\n                          validate=Length(min=1))\n\n    # Optional properties.\n    header = Nested(QobjExperimentHeaderSchema)\n    config = Nested(QobjExperimentConfigSchema)\n\n\nclass QobjConfigSchema(BaseSchema):\n    \"\"\"Base Schema for QobjConfig.\"\"\"\n\n    # Optional properties.\n    max_credits = Integer()\n    seed = Integer()\n    memory_slots = Integer(validate=Range(min=0))\n    shots = Integer(validate=Range(min=1))\n\n\nclass QobjHeaderSchema(BaseSchema):\n    \"\"\"Base Schema for QobjHeader.\"\"\"\n\n    # Optional properties.\n    backend_name = String()\n    backend_version = String()\n\n\n@bind_schema(QobjInstructionSchema)\nclass QobjInstruction(BaseModel):\n    \"\"\"Model for QobjInstruction.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjInstructionSchema``.\n\n    Attributes:\n        name (str): name of the instruction\n    \"\"\"\n    def __init__(self, name, **kwargs):\n        self.name = name\n\n        super().__init__(**kwargs)\n\n\n@bind_schema(QobjExperimentHeaderSchema)\nclass QobjExperimentHeader(BaseModel):\n    \"\"\"Model for QobjExperimentHeader.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjExperimentHeaderSchema``.\n    \"\"\"\n    pass\n\n\n@bind_schema(QobjExperimentConfigSchema)\nclass QobjExperimentConfig(BaseModel):\n    \"\"\"Model for QobjExperimentConfig.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjExperimentConfigSchema``.\n    \"\"\"\n    pass\n\n\n@bind_schema(QobjExperimentSchema)\nclass QobjExperiment(BaseModel):\n    \"\"\"Model for QobjExperiment.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjExperimentSchema``.\n\n    Attributes:\n        instructions (list[QobjInstruction]): list of instructions.\n    \"\"\"\n    def __init__(self, instructions, **kwargs):\n        self.instructions = instructions\n\n        super().__init__(**kwargs)\n\n\n@bind_schema(QobjConfigSchema)\nclass QobjConfig(BaseModel):\n    \"\"\"Model for QobjConfig.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjConfigSchema``.\n    \"\"\"\n    pass\n\n\n@bind_schema(QobjHeaderSchema)\nclass QobjHeader(BaseModel):\n    \"\"\"Model for QobjHeader.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjHeaderSchema``.\n    \"\"\"\n    pass\n", "path": "qiskit/qobj/models/base.py"}, {"content": "# -*- coding: utf-8 -*-\n\n# Copyright 2019, IBM.\n#\n# This source code is licensed under the Apache License, Version 2.0 found in\n# the LICENSE.txt file in the root directory of this source tree.\n\n\"\"\"The qasm qobj models.\"\"\"\n\nfrom marshmallow.validate import Range, Length, Regexp\n\nfrom qiskit.validation import bind_schema, BaseSchema, BaseModel\nfrom qiskit.validation.fields import List, Integer, InstructionParameter, Nested, String\nfrom .base import (QobjInstructionSchema, QobjExperimentConfigSchema, QobjExperimentSchema,\n                   QobjConfigSchema, QobjInstruction, QobjExperimentConfig,\n                   QobjExperiment, QobjConfig)\n\n\nclass QobjConditionalSchema(BaseSchema):\n    \"\"\"Schema for QobjConditional.\"\"\"\n\n    # Required properties.\n    mask = String(required=True, validate=Regexp('^0x([0-9A-Fa-f])+$'))\n    type = String(required=True)\n    val = String(required=True, validate=Regexp('^0x([0-9A-Fa-f])+$'))\n\n\nclass QasmQobjInstructionSchema(QobjInstructionSchema):\n    \"\"\"Schema for QasmQobjInstruction.\"\"\"\n\n    # Optional properties.\n    qubits = List(Integer(validate=Range(min=0)),\n                  validate=Length(min=1))\n    params = List(InstructionParameter())\n    memory = List(Integer(validate=Range(min=0)),\n                  validate=Length(min=1))\n    conditional = Nested(QobjConditionalSchema)\n\n\nclass QasmQobjExperimentConfigSchema(QobjExperimentConfigSchema):\n    \"\"\"Schema for QasmQobjExperimentConfig.\"\"\"\n\n    # Optional properties.\n    memory_slots = Integer(validate=Range(min=0))\n    n_qubits = Integer(validate=Range(min=1))\n\n\nclass QasmQobjExperimentSchema(QobjExperimentSchema):\n    \"\"\"Schema for QasmQobjExperiment.\"\"\"\n\n    # Required properties.\n    instructions = Nested(QasmQobjInstructionSchema, required=True, many=True,\n                          validate=Length(min=1))\n\n    # Optional properties.\n    config = Nested(QasmQobjExperimentConfigSchema)\n\n\nclass QasmQobjConfigSchema(QobjConfigSchema):\n    \"\"\"Schema for QasmQobjConfig.\"\"\"\n\n    # Optional properties.\n    n_qubits = Integer(validate=Range(min=1))\n\n\n@bind_schema(QobjConditionalSchema)\nclass QobjConditional(BaseModel):\n    \"\"\"Model for QobjConditional.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjConditionalSchema``.\n\n    Attributes:\n        mask (str): hexadecimal mask of the conditional\n        type (str): type of the conditional\n        val (str): hexadecimal value of the conditional\n    \"\"\"\n    def __init__(self, mask, type, val, **kwargs):\n        # pylint: disable=redefined-builtin\n        self.mask = mask\n        self.type = type\n        self.val = val\n\n        super().__init__(**kwargs)\n\n\n@bind_schema(QasmQobjInstructionSchema)\nclass QasmQobjInstruction(QobjInstruction):\n    \"\"\"Model for QasmQobjInstruction inherit from QobjInstruction.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QasmQobjInstructionSchema``.\n\n    Attributes:\n        name (str): name of the instruction\n    \"\"\"\n    def __init__(self, name, **kwargs):\n        super().__init__(name=name,\n                         **kwargs)\n\n\n@bind_schema(QasmQobjExperimentConfigSchema)\nclass QasmQobjExperimentConfig(QobjExperimentConfig):\n    \"\"\"Model for QasmQobjExperimentConfig inherit from QobjExperimentConfig.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QasmQobjExperimentConfigSchema``.\n    \"\"\"\n    pass\n\n\n@bind_schema(QasmQobjExperimentSchema)\nclass QasmQobjExperiment(QobjExperiment):\n    \"\"\"Model for QasmQobjExperiment inherit from QobjExperiment.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QasmQobjExperimentSchema``.\n\n    Attributes:\n        instructions (list[QasmQobjInstruction]): list of instructions.\n    \"\"\"\n    def __init__(self, instructions, **kwargs):\n        super().__init__(instructions=instructions,\n                         **kwargs)\n\n\n@bind_schema(QasmQobjConfigSchema)\nclass QasmQobjConfig(QobjConfig):\n    \"\"\"Model for QasmQobjConfig inherit from QobjConfig.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QasmQobjConfigSchema``.\n    \"\"\"\n    pass\n", "path": "qiskit/qobj/models/qasm.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Copyright 2019, IBM.\n#\n# This source code is licensed under the Apache License, Version 2.0 found in\n# the LICENSE.txt file in the root directory of this source tree.\n\n\"\"\"The generic qobj models.\"\"\"\n\nfrom marshmallow.validate import Range\n\nfrom qiskit.validation import BaseSchema, bind_schema, BaseModel\nfrom qiskit.validation.fields import String, Nested, Integer\n\n\nclass QobjInstructionSchema(BaseSchema):\n    \"\"\"Base Schema for QobjInstruction.\"\"\"\n\n    # Required properties\n    name = String(required=True)\n\n\nclass QobjExperimentHeaderSchema(BaseSchema):\n    \"\"\"Base Schema for QobjExperimentHeader.\"\"\"\n    pass\n\n\nclass QobjExperimentConfigSchema(BaseSchema):\n    \"\"\"Base Schema for QobjExperimentConfig.\"\"\"\n    pass\n\n\nclass QobjExperimentSchema(BaseSchema):\n    \"\"\"Base Schema for QobjExperiment.\"\"\"\n\n    # Required properties.\n    instructions = Nested(QobjInstructionSchema, required=True, many=True)\n\n    # Optional properties.\n    header = Nested(QobjExperimentHeaderSchema)\n    config = Nested(QobjExperimentConfigSchema)\n\n\nclass QobjConfigSchema(BaseSchema):\n    \"\"\"Base Schema for QobjConfig.\"\"\"\n\n    # Optional properties.\n    max_credits = Integer()\n    seed = Integer()\n    memory_slots = Integer(validate=Range(min=0))\n    shots = Integer(validate=Range(min=1))\n\n\nclass QobjHeaderSchema(BaseSchema):\n    \"\"\"Base Schema for QobjHeader.\"\"\"\n\n    # Optional properties.\n    backend_name = String()\n    backend_version = String()\n\n\n@bind_schema(QobjInstructionSchema)\nclass QobjInstruction(BaseModel):\n    \"\"\"Model for QobjInstruction.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjInstructionSchema``.\n\n    Attributes:\n        name (str): name of the instruction\n    \"\"\"\n    def __init__(self, name, **kwargs):\n        self.name = name\n\n        super().__init__(**kwargs)\n\n\n@bind_schema(QobjExperimentHeaderSchema)\nclass QobjExperimentHeader(BaseModel):\n    \"\"\"Model for QobjExperimentHeader.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjExperimentHeaderSchema``.\n    \"\"\"\n    pass\n\n\n@bind_schema(QobjExperimentConfigSchema)\nclass QobjExperimentConfig(BaseModel):\n    \"\"\"Model for QobjExperimentConfig.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjExperimentConfigSchema``.\n    \"\"\"\n    pass\n\n\n@bind_schema(QobjExperimentSchema)\nclass QobjExperiment(BaseModel):\n    \"\"\"Model for QobjExperiment.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjExperimentSchema``.\n\n    Attributes:\n        instructions (list[QobjInstruction]): list of instructions.\n    \"\"\"\n    def __init__(self, instructions, **kwargs):\n        self.instructions = instructions\n\n        super().__init__(**kwargs)\n\n\n@bind_schema(QobjConfigSchema)\nclass QobjConfig(BaseModel):\n    \"\"\"Model for QobjConfig.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjConfigSchema``.\n    \"\"\"\n    pass\n\n\n@bind_schema(QobjHeaderSchema)\nclass QobjHeader(BaseModel):\n    \"\"\"Model for QobjHeader.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjHeaderSchema``.\n    \"\"\"\n    pass\n", "path": "qiskit/qobj/models/base.py"}, {"content": "# -*- coding: utf-8 -*-\n\n# Copyright 2019, IBM.\n#\n# This source code is licensed under the Apache License, Version 2.0 found in\n# the LICENSE.txt file in the root directory of this source tree.\n\n\"\"\"The qasm qobj models.\"\"\"\n\nfrom marshmallow.validate import Range, Length, Regexp\n\nfrom qiskit.validation import bind_schema, BaseSchema, BaseModel\nfrom qiskit.validation.fields import List, Integer, InstructionParameter, Nested, String\nfrom .base import (QobjInstructionSchema, QobjExperimentConfigSchema, QobjExperimentSchema,\n                   QobjConfigSchema, QobjInstruction, QobjExperimentConfig,\n                   QobjExperiment, QobjConfig)\n\n\nclass QobjConditionalSchema(BaseSchema):\n    \"\"\"Schema for QobjConditional.\"\"\"\n\n    # Required properties.\n    mask = String(required=True, validate=Regexp('^0x([0-9A-Fa-f])+$'))\n    type = String(required=True)\n    val = String(required=True, validate=Regexp('^0x([0-9A-Fa-f])+$'))\n\n\nclass QasmQobjInstructionSchema(QobjInstructionSchema):\n    \"\"\"Schema for QasmQobjInstruction.\"\"\"\n\n    # Optional properties.\n    qubits = List(Integer(validate=Range(min=0)),\n                  validate=Length(min=1))\n    params = List(InstructionParameter())\n    memory = List(Integer(validate=Range(min=0)),\n                  validate=Length(min=1))\n    conditional = Nested(QobjConditionalSchema)\n\n\nclass QasmQobjExperimentConfigSchema(QobjExperimentConfigSchema):\n    \"\"\"Schema for QasmQobjExperimentConfig.\"\"\"\n\n    # Optional properties.\n    memory_slots = Integer(validate=Range(min=0))\n    n_qubits = Integer(validate=Range(min=1))\n\n\nclass QasmQobjExperimentSchema(QobjExperimentSchema):\n    \"\"\"Schema for QasmQobjExperiment.\"\"\"\n\n    # Required properties.\n    instructions = Nested(QasmQobjInstructionSchema, required=True, many=True)\n\n    # Optional properties.\n    config = Nested(QasmQobjExperimentConfigSchema)\n\n\nclass QasmQobjConfigSchema(QobjConfigSchema):\n    \"\"\"Schema for QasmQobjConfig.\"\"\"\n\n    # Optional properties.\n    n_qubits = Integer(validate=Range(min=1))\n\n\n@bind_schema(QobjConditionalSchema)\nclass QobjConditional(BaseModel):\n    \"\"\"Model for QobjConditional.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QobjConditionalSchema``.\n\n    Attributes:\n        mask (str): hexadecimal mask of the conditional\n        type (str): type of the conditional\n        val (str): hexadecimal value of the conditional\n    \"\"\"\n    def __init__(self, mask, type, val, **kwargs):\n        # pylint: disable=redefined-builtin\n        self.mask = mask\n        self.type = type\n        self.val = val\n\n        super().__init__(**kwargs)\n\n\n@bind_schema(QasmQobjInstructionSchema)\nclass QasmQobjInstruction(QobjInstruction):\n    \"\"\"Model for QasmQobjInstruction inherit from QobjInstruction.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QasmQobjInstructionSchema``.\n\n    Attributes:\n        name (str): name of the instruction\n    \"\"\"\n    def __init__(self, name, **kwargs):\n        super().__init__(name=name,\n                         **kwargs)\n\n\n@bind_schema(QasmQobjExperimentConfigSchema)\nclass QasmQobjExperimentConfig(QobjExperimentConfig):\n    \"\"\"Model for QasmQobjExperimentConfig inherit from QobjExperimentConfig.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QasmQobjExperimentConfigSchema``.\n    \"\"\"\n    pass\n\n\n@bind_schema(QasmQobjExperimentSchema)\nclass QasmQobjExperiment(QobjExperiment):\n    \"\"\"Model for QasmQobjExperiment inherit from QobjExperiment.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QasmQobjExperimentSchema``.\n\n    Attributes:\n        instructions (list[QasmQobjInstruction]): list of instructions.\n    \"\"\"\n    def __init__(self, instructions, **kwargs):\n        super().__init__(instructions=instructions,\n                         **kwargs)\n\n\n@bind_schema(QasmQobjConfigSchema)\nclass QasmQobjConfig(QobjConfig):\n    \"\"\"Model for QasmQobjConfig inherit from QobjConfig.\n\n    Please note that this class only describes the required fields. For the\n    full description of the model, please check ``QasmQobjConfigSchema``.\n    \"\"\"\n    pass\n", "path": "qiskit/qobj/models/qasm.py"}]}