GRS
GRS

Reputation: 3084

Does Google CloudML Serving allow connecting to NoSQL DBs e.g. Datastore?

We have a model currently serving on Cloud ML. As a modification we added connections to datastore, which return 403, Insufficient privileges.

The mock code generating the error is:

    from google.cloud import datastore
    import datetime
    # create & upload task
    client = datastore.Client()
    key = client.key('Task')
    task = datastore.Entity(
        key, exclude_from_indexes=['description'])

    task.update({
        'created': datetime.datetime.utcnow(),
        'description': 'description',
        'done': False
    })

    client.put(task)

    # now list tasks
    query = client.query(kind='Task')
    query.order = ['created']
    return list(query.fetch())

The next step would be adding credentials (service account) and exporting new path to GOOGLE_APPLICATION_DEFAULT parameter. However, since getting this account is difficult (company layering), I'd like to save time by asking the question.

Is the only way of communication with a NoSQL DB via Cloud Functions? Is that the common approach?

Upvotes: 1

Views: 33

Answers (1)

gogasca
gogasca

Reputation: 10058

When you create your Model, you need custom prediction, and define a service account that has access to your resources.

gcloud components install beta

gcloud beta ai-platform versions create your-version-name \
  --service-account your-service-account-name@your-project-id.iam.gserviceaccount.com
  ...

Upvotes: 1

Related Questions