Repository: quantumlib/Cirq

Issue:
Remove references to cirq.google in cirq core / contrib
In a bunch of our tests, there are a bunch of cirq.google references that need to be cleaned up in order to be able to extract cirq.google as a separate module.

```
git grep cirq.google | grep -v "cirq/google" | grep -v "json_test" | grep -v "docs" | grep -v "examples" | grep -v "json_serialization" | grep -v "setup"
```

These need to be replaced with cirq.google independent logic. 

```
cirq/circuits/circuit_dag_test.py:    circuit = cirq.Circuit(cirq.X(q0), cirq.Y(q0), device=cirq.google.Bristlecone)
cirq/circuits/circuit_dag_test.py:    q0, q1, q2, q3 = cirq.google.Bristlecone.col(5)[:4]
cirq/circuits/circuit_dag_test.py:        device=cirq.google.Bristlecone,
cirq/circuits/circuit_test.py:import cirq.google as cg
cirq/circuits/circuit_test.py:    c = circuit_cls(device=cirq.google.Bristlecone)
cirq/circuits/circuit_test.py:    assert c2.device is cirq.google.Bristlecone
cirq/circuits/circuit_test.py:    c = circuit_cls(device=cirq.google.Bristlecone)
cirq/circuits/circuit_test.py:    assert repr(c) == f'cirq.{circuit_cls.__name__}(device=cirq.google.Foxtail)'
cirq/circuits/circuit_test.py:], device=cirq.google.Foxtail)"""
cirq/circuits/frozen_circuit_test.py:        c.device = cirq.google.devices.Foxtail
cirq/experiments/random_quantum_circuit_generation_test.py:    yield cirq.google.SYC(a, b)
cirq/experiments/random_quantum_circuit_generation_test.py:            lambda a, b, _: cirq.google.SYC(a, b),
cirq/experiments/random_quantum_circuit_generation_test.py:            lambda a, b, _: cirq.google.SYC(a, b),
cirq/experiments/random_quantum_circuit_generation_test.py:            lambda a, b, _: cirq.google.SYC(a, b),
cirq/experiments/random_quantum_circuit_generation_test.py:            lambda a, b, _: cirq.google.SYC(a, b),
cirq/ops/three_qubit_gates_test.py:    ops = tuple(cirq.flatten_op_tree(cirq.google.ConvertToXmonGates().convert(op)))
cirq/ops/three_qubit_gates_test.py:        cirq.google.ConvertToXmonGates().optimize_circuit(circuit)
cirq/ops/three_qubit_gates_test.py:        cirq.google.Foxtail.validate_circuit(circuit)
cirq/optimizers/cphase_to_fsim_test.py:        fsim_gate = cirq.google.SYC
cirq/optimizers/cphase_to_fsim_test.py:            cphase_gate=cirq.CZ, fsim_gate=cirq.google.SYC, qubits=cirq.LineQubit.range(3)
cirq/optimizers/cphase_to_fsim_test.py:    ops = cirq.decompose_cphase_into_two_fsim(cirq.CZ, fsim_gate=cirq.google.SYC)
cirq/optimizers/cphase_to_fsim_test.py:            assert isinstance(op.gate, cirq.google.SycamoreGate)
cirq/optimizers/cphase_to_fsim_test.py:    assert_decomposition_valid(cphase_gate, cirq.google.SYC)
cirq/optimizers/two_qubit_to_fsim_test.py:    cirq.google.SYC,
dev_tools/packaging/verify-published-package.sh:    "${tmp_dir}/${PYTHON_VERSION}/bin/python" -c "import cirq; print(cirq.google.Foxtail)"
dev_tools/profiling/benchmark_simulators.py:test_device = cirq.google.XmonDevice(
```

In contrib: 

