Trying to follow the example here to launch a custom job in vertex ai.
This is the code I am using
from google.cloud import aiplatform
def create_custom_job_sample(
project: str,
display_name: str,
container_image_uri: str,
location: str = "us-central1",
api_endpoint: str = "us-central1-aiplatform.googleapis.com",
):
# The AI Platform services require regional API endpoints.
client_options = {"api_endpoint": api_endpoint}
# Initialize client that will be used to create and send requests.
# This client only needs to be created once, and can be reused for multiple requests.
client = aiplatform.gapic.JobServiceClient(client_options=client_options)
custom_job = {
"display_name": display_name,
"job_spec": {
"worker_pool_specs": [
{
"machine_spec": {
"machine_type": "n1-standard-4"
},
"replica_count": 1,
"container_spec": {
"image_uri": container_image_uri,
"command": [],
"args": [],
},
}
]
},
}
parent = f"projects/{project}/locations/{location}"
response = client.create_custom_job(parent=parent, custom_job=custom_job)
print("response:", response)
create_custom_job_sample(
"MY_PROJECT",
"job-123",
"europe-west1-docker.pkg.dev/<MYPROJECT>/<MY_IMAGE_URI>",
"europe-west1",
"eu-west1-aiplatform.googleapis.com"
)
However I get an error that start with
E0728 15:00:53.742356000 4417760704 hpack_parser.cc:1234] Error parsing metadata: error=invalid value key=content-type value=text/html; charset=UTF-8
and ends with
google.api_core.exceptions.Unknown: None Stream removed
Don't understand what the problem is. The job starts correctly from the terminal with
gcloud ai custom-jobs create \
--region=europe-west1 \
--display-name=test-job-1 \
--worker-pool-spec=machine-type=n1-standard-4,replica-count=1,executor-image-uri=<MY_IMAGE_URI>,local-package-path=.,script=myfolder/myscript.py
Could someone help me?