Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/google-cloud-bigquery-reservation/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ In order to use this library, you first need to go through the following steps:
1. `Select or create a Cloud Platform project.`_
2. `Enable billing for your project.`_
3. `Enable the BigQuery Reservation.`_
4. `Setup Authentication.`_
4. `Set up Authentication.`_

.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
.. _Enable the BigQuery Reservation.: https://cloud.google.com/bigquery/docs/reference/reservations
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
.. _Set up Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html

Installation
~~~~~~~~~~~~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "1.16.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "1.16.0" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def _prep_wrapped_messages(self, client_info):
),
self.failover_reservation: gapic_v1.method.wrap_method(
self.failover_reservation,
default_timeout=None,
default_timeout=300.0,
client_info=client_info,
),
self.create_capacity_commitment: gapic_v1.method.wrap_method(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ def _prep_wrapped_messages(self, client_info):
),
self.failover_reservation: self._wrap_method(
self.failover_reservation,
default_timeout=None,
default_timeout=300.0,
client_info=client_info,
),
self.create_capacity_commitment: self._wrap_method(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,15 @@ class Reservation(proto.Message):
runtime if ignore_idle_slots is set to false, or autoscaling
is enabled.

If edition is EDITION_UNSPECIFIED and total slot_capacity of
the reservation and its siblings exceeds the total
slot_count of all capacity commitments, the request will
fail with ``google.rpc.Code.RESOURCE_EXHAUSTED``.

If edition is any value but EDITION_UNSPECIFIED, then the
above requirement is not needed. The total slot_capacity of
the reservation and its siblings may exceed the total
slot_count of capacity commitments. In that case, the
exceeding slots will be charged with the autoscale SKU. You
can increase the number of baseline slots in a reservation
every few minutes. If you want to decrease your baseline
slots, you are limited to once an hour if you have recently
changed your baseline slot capacity and your baseline slots
exceed your committed slots. Otherwise, you can decrease
your baseline slots every few minutes.
The total slot_capacity of the reservation and its siblings
may exceed the total slot_count of capacity commitments. In
that case, the exceeding slots will be charged with the
autoscale SKU. You can increase the number of baseline slots
in a reservation every few minutes. If you want to decrease
your baseline slots, you are limited to once an hour if you
have recently changed your baseline slot capacity and your
baseline slots exceed your committed slots. Otherwise, you
can decrease your baseline slots every few minutes.
ignore_idle_slots (bool):
If false, any query or pipeline job using this reservation
will use idle slots from other reservations within the same
Expand Down Expand Up @@ -165,7 +158,7 @@ class Reservation(proto.Message):
edition (google.cloud.bigquery_reservation_v1.types.Edition):
Edition of the reservation.
primary_location (str):
Optional. The current location of the
Output only. The current location of the
reservation's primary replica. This field is
only set for reservations using the managed
disaster recovery feature.
Expand All @@ -179,11 +172,24 @@ class Reservation(proto.Message):
convert a non-failover reservation to a failover
reservation(or vice versa).
original_primary_location (str):
Optional. The location where the reservation
was originally created. This is set only during
the failover reservation's creation. All billing
charges for the failover reservation will be
applied to this location.
Output only. The location where the
reservation was originally created. This is set
only during the failover reservation's creation.
All billing charges for the failover reservation
will be applied to this location.
replication_status (google.cloud.bigquery_reservation_v1.types.Reservation.ReplicationStatus):
Output only. The Disaster Recovery(DR)
replication status of the reservation. This is
only available for the primary replicas of
DR/failover reservations and provides
information about the both the staleness of the
secondary and the last error encountered while
trying to replicate changes from the primary to
the secondary. If this field is blank, it means
that the reservation is either not a DR
reservation or the reservation is a DR secondary
or that any replication operations on the
reservation have succeeded.
"""

class Autoscale(proto.Message):
Expand All @@ -210,6 +216,43 @@ class Autoscale(proto.Message):
number=2,
)

class ReplicationStatus(proto.Message):
r"""Disaster Recovery(DR) replication status of the reservation.

Attributes:
error (google.rpc.status_pb2.Status):
Output only. The last error encountered while
trying to replicate changes from the primary to
the secondary. This field is only available if
the replication has not succeeded since.
last_error_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. The time at which the last error
was encountered while trying to replicate
changes from the primary to the secondary. This
field is only available if the replication has
not succeeded since.
last_replication_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. A timestamp corresponding to the
last change on the primary that was successfully
replicated to the secondary.
"""

error: status_pb2.Status = proto.Field(
proto.MESSAGE,
number=1,
message=status_pb2.Status,
)
last_error_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=2,
message=timestamp_pb2.Timestamp,
)
last_replication_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
)

name: str = proto.Field(
proto.STRING,
number=1,
Expand Down Expand Up @@ -262,6 +305,11 @@ class Autoscale(proto.Message):
proto.STRING,
number=20,
)
replication_status: ReplicationStatus = proto.Field(
proto.MESSAGE,
number=24,
message=ReplicationStatus,
)


class CapacityCommitment(proto.Message):
Expand Down Expand Up @@ -897,6 +945,16 @@ class Assignment(proto.Message):
Which type of jobs will use the reservation.
state (google.cloud.bigquery_reservation_v1.types.Assignment.State):
Output only. State of the assignment.
enable_gemini_in_bigquery (bool):
Optional. This field controls if "Gemini in BigQuery"
(https://cloud.google.com/gemini/docs/bigquery/overview)
features should be enabled for this reservation assignment,
which is not on by default. "Gemini in BigQuery" has a
distinct compliance posture from BigQuery. If this field is
set to true, the assignment job type is QUERY, and the
parent reservation edition is ENTERPRISE_PLUS, then the
assignment will give the grantee project/organization access
to "Gemini in BigQuery" features.
"""

class JobType(proto.Enum):
Expand All @@ -920,12 +978,18 @@ class JobType(proto.Enum):
BACKGROUND (4):
Background jobs that BigQuery runs for the
customers in the background.
CONTINUOUS (6):
Continuous SQL jobs will use this
reservation. Reservations with continuous
assignments cannot be mixed with non-continuous
assignments.
"""
JOB_TYPE_UNSPECIFIED = 0
PIPELINE = 1
QUERY = 2
ML_EXTERNAL = 3
BACKGROUND = 4
CONTINUOUS = 6

class State(proto.Enum):
r"""Assignment will remain in PENDING state if no active capacity
Expand Down Expand Up @@ -963,6 +1027,10 @@ class State(proto.Enum):
number=6,
enum=State,
)
enable_gemini_in_bigquery: bool = proto.Field(
proto.BOOL,
number=10,
)


