Пример #1
0
def test_configure_http_instance_kwargs():
    http = http_utils.configure_http_instance(HTTPMock())
    actual = http.request("uri",
                          "bla",
                          "blahh",
                          headers={'user-agent': "uatest"})
    assert actual == EXPECTED_UA + " uatest"
Пример #2
0
    def __init__(self, model_dir, model_name, version_name, project_id=None,
                 **deploy_kwargs):
        self._project_id = project_id or guess_project_name()

        self._model_dir = model_dir
        self._model_name = model_name
        self._version_name = version_name
        self._deploy_kwargs = deploy_kwargs
        self._ml = discovery.build('ml', 'v1')
        self._ml._http = http_utils.configure_http_instance(self._ml._http) #pylint:disable=protected-access

        # Set default deploy kwargs
        if 'runtime_version' not in self._deploy_kwargs:
            self._deploy_kwargs['runtime_version'] = '1.13'
        if 'python_version' not in self._deploy_kwargs:
            self._deploy_kwargs['python_version'] = '3.5'
Пример #3
0
 def __init__(self, project_id=None, region=None, scale_tier=None,
              job_config=None, use_stream_logs=False):
     """
     :param project_id: Google Cloud project ID to use.
     :param region: region in which the job has to be deployed.
         Ref: https://cloud.google.com/compute/docs/regions-zones/
     :param scale_tier: machine type to use for the job.
         Ref: https://cloud.google.com/ml-engine/docs/tensorflow/machine-types
     :param job_config: Custom job configuration options. If an option is specified
         in the job_config and as a top-level parameter, the parameter overrides
         the value in the job_config.
         Ref: https://cloud.google.com/ml-engine/reference/rest/v1/projects.jobs
     :param use_stream_logs: If true, when deploying a job, output the job stream
         log until the job ends.
     """
     self._project_id = project_id or guess_project_name()
     self._region = region or 'us-central1'
     self._job_config = job_config or {}
     self.scale_tier = scale_tier
     self._ml = discovery.build('ml', 'v1')
     self._ml._http = http_utils.configure_http_instance(self._ml._http) #pylint:disable=protected-access
     self._use_stream_logs = use_stream_logs
Пример #4
0
def test_configure_http_instance_args_no_ua():
    http = http_utils.configure_http_instance(HTTPMock())
    actual = http.request("uri", "bla", "blahh", {'not_ua': "uatest"})
    assert actual == EXPECTED_UA
Пример #5
0
def test_configure_http_instance_empty_args():
    http = http_utils.configure_http_instance(HTTPMock())
    actual = http.request()
    assert actual == EXPECTED_UA