Skip to content

Commit

Permalink
Relax schema validation on backendconfiguration (#2258)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mtreinish authored and nonhermitian committed Apr 30, 2019
1 parent 1d8d386 commit 6aae8b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=====================

Expand Down
6 changes: 3 additions & 3 deletions qiskit/providers/models/backendconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand All @@ -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)),
Expand Down

0 comments on commit 6aae8b3

Please sign in to comment.