Skip to content

Commit

Permalink
feat: [google-cloud-batch] add a install_ops_agent field to InstanceP…
Browse files Browse the repository at this point in the history
…olicyOrTemplate for Ops Agent support (#12839)

- [ ] Regenerate this pull request now.

BEGIN_COMMIT_OVERRIDE

---

feat: add a install_ops_agent field to InstancePolicyOrTemplate for Ops
Agent support

---

docs:Add instructions on how to configure cross-project pubsub publisher

---
docs: document default disk type: pd-standard for non boot disk,
pd-balanced for boot disk

---
docs: Update list of volume.mount_options field

---
docs: Update GCS description of volume.mount_options field

---
docs: Update links in the description of volume.mount_options field

END_COMMIT_OVERRIDE

PiperOrigin-RevId: 646638165

Source-Link:
googleapis/googleapis@0333730

Source-Link:
googleapis/googleapis-gen@1521ef6
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiIxNTIxZWY2MjA5YmNkNjJlOTkyNGYyY2VhZWU1YzM2NDExNTEwYTNiIn0=

BEGIN_NESTED_COMMIT

docs: [google-cloud-batch]Add instructions on how to configure
cross-project pubsub publisher

---

docs: document default disk type: pd-standard for non boot disk,
pd-balanced for boot disk

---
docs: Update list of volume.mount_options field

---
docs: Update GCS description of volume.mount_options field

---
docs: Update links in the description of volume.mount_options field




PiperOrigin-RevId: 646637874

Source-Link:
googleapis/googleapis@a0eb8ce

Source-Link:
googleapis/googleapis-gen@ecfc6d5
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiJlY2ZjNmQ1ODNlN2NhZDEyOTBjNDM1ZWM4MGQzODFiNWUzMTY5Mjg4In0=
END_NESTED_COMMIT

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Victor Chudnovsky <vchudnov@google.com>
  • Loading branch information
3 people authored Jun 27, 2024
1 parent 7ce3bf4 commit bcd061f
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 55 deletions.
2 changes: 1 addition & 1 deletion packages/google-cloud-batch/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Python Client for Cloud Batch
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-batch.svg
:target: https://pypi.org/project/google-cloud-batch/
.. _Cloud Batch: https://cloud.google.com/batch/docs
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/batch/latest
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/batch/latest/summary_overview
.. _Product Documentation: https://cloud.google.com/batch/docs

Quick Start
Expand Down
5 changes: 5 additions & 0 deletions packages/google-cloud-batch/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ For a list of all ``google-cloud-batch`` releases:
:maxdepth: 2

CHANGELOG

.. toctree::
:hidden:

summary_overview.md
22 changes: 22 additions & 0 deletions packages/google-cloud-batch/docs/summary_overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
This is a templated file. Adding content to this file may result in it being
reverted. Instead, if you want to place additional content, create an
"overview_content.md" file in `docs/` directory. The Sphinx tool will
pick up on the content and merge the content.
]: #

# Cloud Batch API

Overview of the APIs available for Cloud Batch API.

## All entries

Classes, methods and properties & attributes for
Cloud Batch API.

