Ejemplo n.º 1
0
    def _wrapper(obj, *args, **kwargs):

        if get_test_options()['skip_online']:
            raise SkipTest('Skipping online tests')

        if os.getenv('USE_STAGING_CREDENTIALS', ''):
            credentials = Credentials(os.getenv('QE_STAGING_TOKEN'),
                                      os.getenv('QE_STAGING_URL'))
            backend_name = os.getenv('QE_STAGING_DEVICE', None)
        else:
            if not get_test_options()['run_slow']:
                raise SkipTest('Skipping slow tests')
            credentials = _get_credentials()
            backend_name = os.getenv('QE_DEVICE', None)

        obj.using_ibmq_credentials = credentials.is_ibmq()
        ibmq_factory = IBMQFactory()
        provider = ibmq_factory.enable_account(credentials.token,
                                               credentials.url)
        kwargs.update({'provider': provider})
        _backend = provider.get_backend(backend_name) if backend_name else \
            least_busy(provider.backends(simulator=False))
        kwargs.update({'backend': _backend})

        return func(obj, *args, **kwargs)
Ejemplo n.º 2
0
    def _wrapper(obj, *args, **kwargs):
        if get_test_options()['skip_online']:
            raise SkipTest('Skipping online tests')

        credentials = _get_credentials()
        kwargs.update({'qe_token': credentials.token,
                       'qe_url': credentials.url})

        return func(obj, *args, **kwargs)
Ejemplo n.º 3
0
    def _wrapper(obj, *args, **kwargs):
        if get_test_options()["skip_online"]:
            raise SkipTest("Skipping online tests")

        credentials = _get_credentials()
        kwargs.update({
            "qe_token": credentials.token,
            "qe_url": credentials.url
        })

        return func(obj, *args, **kwargs)
Ejemplo n.º 4
0
    def _wrapper(obj, *args, **kwargs):

        if get_test_options()['skip_online']:
            raise SkipTest('Skipping online tests')

        if os.getenv('USE_STAGING_CREDENTIALS', ''):
            credentials = Credentials(os.getenv('QE_STAGING_TOKEN'), os.getenv('QE_STAGING_URL'))
            backend_name = os.getenv('QE_STAGING_DEVICE', None)
        else:
            if not get_test_options()['run_slow']:
                raise SkipTest('Skipping slow tests')
            credentials = _get_credentials()
            backend_name = os.getenv('QE_DEVICE', None)

        obj.using_ibmq_credentials = credentials.is_ibmq()
        ibmq_factory = IBMQFactory()
        provider = ibmq_factory.enable_account(credentials.token, credentials.url)

        _backend = None
        if backend_name:
            for provider in ibmq_factory.providers():
                backends = provider.backends(name=backend_name)
                if backends:
                    _backend = backends[0]
                    break
        else:
            _backend = least_busy(provider.backends(
                simulator=False, filters=lambda b: b.configuration().n_qubits >= 5))

        if not _backend:
            raise Exception("Unable to find suitable backend.")

        kwargs.update({'provider': provider})
        kwargs.update({'backend': _backend})

        return func(obj, *args, **kwargs)