Search code examples
google-cloud-platformgoogle-cloud-mlgoogle-cloud-datalab

Syntax Error When Running `gcloud ml-engine` commands in Google Datalab


I am trying to deploy a model to Google ML Engine using DataLab. The code works in my live project datalab but gives a syntax error on my staging datalab. I thought this may be due to different versions of gcloud and so I ran the updates but I am still getting the same syntax error. How can I fix this?

Code:

MODEL_NAME="waittimes_model_03"
MODEL_VERSION="ml_on_gcp_waittimes_06"
gcloud ml-engine models create ${MODEL_NAME} --regions us-central1
gcloud ml-engine versions create ${MODEL_VERSION} --model ${MODEL_NAME} --origin waitestimates/export/exporter/1532010994 --staging-bucket ${BUCKET}  --runtime-version 1.6

Error:

File "<ipython-input-4-104542ff058c>", line 8
    gcloud ml-engine models create ${MODEL_NAME} --regions us-central1
            ^
SyntaxError: invalid syntax

Solution

  • Add the ! prefix to your command, e.g.,

    !gcloud ml-engine models create ${MODEL_NAME} --regions us-central1