class CreateAssignmentRequest(proto.Message):
Expand Down
81 changes: 79 additions & 2 deletions packages/google-cloud-bigquery-reservation/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,20 +382,29 @@ def docfx(session):
["python", "upb", "cpp"],
)
def prerelease_deps(session, protobuf_implementation):
"""Run all tests with prerelease versions of dependencies installed."""
"""
Run all tests with pre-release versions of dependencies installed
rather than the standard non pre-release versions.
Pre-releases versions can be installed using
`pip install --pre <package>`.
"""

if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"):
session.skip("cpp implementation is not supported in python 3.11+")

# Install all dependencies
session.install("-e", ".[all, tests, tracing]")
session.install("-e", ".")

unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
# Install dependencies for the unit test environment
session.install(*unit_deps_all)

system_deps_all = (
SYSTEM_TEST_STANDARD_DEPENDENCIES
+ SYSTEM_TEST_EXTERNAL_DEPENDENCIES
+ SYSTEM_TEST_EXTRAS
)
# Install dependencies for the system test environment
session.install(*system_deps_all)

# Because we test minimum dependency versions on the minimum Python
Expand All @@ -417,6 +426,7 @@ def prerelease_deps(session, protobuf_implementation):
)
]

# Install dependencies specified in `testing/constraints-X.txt`.
session.install(*constraints_deps)

prerel_deps = [
Expand Down Expand Up @@ -458,3 +468,70 @@ def prerelease_deps(session, protobuf_implementation):
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)


@nox.session(python="3.13")
@nox.parametrize(
"protobuf_implementation",
["python", "upb"],
)
def core_deps_from_source(session, protobuf_implementation):
"""Run all tests with local versions of core dependencies installed,
rather than pulling core dependencies from PyPI.
"""

# Install all dependencies
session.install(".")

# Install dependencies for the unit test environment
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
session.install(*unit_deps_all)

# Install dependencies for the system test environment
system_deps_all = (
SYSTEM_TEST_STANDARD_DEPENDENCIES
+ SYSTEM_TEST_EXTERNAL_DEPENDENCIES
+ SYSTEM_TEST_EXTRAS
)
session.install(*system_deps_all)

# Because we test minimum dependency versions on the minimum Python
# version, the first version we test with in the unit tests sessions has a
# constraints file containing all dependencies and extras that should be installed.
with open(
CURRENT_DIRECTORY
/ "testing"
/ f"constraints-{UNIT_TEST_PYTHON_VERSIONS[0]}.txt",
encoding="utf-8",
) as constraints_file:
constraints_text = constraints_file.read()

# Ignore leading whitespace and comment lines.
constraints_deps = [
match.group(1)
for match in re.finditer(
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
)
]

# Install dependencies specified in `testing/constraints-X.txt`.
session.install(*constraints_deps)

core_dependencies_from_source = [
"google-api-core @ git+https://github.com/googleapis/python-api-core.git",
"google-auth @ git+https://github.com/googleapis/google-auth-library-python.git",
f"{CURRENT_DIRECTORY}/../googleapis-common-protos",
f"{CURRENT_DIRECTORY}/../grpc-google-iam-v1",
"proto-plus @ git+https://github.com/googleapis/proto-plus-python.git",
]

for dep in core_dependencies_from_source:
session.install(dep, "--ignore-installed", "--no-deps")

session.run(
"py.test",
"tests/unit",
env={
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-bigquery-reservation",
"version": "1.16.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Loading