[classes](https://cloud.google.com/python/docs/reference/batch/latest/summary_class.html)

[methods](https://cloud.google.com/python/docs/reference/batch/latest/summary_method.html)

[properties and
attributes](https://cloud.google.com/python/docs/reference/batch/latest/summary_property.html)
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__ = "0.17.21" # {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__ = "0.17.21" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
31 changes: 25 additions & 6 deletions packages/google-cloud-batch/google/cloud/batch_v1/types/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,19 @@ class JobNotification(proto.Message):
Attributes:
pubsub_topic (str):
The Pub/Sub topic where notifications like the job state
changes will be published. The topic must exist in the same
project as the job and billings will be charged to this
project. If not specified, no Pub/Sub messages will be sent.
Topic format: ``projects/{project}/topics/{topic}``.
The Pub/Sub topic where notifications for the job, like
state changes, will be published. If undefined, no Pub/Sub
notifications are sent for this job.
Specify the topic using the following format:
``projects/{project}/topics/{topic}``. Notably, if you want
to specify a Pub/Sub topic that is in a different project
than the job, your administrator must grant your project's
Batch service agent permission to publish to that topic.
For more information about configuring Pub/Sub notifications
for a job, see
https://cloud.google.com/batch/docs/enable-notifications.
message (google.cloud.batch_v1.types.JobNotification.Message):
The attribute requirements of messages to be
sent to this Pub/Sub topic. Without this field,
Expand Down Expand Up @@ -556,7 +564,10 @@ class Disk(proto.Message):
Disk type as shown in ``gcloud compute disk-types list``.
For example, local SSD uses type "local-ssd". Persistent
disks and boot disks use "pd-balanced", "pd-extreme",
"pd-ssd" or "pd-standard".
"pd-ssd" or "pd-standard". If not specified, "pd-standard"
will be used as the default type for non-boot disks,
"pd-balanced" will be used as the default type for boot
disks.
size_gb (int):
Disk size in GB.
Expand Down Expand Up @@ -797,6 +808,10 @@ class InstancePolicyOrTemplate(proto.Message):
https://cloud.google.com/container-optimized-os/docs/release-notes.
For non Container-Optimized Image cases, following
https://github.com/GoogleCloudPlatform/compute-gpu-installation/blob/main/linux/install_gpu_driver.py.
install_ops_agent (bool):
Optional. Set this field true if you want
Batch to install Ops Agent on your behalf.
Default is false.
"""

policy: "AllocationPolicy.InstancePolicy" = proto.Field(
Expand All @@ -814,6 +829,10 @@ class InstancePolicyOrTemplate(proto.Message):
proto.BOOL,
number=3,
)
install_ops_agent: bool = proto.Field(
proto.BOOL,
number=4,
)

class NetworkInterface(proto.Message):
r"""A network interface.
Expand Down
28 changes: 15 additions & 13 deletions packages/google-cloud-batch/google/cloud/batch_v1/types/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,21 @@ class Volume(proto.Message):
The mount path for the volume, e.g.
/mnt/disks/share.
mount_options (MutableSequence[str]):
For Google Cloud Storage (GCS), mount options
are the options supported by the gcsfuse tool
(https://github.com/GoogleCloudPlatform/gcsfuse).
For existing persistent disks, mount options
provided by the mount command
(https://man7.org/linux/man-pages/man8/mount.8.html)
except writing are supported. This is due to
restrictions of multi-writer mode
(https://cloud.google.com/compute/docs/disks/sharing-disks-between-vms).
For other attached disks and Network File System
(NFS), mount options are these supported by the
mount command
(https://man7.org/linux/man-pages/man8/mount.8.html).
Mount options vary based on the type of storage volume:
- For a Cloud Storage bucket, all the mount options
provided by the ```gcsfuse``
tool <https://cloud.google.com/storage/docs/gcsfuse-cli>`__
are supported.
- For an existing persistent disk, all mount options
provided by the ```mount``
command <https://man7.org/linux/man-pages/man8/mount.8.html>`__
except writing are supported. This is due to restrictions
of `multi-writer
mode <https://cloud.google.com/compute/docs/disks/sharing-disks-between-vms>`__.
- For any other disk or a Network File System (NFS), all
the mount options provided by the ``mount`` command are
supported.
"""

nfs: "NFS" = proto.Field(
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__ = "0.17.21" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,19 @@ class JobNotification(proto.Message):
Attributes:
pubsub_topic (str):
The Pub/Sub topic where notifications like the job state
changes will be published. The topic must exist in the same
project as the job and billings will be charged to this
project. If not specified, no Pub/Sub messages will be sent.
Topic format: ``projects/{project}/topics/{topic}``.
The Pub/Sub topic where notifications for the job, like
state changes, will be published. If undefined, no Pub/Sub
notifications are sent for this job.
Specify the topic using the following format:
``projects/{project}/topics/{topic}``. Notably, if you want
to specify a Pub/Sub topic that is in a different project
than the job, your administrator must grant your project's
Batch service agent permission to publish to that topic.
For more information about configuring Pub/Sub notifications
for a job, see
https://cloud.google.com/batch/docs/enable-notifications.
message (google.cloud.batch_v1alpha.types.JobNotification.Message):
The attribute requirements of messages to be
sent to this Pub/Sub topic. Without this field,
Expand Down Expand Up @@ -676,7 +684,10 @@ class Disk(proto.Message):
Disk type as shown in ``gcloud compute disk-types list``.
For example, local SSD uses type "local-ssd". Persistent
disks and boot disks use "pd-balanced", "pd-extreme",
"pd-ssd" or "pd-standard".
"pd-ssd" or "pd-standard". If not specified, "pd-standard"
will be used as the default type for non-boot disks,
"pd-balanced" will be used as the default type for boot
disks.
size_gb (int):
Disk size in GB.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,21 @@ class Volume(proto.Message):
The mount path for the volume, e.g.
/mnt/disks/share.
mount_options (MutableSequence[str]):
For Google Cloud Storage (GCS), mount options
are the options supported by the gcsfuse tool
(https://github.com/GoogleCloudPlatform/gcsfuse).
For existing persistent disks, mount options
provided by the mount command
(https://man7.org/linux/man-pages/man8/mount.8.html)
except writing are supported. This is due to
restrictions of multi-writer mode
(https://cloud.google.com/compute/docs/disks/sharing-disks-between-vms).
For other attached disks and Network File System
(NFS), mount options are these supported by the
mount command
(https://man7.org/linux/man-pages/man8/mount.8.html).
Mount options vary based on the type of storage volume:
- For a Cloud Storage bucket, all the mount options
provided by the ```gcsfuse``
tool <https://cloud.google.com/storage/docs/gcsfuse-cli>`__
are supported.
- For an existing persistent disk, all mount options
provided by the ```mount``
command <https://man7.org/linux/man-pages/man8/mount.8.html>`__
except writing are supported. This is due to restrictions
of `multi-writer
mode <https://cloud.google.com/compute/docs/disks/sharing-disks-between-vms>`__.
- For any other disk or a Network File System (NFS), all
the mount options provided by the ``mount`` command are
supported.
"""

nfs: "NFS" = proto.Field(
Expand Down
46 changes: 35 additions & 11 deletions packages/google-cloud-batch/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints):
session.install("-e", ".", *constraints)


def default(session):
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
@nox.parametrize(
"protobuf_implementation",
["python", "upb", "cpp"],
)
def unit(session, protobuf_implementation):
# Install all test dependencies, then install this package in-place.

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

constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
install_unittest_dependencies(session, "-c", constraints_path)

# TODO(https://github.com/googleapis/synthtool/issues/1976):
# Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
# The 'cpp' implementation requires Protobuf<4.
if protobuf_implementation == "cpp":
session.install("protobuf<4")

# Run py.test against the unit tests.
session.run(
"py.test",
Expand All @@ -181,15 +195,12 @@ def default(session):
"--cov-fail-under=0",
os.path.join("tests", "unit"),
*session.posargs,
env={
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)


@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
def unit(session):
"""Run the unit test suite."""
default(session)


def install_systemtest_dependencies(session, *constraints):
# Use pre-release gRPC for system tests.
# Exclude version 1.52.0rc1 which has a known issue.
Expand Down Expand Up @@ -358,9 +369,16 @@ def docfx(session):


@nox.session(python="3.12")
def prerelease_deps(session):
@nox.parametrize(
"protobuf_implementation",
["python", "upb", "cpp"],
)
def prerelease_deps(session, protobuf_implementation):
"""Run all tests with prerelease versions of dependencies installed."""

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

# Install all dependencies
session.install("-e", ".[all, tests, tracing]")
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
Expand Down Expand Up @@ -397,9 +415,9 @@ def prerelease_deps(session):
"protobuf",
# dependency of grpc
"six",
"grpc-google-iam-v1",
"googleapis-common-protos",
# Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163
"grpcio!=1.52.0rc1",
"grpcio",
"grpcio-status",
"google-api-core",
"google-auth",
Expand All @@ -425,4 +443,10 @@ def prerelease_deps(session):
session.run("python", "-c", "import grpc; print(grpc.__version__)")
session.run("python", "-c", "import google.auth; print(google.auth.__version__)")

session.run("py.test", "tests/unit")
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-batch",
"version": "0.17.21"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-batch",
"version": "0.17.21"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3879,6 +3879,7 @@ def test_create_job_rest(request_type):
},
"instance_template": "instance_template_value",
"install_gpu_drivers": True,
"install_ops_agent": True,
}
],
"service_account": {
Expand Down

0 comments on commit bcd061f

Please sign in to comment.