Repository: Qiskit/qiskit

Issue:
circuit -> schedule raises exception
<!-- ⚠️ 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?
```python
ghz = QuantumCircuit(5, 5)
ghz.h(0)
ghz.cx(range(4), range(1,5))
ghz.barrier()
ghz.measure(range(5), range(5))

sch = schedule(ghz, backend)
```

gives:

AttributeError: 'NoneType' object has no attribute 'instruction_schedule_map'

This works on older versions.


### Steps to reproduce the problem



### What is the expected behavior?



### Suggested solutions





Discussion:
This is likely not a pulse backend and `defaults` returns None, where rather it should error. The other alternative would be to return an error in the scheduler if unavailable.
Valencia and other pulse enabled devices show same
Oh crap.  the provider has pulse off.  Your right sorry.
I think we can reopen this issue, it is confusing if a user encounters it. 
Hi! I've never contributed before, but can I try this one? It seems doable.

Resolving patch:
diff --git a/qiskit/compiler/schedule.py b/qiskit/compiler/schedule.py
--- a/qiskit/compiler/schedule.py
+++ b/qiskit/compiler/schedule.py
@@ -65,7 +65,11 @@ def schedule(circuits: Union[QuantumCircuit, List[QuantumCircuit]],
         if backend is None:
             raise QiskitError("Must supply either a backend or InstructionScheduleMap for "
                               "scheduling passes.")
-        inst_map = backend.defaults().instruction_schedule_map
+        defaults = backend.defaults()
+        if defaults is None:
+            raise QiskitError("The backend defaults are unavailable. The backend may not "
+                              "support pulse.")
+        inst_map = defaults.instruction_schedule_map
     if meas_map is None:
         if backend is None:
             raise QiskitError("Must supply either a backend or a meas_map for scheduling passes.")


Test patch:
diff --git a/test/python/scheduler/test_basic_scheduler.py b/test/python/scheduler/test_basic_scheduler.py
--- a/test/python/scheduler/test_basic_scheduler.py
+++ b/test/python/scheduler/test_basic_scheduler.py
@@ -16,10 +16,11 @@
 
 from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, schedule
 from qiskit.circuit import Gate
+from qiskit.exceptions import QiskitError
 from qiskit.pulse import (Schedule, DriveChannel, AcquireChannel, Acquire,
                           MeasureChannel, MemorySlot, Gaussian, Play)
 
-from qiskit.test.mock import FakeOpenPulse2Q, FakeOpenPulse3Q
+from qiskit.test.mock import FakeBackend, FakeOpenPulse2Q, FakeOpenPulse3Q
 from qiskit.test import QiskitTestCase
 
 
@@ -30,6 +31,14 @@ def setUp(self):
         self.backend = FakeOpenPulse2Q()
         self.inst_map = self.backend.defaults().instruction_schedule_map
 
+    def test_unavailable_defaults(self):
+        """Test backend with unavailable defaults."""
+        qr = QuantumRegister(1)
+        qc = QuantumCircuit(qr)
+        backend = FakeBackend(None)
+        backend.defaults = backend.configuration
+        self.assertRaises(QiskitError, lambda: schedule(qc, backend))
+
     def test_alap_pass(self):
         """Test ALAP scheduling."""
         q = QuantumRegister(2)