```
cirq/contrib/noise_models/noise_models.py:from cirq.google import engine
cirq/contrib/noise_models/noise_models.py:# TODO: move this to cirq.google with simple_noise_from_calibration_metrics.
cirq/contrib/noise_models/noise_models.py:# TODO: move this to cirq.google since it's Google-specific code.
cirq/contrib/noise_models/noise_models_test.py:from cirq.google.api import v2
cirq/contrib/noise_models/noise_models_test.py:    calibration = cirq.google.Calibration(_CALIBRATION_DATA)
cirq/contrib/noise_models/noise_models_test.py:    calibration = cirq.google.Calibration(_CALIBRATION_DATA)
cirq/contrib/noise_models/noise_models_test.py:    calibration = cirq.google.Calibration(_CALIBRATION_DATA)
cirq/contrib/noise_models/noise_models_test.py:    calibration = cirq.google.Calibration(_CALIBRATION_DATA)
cirq/contrib/noise_models/noise_models_test.py:    calibration = cirq.google.Calibration(_CALIBRATION_DATA)
cirq/contrib/noise_models/noise_models_test.py:    calibration = cirq.google.Calibration(_CALIBRATION_DATA)
cirq/contrib/paulistring/recombine_test.py:    baseline_len = len(cirq.google.optimized_for_xmon(c_orig))
cirq/contrib/paulistring/recombine_test.py:    opt_len1 = len(cirq.google.optimized_for_xmon(c_recombined1))
cirq/contrib/paulistring/recombine_test.py:    opt_len2 = len(cirq.google.optimized_for_xmon(c_recombined2))
cirq/contrib/paulistring/separate.py:        circuit: Any Circuit that cirq.google.optimized_for_xmon() supports.
cirq/contrib/quantum_volume/quantum_volume.py:    device_or_qubits: Union[cirq.google.XmonDevice, List[cirq.GridQubit]],
cirq/contrib/quantum_volume/quantum_volume_test.py:        device_graph=ccr.xmon_device_to_graph(cirq.google.Bristlecone),
cirq/contrib/quantum_volume/quantum_volume_test.py:        device_graph=ccr.xmon_device_to_graph(cirq.google.Bristlecone),
cirq/contrib/quantum_volume/quantum_volume_test.py:        cirq.contrib.routing.xmon_device_to_graph(cirq.google.Bristlecone),
cirq/contrib/quantum_volume/quantum_volume_test.py:        device_graph=ccr.xmon_device_to_graph(cirq.google.Bristlecone),
cirq/contrib/quantum_volume/quantum_volume_test.py:        device_graph=ccr.xmon_device_to_graph(cirq.google.Bristlecone),
cirq/contrib/quantum_volume/quantum_volume_test.py:        device_graph=ccr.xmon_device_to_graph(cirq.google.Bristlecone),
cirq/contrib/quantum_volume/quantum_volume_test.py:            device_graph=ccr.xmon_device_to_graph(cirq.google.Bristlecone),
cirq/contrib/quantum_volume/quantum_volume_test.py:        device_or_qubits=cirq.google.Bristlecone,
cirq/contrib/quantum_volume/quantum_volume_test.py:        device_or_qubits=cirq.google.Bristlecone,
cirq/contrib/quantum_volume/quantum_volume_test.py:        device_or_qubits=cirq.google.Bristlecone,
cirq/contrib/routing/device.py:def xmon_device_to_graph(device: cirq.google.XmonDevice) -> nx.Graph:
cirq/contrib/routing/device.py:    >>> g = ccr.xmon_device_to_graph(cirq.google.Foxtail)
cirq/contrib/routing/device_test.py:    foxtail_graph = ccr.xmon_device_to_graph(cirq.google.Foxtail)
cirq/contrib/routing/device_test.py:    foxtail_graph = ccr.xmon_device_to_graph(cirq.google.Foxtail)
```


Discussion:

Resolving patch:
diff --git a/cirq/__init__.py b/cirq/__init__.py
--- a/cirq/__init__.py
+++ b/cirq/__init__.py
@@ -11,6 +11,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+from logging import warning
 
 from cirq import _import
 
@@ -51,7 +52,6 @@
     interop,
     # Applications
     experiments,
-    google,
     # Extra (nothing should depend on these)
     testing,
 )
@@ -564,12 +564,17 @@
 # Unflattened sub-modules.
 
 from cirq import (
-    google,
     ionq,
     pasqal,
     testing,
 )
 
