Fix backend checking to not do string comparison.
@@ -78,18 +78,19 @@ def run_algorithm(params, algo_input=None, json_output=False, backend=None):
algorithm._circuit_caching = inputparser.get_section_property(JSONSchema.PROBLEM, 'circuit_caching')
algorithm._caching_naughty_mode = inputparser.get_section_property(JSONSchema.PROBLEM, 'caching_naughty_mode')
algorithm._cache_file = inputparser.get_section_property(JSONSchema.PROBLEM, 'circuit_cache_file')
- if algorithm._caching_naughty_mode and 'simulator' not in backend:
- raise AlgorithmError("Caching naughty mode can only be used with local backends, but {} backend specified."
- .format(backend))
- if algorithm._circuit_caching and not backend_cfg['skip_transpiler']:
- raise AlgorithmError("Circuit caching cannot be used with transpiler on. Set skip_transpiler to True to use "
- "caching.")
if not algorithm._circuit_caching and algorithm._caching_naughty_mode :
logging.warning("You should not use caching naughty mode if caching is disabled.")
if backend_cfg is not None:
algorithm.setup_quantum_backend(**backend_cfg)
+ if algorithm._caching_naughty_mode and not algorithm.backend.configuration()['local']:
+ raise AlgorithmError("Caching naughty mode can only be used with local backends, but {} backend specified."
+ .format(backend))
+ if algorithm._circuit_caching and not backend_cfg['skip_transpiler']:
+ raise AlgorithmError("Circuit caching cannot be used with transpiler on. Set skip_transpiler to True to use "
+ "caching.")
+
algo_params = copy.deepcopy(inputparser.get_sections())
if algo_input is None:
