It has been a few days that GCP AutoML WebUI cannot export models for offline inference (support team says it is a front end component bug that has been fixed, it has been a few days and it not yet).
Said that, I am usually not a fan of GUI to do that, I was hoping I could use CLI or Python google-cloud-automl API to the job. I have to admit Google sucks at documentation, and they keep constantly changing functionalities without giving details and examples. Although all kind of functionalities are working (bucket listing, bucket creation, data upload to bucket, even model training etc.), but model export has been a headache and hard to configure. Before we proceed, please note that GOOGLE_APPLICATION_CREDENTIALS is added to the environment. What I have tried so far:
1. via POST:
# get the token
access_token = subprocess.check_output(
'gcloud auth application-default print-access-token', shell=True)
data = {
"outputConfig": {
"modelFormat": "tf_saved_model", #or "tf-saved-model"
"gcsDestination": {
"outputUriPrefix": "gs://bucket/folder"
}
}
}
headers = {
'Authorization': f'Bearer {access_token.decode().rstrip()}',
'Content-Type': 'application/json; charset=utf-8',
}
url= f"https://automl.googleapis.com/v1/projects/{project_id}/locations/us-central1/models/{model_id}:export"
response = requests.post(url, headers=headers, json=data)
fails with the response.content:
b'{\n "error": {\n "code": 400,\n "message": "List of found errors:\\t1.Field: name; Message: Required field is invalid\\t",\n "status": "INVALID_ARGUMENT",\n "details": [\n {\n "@type": "type.googleapis.com/google.rpc.BadRequest",\n "fieldViolations": [\n {\n "field": "name",\n "description": "Required field is invalid"\n }\n ]\n }\n ]\n }\n}\n'
2. via google-cloud-automl
location = "us-central1"
client = automl.AutoMlClient()
model_full_id = client.model_path(project=project_id, location=location, model=model_id)
response = client.export_model(????)
There arguments are apparently required (if I run it client.export_model()):
1.Field: name; Message: Location ID was not provided.
2.Field: name; Message: Required field is invalid
3.Field: output_config.gcs_destination.output_uri_prefix; Message: Empty string was given for GCS path or prefix.
I am stuck right in the beginning how to pass arguments. I have tried to configure a metadata for location_to_be_written, and model_format via automl.types.ModelExportOutputConfig(???), but that is a trouble of its own.