GoogleCloudPlatform/practical-ml-vision-book

Chapter Two Permissions error

craine opened this issue · 4 comments

In Chapter Two I'm trying to run this:
CLASS_NAMES = [item.numpy().decode("utf-8") for item in
tf.strings.regex_replace(
tf.io.gfile.glob("gs://cloud-ml-data/img/flower_photos/*"),
"gs://cloud-ml-data/img/flower_photos/", "")]
CLASS_NAMES = [item for item in CLASS_NAMES if item.find(".") == -1]

Looks like I don't have permission to grab these?


PermissionDeniedError Traceback (most recent call last)
in ()
1 CLASS_NAMES = [item.numpy().decode("utf-8") for item in
2 tf.strings.regex_replace(
----> 3 tf.io.gfile.glob("gs://cloud-ml-data/img/flower_photos/*"),
4 "gs://cloud-ml-data/img/flower_photos/", "")]
5 CLASS_NAMES = [item for item in CLASS_NAMES if item.find(".") == -1]

/usr/local/lib/python3.7/dist-packages/tensorflow/python/lib/io/file_io.py in get_matching_files_v2(pattern)
441 compat.as_str_any(matching_filename)
442 for matching_filename in _pywrap_file_io.GetMatchingFiles(
--> 443 compat.as_bytes(pattern))
444 ]
445 else:

PermissionDeniedError: Error executing an HTTP request: HTTP response code 401 with body '{
"error": {
"code": 401,
"message": "Anonymous caller does not have storage.objects.list access to the Google Cloud Storage bucket.",
"errors": [
{
"message": "Anonymous caller does not have storage.objects.list access to the Google Cloud Storage bucket.",
"domain": "global",
"reason": "required",
"locationType": "header",
"location": "Authorization"
}
]
}
}
'
when reading gs://cloud-ml-data/img/flower_photos

Thanks. I'll file a request to get ListPermissions added to the bucket.

Meanwhile, you can workaround this by hardcoding the class names:

CLASS_NAMES = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']

I changed the bucket used. If you update your github repo, the notebook should work now.

Still, this issue is occurring. I am not able to work with the notebook.
PermissionDeniedError: Error executing an HTTP request: HTTP response code 403 with body '<?xml version='1.0' encoding='UTF-8'?><Error><Code>AccessDenied</Code><Message>Access denied.</Message><Details>There is an account problem for the requested project.</Details></Error>' when reading gs://practical-ml-vision-book/flowers_5_jpeg/flower_photos/daisy/754296579_30a9ae018c_n.jpg [Op:ReadFile]