def __init__( self, remote_host: str, api_key: str, default_target: str = None, api_version='v0.1', max_retry_seconds: int = 3600, verbose=False, ): """Creates the Service to access IonQ's API. Args: remote_host: The location of the api in the form of an url. api_key: A string key which allows access to the api. default_target: Which target to default to using. If set to None, no default is set and target must always be specified in calls. If set, then this default is used, unless a target is specified for a given call. Supports either 'qpu' or 'simulator'. api_version: Version of the api. Defaults to 'v0.1'. max_retry_seconds: The number of seconds to retry calls for. Defaults to one hour. verbose: Whether to print to stdio and stderr on retriable errors. """ self._client = ionq_client._IonQClient( remote_host=remote_host, api_key=api_key, default_target=default_target, api_version=api_version, max_retry_seconds=max_retry_seconds, verbose=verbose, )
def __init__( self, remote_host: Optional[str] = None, api_key: Optional[str] = None, default_target: str = None, api_version='v0.1', max_retry_seconds: int = 3600, verbose=False, ): """Creates the Service to access IonQ's API. Args: remote_host: The location of the api in the form of an url. If this is None, then this instance will use the environment variable `IONQ_REMOTE_HOST`. If that variable is not set, then this will raise an `EnvironmentError`. api_key: A string key which allows access to the api. If this is None, then this instance will use the environment variable `IONQ_API_KEY`. If that variable is not set, then this will raise an `EnvironmentError`. default_target: Which target to default to using. If set to None, no default is set and target must always be specified in calls. If set, then this default is used, unless a target is specified for a given call. Supports either 'qpu' or 'simulator'. api_version: Version of the api. Defaults to 'v0.1'. max_retry_seconds: The number of seconds to retry calls for. Defaults to one hour. verbose: Whether to print to stdio and stderr on retriable errors. Raises: EnvironmentError: if `remote_host` or `api_key` are None and have no corresponding environment variable set. """ def init_possibly_from_env(param, env_name, var_name): param = param or os.getenv(env_name) if not param: raise EnvironmentError( f'Parameter {var_name} was not specified and the environment variable ' f'{env_name} was also not set.') return param self.remote_host = init_possibly_from_env(remote_host, 'IONQ_REMOTE_HOST', 'remote_host') self.api_key = init_possibly_from_env(api_key, 'IONQ_API_KEY', 'api_key') self._client = ionq_client._IonQClient( remote_host=self.remote_host, api_key=self.api_key, default_target=default_target, api_version=api_version, max_retry_seconds=max_retry_seconds, verbose=verbose, )
def __init__( self, remote_host: Optional[str] = None, api_key: Optional[str] = None, default_target: str = None, api_version='v0.1', max_retry_seconds: int = 3600, verbose=False, ): """Creates the Service to access IonQ's API. Args: remote_host: The location of the api in the form of an url. If this is None, then this instance will use the environment variable `IONQ_REMOTE_HOST`. If that variable is not set, then this uses `https://api.ionq.co/{api_version}`, where `{api_version}` is the `api_version` specified below. api_key: A string key which allows access to the api. If this is None, then this instance will use the environment variable `IONQ_API_KEY`. If that variable is not set, then this will raise an `EnvironmentError`. default_target: Which target to default to using. If set to None, no default is set and target must always be specified in calls. If set, then this default is used, unless a target is specified for a given call. Supports either 'qpu' or 'simulator'. api_version: Version of the api. Defaults to 'v0.1'. max_retry_seconds: The number of seconds to retry calls for. Defaults to one hour. verbose: Whether to print to stdio and stderr on retriable errors. Raises: EnvironmentError: if the `api_key` is None and has no corresponding environment variable set. """ self.remote_host = (remote_host or os.getenv('IONQ_REMOTE_HOST') or f'https://api.ionq.co/{api_version}') self.api_key = api_key or os.getenv('IONQ_API_KEY') if not self.api_key: raise EnvironmentError( f'Parameter api_key was not specified and the environment variable ' f'IONQ_API_KEY was also not set.') self._client = ionq_client._IonQClient( remote_host=self.remote_host, api_key=self.api_key, default_target=default_target, api_version=api_version, max_retry_seconds=max_retry_seconds, verbose=verbose, )