From 6aae8b3c15e4fecd0b4be3fde174467bc476467e Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 30 Apr 2019 18:15:41 -0400 Subject: [PATCH] Relax schema validation on backendconfiguration (#2258) * Relax schema validation on backendconfiguration The schema validation for backendconfig was set too tightly and it was rejecting valid responses from the backend API. This potentially causes issues when running against the api. This commit addresses this by changing the schema validation to ensure that we properly validate the response received by the backends and no longer reject valid responses moving forward. * Add changelog * Fix tests and lint --- CHANGELOG.rst | 6 ++++++ qiskit/providers/models/backendconfiguration.py | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2ccb0ae2785b..5b35b749a7fd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,12 @@ The format is based on `Keep a Changelog`_. `UNRELEASED`_ ============= +Fixed +----- + +- A potential issue where the backend configuration schema validation would + improperly reject valid responses from the API (#2258) + `0.7.1`_ - 2019-03-04 ===================== diff --git a/qiskit/providers/models/backendconfiguration.py b/qiskit/providers/models/backendconfiguration.py index f6a1fc7c4b22..689b55cb82b8 100644 --- a/qiskit/providers/models/backendconfiguration.py +++ b/qiskit/providers/models/backendconfiguration.py @@ -7,7 +7,7 @@ """Model and schema for backend configuration.""" -from marshmallow.validate import Equal, Length, OneOf, Range, Regexp +from marshmallow.validate import Length, OneOf, Range, Regexp from qiskit.validation import BaseModel, BaseSchema, bind_schema from qiskit.validation.fields import Boolean, DateTime, Integer, List, Nested, String @@ -47,7 +47,7 @@ class BackendConfigurationSchema(BaseSchema): local = Boolean(required=True) simulator = Boolean(required=True) conditional = Boolean(required=True) - open_pulse = Boolean(required=True, validate=Equal(False)) + open_pulse = Boolean(required=True) memory = Boolean(required=True) max_shots = Integer(required=True, validate=Range(min=1)) @@ -56,7 +56,7 @@ class BackendConfigurationSchema(BaseSchema): sample_name = String() coupling_map = List(List(Integer(), validate=Length(min=1)), - validate=Length(min=1)) + validate=Length(min=1), allow_none=True) n_registers = Integer(validate=Range(min=1)) register_map = List(List(Integer(validate=OneOf([0, 1])), validate=Length(min=1)),