+try:
+    from cirq import google
+except ImportError as ex:
+    # coverage: ignore
+    warning("Can't import cirq.google: ", ex)
+
 
 def _register_resolver() -> None:
     """Registers the cirq module's public classes for JSON serialization."""
diff --git a/cirq/ops/measurement_gate.py b/cirq/ops/measurement_gate.py
--- a/cirq/ops/measurement_gate.py
+++ b/cirq/ops/measurement_gate.py
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from typing import Any, Dict, Iterable, Optional, Tuple, Sequence, TYPE_CHECKING, List
+from typing import Any, Dict, Iterable, Optional, Tuple, Sequence, TYPE_CHECKING
 
 import numpy as np
 
diff --git a/dev_tools/profiling/benchmark_simulators.py b/dev_tools/profiling/benchmark_simulators.py
--- a/dev_tools/profiling/benchmark_simulators.py
+++ b/dev_tools/profiling/benchmark_simulators.py
@@ -26,17 +26,9 @@
 _DENSITY = 'density_matrix'
 
 
-test_device = cirq.google.XmonDevice(
-    measurement_duration=cirq.Duration(nanos=1000),
-    exp_w_duration=cirq.Duration(nanos=20),
-    exp_11_duration=cirq.Duration(nanos=50),
-    qubits=[cirq.GridQubit(0, k) for k in range(100)],
-)
-
-
 def simulate(sim_type: str, num_qubits: int, num_gates: int, run_repetitions: int = 1) -> None:
     """"Runs the simulator."""
-    circuit = cirq.Circuit(device=test_device)
+    circuit = cirq.Circuit()
 
     for _ in range(num_gates):
         which = np.random.choice(['expz', 'expw', 'exp11'])


Test patch:
diff --git a/cirq/circuits/frozen_circuit_test.py b/cirq/circuits/frozen_circuit_test.py
--- a/cirq/circuits/frozen_circuit_test.py
+++ b/cirq/circuits/frozen_circuit_test.py
@@ -55,4 +55,4 @@ def test_immutable():
         c.moments = (cirq.Moment(cirq.H(q)), cirq.Moment(cirq.X(q)))
 
     with pytest.raises(AttributeError, match="can't set attribute"):
-        c.device = cirq.google.devices.Foxtail
+        c.device = cirq.UNCONSTRAINED_DEVICE
diff --git a/cirq/contrib/paulistring/recombine_test.py b/cirq/contrib/paulistring/recombine_test.py
--- a/cirq/contrib/paulistring/recombine_test.py
+++ b/cirq/contrib/paulistring/recombine_test.py
@@ -11,10 +11,9 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-
+import pytest
 
 import cirq
