'Creates the Version on Cloud ML.
Returns the operation if the version was created successfully and
raises an error otherwise.'

def create_version(self, project_id, model_name, version_spec):

    parent_name = 'projects/{}/models/{}'.format(project_id, model_name)
    create_request = self._cloudml.projects().models().versions().create(parent=parent_name, body=version_spec)
    response = create_request.execute()
    get_request = self._cloudml.projects().operations().get(name=response['name'])
    return _poll_with_exponential_delay(request=get_request, max_n=9, is_done_func=(lambda resp: resp.get('done', False)), is_error_func=(lambda resp: (resp.get('error', None) is not None)))
