Skip to content

Commit

Permalink
Generate protos for Models API. (googleapis#488)
Browse files Browse the repository at this point in the history
* Generate protos for Models API.

The Models API is a component of the bigquery_v2 interface.
It is not available as a gRPC API, but it does provide
protocol buffers. This commit adds those protocol buffers
to the client so that they can be used to avoid much manual
work to create resource classes that can be serialized to/from
JSON.
  • Loading branch information
tswast committed Mar 25, 2019
1 parent 675dbd8 commit 97a4451
Show file tree
Hide file tree
Showing 24 changed files with 4,643 additions and 10 deletions.
7 changes: 3 additions & 4 deletions bigquery/LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
https://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

Expand Down Expand Up @@ -193,7 +192,7 @@
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
4 changes: 3 additions & 1 deletion bigquery/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include README.rst LICENSE
recursive-include google *.json *.proto
recursive-include tests *
global-exclude *.pyc __pycache__
global-exclude *.py[co]
global-exclude __pycache__
5 changes: 5 additions & 0 deletions bigquery/docs/gapic/v2/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Types for BigQuery API Client
=============================

.. automodule:: google.cloud.bigquery_v2.types
:members:
12 changes: 11 additions & 1 deletion bigquery/docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,19 @@ External Configuration


Magics
======================
======

.. toctree::
:maxdepth: 2

magics

Additional Types
================

Protocol buffer classes for working with the Models API.

.. toctree::
:maxdepth: 2

gapic/v2/types
6 changes: 4 additions & 2 deletions bigquery/google/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Copyright 2016 Google LLC
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
6 changes: 4 additions & 2 deletions bigquery/google/cloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Copyright 2016 Google LLC
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
Empty file.
121 changes: 121 additions & 0 deletions bigquery/google/cloud/bigquery_v2/gapic/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Wrappers for protocol buffer enum types."""

import enum


class Model(object):
class DataSplitMethod(enum.IntEnum):
"""
Indicates the method to split input data into multiple tables.
Attributes:
DATA_SPLIT_METHOD_UNSPECIFIED (int)
RANDOM (int): Splits data randomly.
CUSTOM (int): Splits data with the user provided tags.
SEQUENTIAL (int): Splits data sequentially.
NO_SPLIT (int): Data split will be skipped.
AUTO_SPLIT (int): Splits data automatically: Uses NO\_SPLIT if the data size is small.
Otherwise uses RANDOM.
"""

DATA_SPLIT_METHOD_UNSPECIFIED = 0
RANDOM = 1
CUSTOM = 2
SEQUENTIAL = 3
NO_SPLIT = 4
AUTO_SPLIT = 5

class LearnRateStrategy(enum.IntEnum):
"""
Indicates the learning rate optimization strategy to use.
Attributes:
LEARN_RATE_STRATEGY_UNSPECIFIED (int)
LINE_SEARCH (int): Use line search to determine learning rate.
CONSTANT (int): Use a constant learning rate.
"""

LEARN_RATE_STRATEGY_UNSPECIFIED = 0
LINE_SEARCH = 1
CONSTANT = 2

class LossType(enum.IntEnum):
"""
Loss metric to evaluate model training performance.
Attributes:
LOSS_TYPE_UNSPECIFIED (int)
MEAN_SQUARED_LOSS (int): Mean squared loss, used for linear regression.
MEAN_LOG_LOSS (int): Mean log loss, used for logistic regression.
"""

LOSS_TYPE_UNSPECIFIED = 0
MEAN_SQUARED_LOSS = 1
MEAN_LOG_LOSS = 2

class ModelType(enum.IntEnum):
"""
Indicates the type of the Model.
Attributes:
MODEL_TYPE_UNSPECIFIED (int)
LINEAR_REGRESSION (int): Linear regression model.
LOGISTIC_REGRESSION (int): Logistic regression model.
"""

MODEL_TYPE_UNSPECIFIED = 0
LINEAR_REGRESSION = 1
LOGISTIC_REGRESSION = 2


class StandardSqlDataType(object):
class TypeKind(enum.IntEnum):
"""
Attributes:
TYPE_KIND_UNSPECIFIED (int): Invalid type.
INT64 (int): Encoded as a string in decimal format.
BOOL (int): Encoded as a boolean "false" or "true".
FLOAT64 (int): Encoded as a number, or string "NaN", "Infinity" or "-Infinity".
STRING (int): Encoded as a string value.
BYTES (int): Encoded as a base64 string per RFC 4648, section 4.
TIMESTAMP (int): Encoded as an RFC 3339 timestamp with mandatory "Z" time zone string:
1985-04-12T23:20:50.52Z
DATE (int): Encoded as RFC 3339 full-date format string: 1985-04-12
TIME (int): Encoded as RFC 3339 partial-time format string: 23:20:50.52
DATETIME (int): Encoded as RFC 3339 full-date "T" partial-time: 1985-04-12T23:20:50.52
GEOGRAPHY (int): Encoded as WKT
NUMERIC (int): Encoded as a decimal string.
ARRAY (int): Encoded as a list with types matching Type.array\_type.
STRUCT (int): Encoded as a list with fields of type Type.struct\_type[i]. List is used
because a JSON object cannot have duplicate field names.
"""

TYPE_KIND_UNSPECIFIED = 0
INT64 = 2
BOOL = 5
FLOAT64 = 7
STRING = 8
BYTES = 9
TIMESTAMP = 19
DATE = 10
TIME = 20
DATETIME = 21
GEOGRAPHY = 22
NUMERIC = 23
ARRAY = 16
STRUCT = 17
Empty file.
34 changes: 34 additions & 0 deletions bigquery/google/cloud/bigquery_v2/proto/location_metadata.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

syntax = "proto3";

package google.cloud.bigquery.v2;

import "google/api/annotations.proto";

option go_package = "google.golang.org/genproto/googleapis/cloud/bigquery/v2;bigquery";
option java_outer_classname = "LocationMetadataProto";
option java_package = "com.google.cloud.bigquery.v2";


// BigQuery-specific metadata about a location. This will be set on
// google.cloud.location.Location.metadata in Cloud Location API
// responses.
message LocationMetadata {
// The legacy BigQuery location ID, e.g. “EU” for the “europe” location.
// This is for any API consumers that need the legacy “US” and “EU” locations.
string legacy_location_id = 1;
}
98 changes: 98 additions & 0 deletions bigquery/google/cloud/bigquery_v2/proto/location_metadata_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc
Loading

0 comments on commit 97a4451

Please sign in to comment.