-
 from cirq.contrib.paulistring import (
     convert_and_separate_circuit,
     pauli_string_dag_from_circuit,
@@ -29,6 +28,7 @@ def _assert_no_multi_qubit_pauli_strings(circuit: cirq.Circuit) -> None:
 
 
 def test_move_non_clifford_into_clifford():
+    cg = pytest.importorskip("cirq.google")
     q0, q1, q2 = cirq.LineQubit.range(3)
     c_orig = cirq.testing.nonoptimal_toffoli_circuit(q0, q1, q2)
 
@@ -43,8 +43,8 @@ def test_move_non_clifford_into_clifford():
     _assert_no_multi_qubit_pauli_strings(c_recombined1)
     _assert_no_multi_qubit_pauli_strings(c_recombined2)
 
-    baseline_len = len(cirq.google.optimized_for_xmon(c_orig))
-    opt_len1 = len(cirq.google.optimized_for_xmon(c_recombined1))
-    opt_len2 = len(cirq.google.optimized_for_xmon(c_recombined2))
+    baseline_len = len(cg.optimized_for_xmon(c_orig))
+    opt_len1 = len(cg.optimized_for_xmon(c_recombined1))
+    opt_len2 = len(cg.optimized_for_xmon(c_recombined2))
     assert opt_len1 <= baseline_len
     assert opt_len2 <= baseline_len
diff --git a/cirq/experiments/google_v2_supremacy_circuit_test.py b/cirq/experiments/google_v2_supremacy_circuit_test.py
--- a/cirq/experiments/google_v2_supremacy_circuit_test.py
+++ b/cirq/experiments/google_v2_supremacy_circuit_test.py
@@ -45,6 +45,7 @@ def test_google_v2_supremacy_circuit():
 
 
 def test_google_v2_supremacy_bristlecone():
+    pytest.importorskip("cirq.google")
     # Check instance consistency
     c = supremacy_v2.generate_boixo_2018_supremacy_circuits_v2_bristlecone(
         n_rows=11, cz_depth=8, seed=0
@@ -71,6 +72,7 @@ def test_google_v2_supremacy_bristlecone():
 
 
 def test_n_rows_less_than_2():
+    pytest.importorskip("cirq.google")
     with pytest.raises(AssertionError):
         supremacy_v2.generate_boixo_2018_supremacy_circuits_v2_bristlecone(
             n_rows=1, cz_depth=0, seed=0
diff --git a/cirq/experiments/random_quantum_circuit_generation_test.py b/cirq/experiments/random_quantum_circuit_generation_test.py
--- a/cirq/experiments/random_quantum_circuit_generation_test.py
+++ b/cirq/experiments/random_quantum_circuit_generation_test.py
@@ -257,6 +257,11 @@ def _cz_with_adjacent_z_rotations(
     yield cirq.Z(b) ** z_exponents[3]
 
 
+class FakeSycamoreGate(cirq.FSimGate):
+    def __init__(self):
+        super().__init__(theta=np.pi / 2, phi=np.pi / 6)
+
+
 @pytest.mark.parametrize(
     'qubits, depth, two_qubit_op_factory, pattern, '
     'single_qubit_gates, add_final_single_qubit_layer, '
@@ -278,7 +283,7 @@ def _cz_with_adjacent_z_rotations(
         (
             cirq.GridQubit.rect(4, 3),
             20,
-            lambda a, b, _: cirq.google.SYC(a, b),
+            lambda a, b, _: FakeSycamoreGate()(a, b),
             cirq.experiments.HALF_GRID_STAGGERED_PATTERN,
             (cirq.X ** 0.5, cirq.Y ** 0.5, cirq.Z ** 0.5),
             True,
diff --git a/cirq/google/devices/known_devices_test.py b/cirq/google/devices/known_devices_test.py
--- a/cirq/google/devices/known_devices_test.py
+++ b/cirq/google/devices/known_devices_test.py
@@ -15,7 +15,7 @@
 import pytest
 
 import cirq
-import cirq.google as cg
+import cirq.google
 import cirq.google.common_serializers as cgc
 import cirq.google.devices.known_devices as known_devices
 
@@ -301,7 +301,7 @@ def test_create_device_proto_for_irregular_grid():
 
 
 def test_multiple_gate_sets():
-    halfPiGateSet = cg.serializable_gate_set.SerializableGateSet(
+    halfPiGateSet = cirq.google.serializable_gate_set.SerializableGateSet(
         gate_set_name='half_pi_gateset',
         serializers=[*cgc.SINGLE_QUBIT_HALF_PI_SERIALIZERS, cgc.MEASUREMENT_SERIALIZER],
         deserializers=[*cgc.SINGLE_QUBIT_HALF_PI_DESERIALIZERS, cgc.MEASUREMENT_DESERIALIZER],
@@ -314,7 +314,7 @@ def test_multiple_gate_sets():
         'meas': 14_141,
     }
     test_proto = known_devices.create_device_proto_from_diagram(
-        "aa\naa", [cg.gate_sets.XMON, halfPiGateSet], durations_dict
+        "aa\naa", [cirq.google.gate_sets.XMON, halfPiGateSet], durations_dict
     )
     assert (
         str(test_proto)
@@ -457,7 +457,7 @@ def test_multiple_gate_sets():
 
 
 def test_json_dict():
-    assert cg.Foxtail._json_dict_() == {
+    assert cirq.google.Foxtail._json_dict_() == {
         'cirq_type': '_NamedConstantXmonDevice',
         'constant': 'cirq.google.Foxtail',
     }
@@ -471,7 +471,7 @@ def test_json_dict():
         known_devices._NamedConstantXmonDevice._from_json_dict_('the_unknown_fiddler')
 
 
-@pytest.mark.parametrize('device', [cg.Sycamore, cg.Sycamore23])
+@pytest.mark.parametrize('device', [cirq.google.Sycamore, cirq.google.Sycamore23])
 def test_sycamore_devices(device):
     q0 = cirq.GridQubit(5, 3)
     q1 = cirq.GridQubit(5, 4)
@@ -489,26 +489,28 @@ def test_sycamore_grid_layout():
     q1 = cirq.GridQubit(5, 6)
     syc = cirq.FSimGate(theta=np.pi / 2, phi=np.pi / 6)(q0, q1)
     sqrt_iswap = cirq.FSimGate(theta=np.pi / 4, phi=0)(q0, q1)
-    cg.Sycamore.validate_operation(syc)
-    cg.Sycamore.validate_operation(sqrt_iswap)
+    cirq.google.Sycamore.validate_operation(syc)
+    cirq.google.Sycamore.validate_operation(sqrt_iswap)
 
     with pytest.raises(ValueError):
-        cg.Sycamore23.validate_operation(syc)
+        cirq.google.Sycamore23.validate_operation(syc)
     with pytest.raises(ValueError):
-        cg.Sycamore23.validate_operation(sqrt_iswap)
+        cirq.google.Sycamore23.validate_operation(sqrt_iswap)
 
 
 def test_proto_with_waitgate():
-    wait_gateset = cg.serializable_gate_set.SerializableGateSet(
+    wait_gateset = cirq.google.serializable_gate_set.SerializableGateSet(
         gate_set_name='wait_gateset',
         serializers=[cgc.WAIT_GATE_SERIALIZER],
         deserializers=[cgc.WAIT_GATE_DESERIALIZER],
     )
-    wait_proto = cg.devices.known_devices.create_device_proto_from_diagram(
+    wait_proto = cirq.google.devices.known_devices.create_device_proto_from_diagram(
         "aa\naa",
         [wait_gateset],
     )
-    wait_device = cg.SerializableDevice.from_proto(proto=wait_proto, gate_sets=[wait_gateset])
+    wait_device = cirq.google.SerializableDevice.from_proto(
+        proto=wait_proto, gate_sets=[wait_gateset]
+    )
     q0 = cirq.GridQubit(1, 1)
     wait_op = cirq.wait(q0, nanos=25)
     wait_device.validate_operation(wait_op)
@@ -560,7 +562,7 @@ def test_proto_with_waitgate():
 
 
 def test_adding_gates_multiple_times():
-    waiting_for_godot = cg.serializable_gate_set.SerializableGateSet(
+    waiting_for_godot = cirq.google.serializable_gate_set.SerializableGateSet(
         gate_set_name='wait_gateset',
         serializers=[cgc.WAIT_GATE_SERIALIZER, cgc.WAIT_GATE_SERIALIZER, cgc.WAIT_GATE_SERIALIZER],
         deserializers=[
@@ -569,11 +571,13 @@ def test_adding_gates_multiple_times():
             cgc.WAIT_GATE_DESERIALIZER,
         ],
     )
-    wait_proto = cg.devices.known_devices.create_device_proto_from_diagram(
+    wait_proto = cirq.google.devices.known_devices.create_device_proto_from_diagram(
         "aa",
         [waiting_for_godot],
     )
-    wait_device = cg.SerializableDevice.from_proto(proto=wait_proto, gate_sets=[waiting_for_godot])
+    wait_device = cirq.google.SerializableDevice.from_proto(
+        proto=wait_proto, gate_sets=[waiting_for_godot]
+    )
     q0 = cirq.GridQubit(0, 0)
     wait_op = cirq.wait(q0, nanos=25)
     wait_device.validate_operation(wait_op)
diff --git a/cirq/optimizers/cphase_to_fsim_test.py b/cirq/optimizers/cphase_to_fsim_test.py
--- a/cirq/optimizers/cphase_to_fsim_test.py
+++ b/cirq/optimizers/cphase_to_fsim_test.py
@@ -8,11 +8,16 @@
 import cirq
 
 
+class FakeSycamoreGate(cirq.FSimGate):
+    def __init__(self):
+        super().__init__(theta=np.pi / 2, phi=np.pi / 6)
+
+
 def test_parameterized_gates():
     t = sympy.Symbol('t')
     with pytest.raises(ValueError):
         cphase_gate = cirq.CZPowGate(exponent=t)
-        fsim_gate = cirq.google.SYC
+        fsim_gate = FakeSycamoreGate()
         cirq.decompose_cphase_into_two_fsim(cphase_gate, fsim_gate=fsim_gate)
 
     with pytest.raises(ValueError):
@@ -29,18 +34,19 @@ def test_parameterized_gates():
 def test_invalid_qubits():
     with pytest.raises(ValueError):
         cirq.decompose_cphase_into_two_fsim(
-            cphase_gate=cirq.CZ, fsim_gate=cirq.google.SYC, qubits=cirq.LineQubit.range(3)
+            cphase_gate=cirq.CZ, fsim_gate=FakeSycamoreGate(), qubits=cirq.LineQubit.range(3)
         )
 
 
 def test_circuit_structure():
-    ops = cirq.decompose_cphase_into_two_fsim(cirq.CZ, fsim_gate=cirq.google.SYC)
+    syc = FakeSycamoreGate()
+    ops = cirq.decompose_cphase_into_two_fsim(cirq.CZ, fsim_gate=syc)
     num_interaction_moments = 0
     for op in ops:
         assert len(op.qubits) in (0, 1, 2)
         if len(op.qubits) == 2:
             num_interaction_moments += 1
-            assert isinstance(op.gate, cirq.google.SycamoreGate)
+            assert isinstance(op.gate, FakeSycamoreGate)
     assert num_interaction_moments == 2
 
 
@@ -56,7 +62,7 @@ def assert_decomposition_valid(cphase_gate, fsim_gate):
 )
 def test_decomposition_to_sycamore_gate(exponent):
     cphase_gate = cirq.CZPowGate(exponent=exponent)
-    assert_decomposition_valid(cphase_gate, cirq.google.SYC)
+    assert_decomposition_valid(cphase_gate, FakeSycamoreGate())
 
 
 @pytest.mark.parametrize(
diff --git a/cirq/optimizers/two_qubit_to_fsim_test.py b/cirq/optimizers/two_qubit_to_fsim_test.py
--- a/cirq/optimizers/two_qubit_to_fsim_test.py
+++ b/cirq/optimizers/two_qubit_to_fsim_test.py
@@ -26,7 +26,6 @@
 
 FEASIBLE_FSIM_GATES = [
     cirq.ISWAP,
-    cirq.google.SYC,
     cirq.FSimGate(np.pi / 2, 0),
     cirq.FSimGate(-np.pi / 2, 0),
     cirq.FSimGate(np.pi / 2, np.pi / 6),
diff --git a/cirq/protocols/json_test_data/TaggedOperation.json b/cirq/protocols/json_test_data/TaggedOperation.json
--- a/cirq/protocols/json_test_data/TaggedOperation.json
+++ b/cirq/protocols/json_test_data/TaggedOperation.json
@@ -18,7 +18,7 @@
   [
     "tag1",
     {
-      "cirq_type": "PhysicalZTag"
+      "cirq_type": "VirtualTag"
     }
   ]
 }
\ No newline at end of file
diff --git a/cirq/protocols/json_test_data/TaggedOperation.repr b/cirq/protocols/json_test_data/TaggedOperation.repr
--- a/cirq/protocols/json_test_data/TaggedOperation.repr
+++ b/cirq/protocols/json_test_data/TaggedOperation.repr
@@ -1 +1 @@
-cirq.TaggedOperation(cirq.X.on(cirq.NamedQubit('q1')), 'tag1', cirq.google.PhysicalZTag())
\ No newline at end of file
+cirq.TaggedOperation(cirq.X.on(cirq.NamedQubit('q1')), 'tag1', cirq.ops.VirtualTag())
\ No newline at end of file
diff --git a/dev_tools/notebooks/notebook_test.py b/dev_tools/notebooks/notebook_test.py
--- a/dev_tools/notebooks/notebook_test.py
+++ b/dev_tools/notebooks/notebook_test.py
@@ -23,6 +23,7 @@
 import glob
 import os
 import subprocess
+from logging import warning
 from typing import Set
 
 import pytest
@@ -45,8 +46,12 @@
 
 
 def _list_all_notebooks() -> Set[str]:
-    output = subprocess.check_output(['git', 'ls-files', '*.ipynb'])
-    return set(output.decode('utf-8').splitlines())
+    try:
+        output = subprocess.check_output(['git', 'ls-files', '*.ipynb'])
+        return set(output.decode('utf-8').splitlines())
+    except subprocess.CalledProcessError as ex:
+        warning("It seems that tests are run from not a git repo, notebook tests are skipped", ex)
+        return set()
 
 
 def _tested_notebooks():
diff --git a/dev_tools/profiling/benchmark_simulators_test.py b/dev_tools/profiling/benchmark_simulators_test.py
--- a/dev_tools/profiling/benchmark_simulators_test.py
+++ b/dev_tools/profiling/benchmark_simulators_test.py
@@ -13,7 +13,6 @@
 # limitations under the License.
 
 """Tests for the simulator benchmarker."""
-
 from dev_tools.profiling import benchmark_simulators
 
 
diff --git a/examples/advanced/quantum_volume_test.py b/examples/advanced/quantum_volume_test.py
--- a/examples/advanced/quantum_volume_test.py
+++ b/examples/advanced/quantum_volume_test.py
@@ -1,15 +1,14 @@
 """Tests for the Quantum Volume benchmarker."""
 
-from unittest.mock import Mock, MagicMock
-import io
-import numpy as np
+import pytest
+
 from examples.advanced import quantum_volume
-import cirq
 
 
 def test_main_loop():
     """Test that the main loop is able to run without erring."""
     # Keep test from taking a long time by lowering repetitions.
+    pytest.importorskip("cirq.google")
     args = '--num_qubits 5 --depth 5 --num_circuits 1  --routes 3'.split()
     quantum_volume.main(**quantum_volume.parse_arguments(args))
 
diff --git a/examples/direct_fidelity_estimation_test.py b/examples/direct_fidelity_estimation_test.py
--- a/examples/direct_fidelity_estimation_test.py
+++ b/examples/direct_fidelity_estimation_test.py
@@ -1,7 +1,6 @@
 import numpy as np
 import pytest
 import cirq
-import cirq.google as cg
 import examples.direct_fidelity_estimation as dfe
 
 
@@ -62,10 +61,7 @@ def test_direct_fidelity_estimation_with_noise_non_clifford():
 def test_incorrect_sampler_raises_exception():
     qubits = cirq.LineQubit.range(1)
     circuit = cirq.Circuit(cirq.X(qubits[0]))
-
-    sampler_incorrect_type = cg.QuantumEngineSampler(
-        engine=None, processor_id='dummy_id', gate_set=[]
-    )
+    sampler_incorrect_type = cirq.ZerosSampler
 
     with pytest.raises(TypeError):
         dfe.direct_fidelity_estimation(
diff --git a/examples/examples_test.py b/examples/examples_test.py
--- a/examples/examples_test.py
+++ b/examples/examples_test.py
@@ -53,6 +53,7 @@ def test_example_runs_deutsch():
 
 
 def test_example_runs_hello_line():
+    pytest.importorskip("cirq.google")
     examples.place_on_bristlecone.main()
 
 
@@ -73,6 +74,7 @@ def test_example_runs_quantum_fourier_transform():
 
 
 def test_example_runs_bcs_mean_field():
+    pytest.importorskip("cirq.google")
     examples.bcs_mean_field.main()
 
 
@@ -89,6 +91,7 @@ def test_example_runs_phase_estimator():
 
 
 def test_example_heatmaps():
+    pytest.importorskip("cirq.google")
     plt.switch_backend('agg')
     examples.heatmaps.main()