You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I determined this is the correct repository in which to report this bug.
Summary of the issue
Context
Running mypy on this official code sample (copy and paste into a file batch_example.py and running mypy batch_example.py)
Expected Behavior:
No mypy errors
Actual Behavior:
mypy errors:
batch_example.py:66: error: Incompatible types in assignment (expression has type"int", variable has type"Destination") [assignment]
Found 1 error in 1 file (checked 1 source file)
API client name and version
google-cloud-batch v0.17.28
Reproduction steps: code
fromgoogle.cloudimportbatch_v1defcreate_container_job(project_id: str, region: str, job_name: str) ->batch_v1.Job:
""" This method shows how to create a sample Batch Job that will run a simple command inside a container on Cloud Compute instances. Args: project_id: project ID or project number of the Cloud project you want to use. region: name of the region you want to use to run the job. Regions that are available for Batch are listed on: https://cloud.google.com/batch/docs/get-started#locations job_name: the name of the job that will be created. It needs to be unique for each project and region pair. Returns: A job object representing the job created. """client=batch_v1.BatchServiceClient()
# Define what will be done as part of the job.runnable=batch_v1.Runnable()
runnable.container=batch_v1.Runnable.Container()
runnable.container.image_uri="gcr.io/google-containers/busybox"runnable.container.entrypoint="/bin/sh"runnable.container.commands= [
"-c",
"echo Hello world! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks.",
]
# Jobs can be divided into tasks. In this case, we have only one task.task=batch_v1.TaskSpec()
task.runnables= [runnable]
# We can specify what resources are requested by each task.resources=batch_v1.ComputeResource()
resources.cpu_milli=2000# in milliseconds per cpu-second. This means the task requires 2 whole CPUs.resources.memory_mib=16# in MiBtask.compute_resource=resourcestask.max_retry_count=2task.max_run_duration="3600s"# Tasks are grouped inside a job using TaskGroups.# Currently, it's possible to have only one task group.group=batch_v1.TaskGroup()
group.task_count=4group.task_spec=task# Policies are used to define on what kind of virtual machines the tasks will run on.# In this case, we tell the system to use "e2-standard-4" machine type.# Read more about machine types here: https://cloud.google.com/compute/docs/machine-typespolicy=batch_v1.AllocationPolicy.InstancePolicy()
policy.machine_type="e2-standard-4"instances=batch_v1.AllocationPolicy.InstancePolicyOrTemplate()
instances.policy=policyallocation_policy=batch_v1.AllocationPolicy()
allocation_policy.instances= [instances]
job=batch_v1.Job()
job.task_groups= [group]
job.allocation_policy=allocation_policyjob.labels= {"env": "testing", "type": "container"}
# We use Cloud Logging as it's an out of the box available optionjob.logs_policy=batch_v1.LogsPolicy()
job.logs_policy.destination=batch_v1.LogsPolicy.Destination.CLOUD_LOGGINGcreate_request=batch_v1.CreateJobRequest()
create_request.job=jobcreate_request.job_id=job_name# The job's parent is the region in which the job will runcreate_request.parent=f"projects/{project_id}/locations/{region}"returnclient.create_job(create_request)
Reproduction steps: supporting files
No response
Reproduction steps: actual results
batch_example.py:66: error: Incompatible types in assignment (expression has type"int", variable has type"Destination") [assignment]
Found 1 error in 1 file (checked 1 source file)
Thanks for reporting this issue. I'm going to transfer this issue to the repository where the client library code generator lives so this issue can be addressed.
parthea
transferred this issue from googleapis/google-cloud-python
Oct 19, 2024
Determine this is the right repository
Summary of the issue
Context
Running
mypy
on this official code sample (copy and paste into a filebatch_example.py
and runningmypy batch_example.py
)Expected Behavior:
No mypy errors
Actual Behavior:
mypy errors:
API client name and version
google-cloud-batch v0.17.28
Reproduction steps: code
Reproduction steps: supporting files
No response
Reproduction steps: actual results
Reproduction steps: expected results
OS & version + platform
macOS 15.0.1
Python environment
Python 3.11.10
Python dependencies
The text was updated successfully, but these errors were encountered: