Re: [google-appengine] Google Translate API & Permissions

2021-09-28 Thread wesley chun
All, I'm happy to announce that I've finally published the blog post

(Tweet

& FB post

for sharing) I promised. Summarizing the 2 things that would've improved
Joshua's initial experience:

   1. Awareness of the *Google Cloud client libraries* (he used the Google
   APIs client libraries, lower-level and somewhat more challenging) — I'm
   working on a follow-up post explaining why we have two different types of
   client libraries and when you'd use one vs. the other.
   2. Awareness of *default service accounts* — these exist for all our
   serverless platforms and come pre-baked w/enough IAM permissions to get a
   prototype working; that gives you more time to research specific IAM
   roles/perms the app will need when you get closer to production.

The point is to make products that people can get started on without much
friction but also allow for more sophisticated usage as needed. I've also
provided Joshua's feedback directly to folks on our serverless platform
teams. Anyway, hope this helps and please let me know if you have any
questions; also reshare as desired to your developer social networks! (BTW,
thx for the kind words Eric!)

Cheers,
--Wesley

On Sat, May 8, 2021 at 6:09 AM Eric Hardy  wrote:

> Thank you Wesley.  I appreciate your efforts.  I want to spend more time
> site building than wrestling with a cloud platform.  I will follow the
> above mentioned links to nut this out.
>
> On Sat, May 8, 2021 at 9:20 AM wesley chun  wrote:
>
>> @Joshua: your inquiry inspired me to do some research into this issue
>> over the past few months resulting in the following:
>>
>> 1. *Use Cloud client libraries:* yep, your experience was not fun for
>> any developer looking to use a Cloud API (whether App Engine or a simple
>> cmd-line script). One solution is to avoid the Google APIs client library
>>  and use the Google
>> Cloud client libraries
>>  instead, and
>> in your case just the one for Cloud Translation
>> (basic/v2
>>  or
>> advanced/v3
>> ).
>> (I'm also working on a blog post to outline the differences between these 
>> *platform
>> vs. product* client libraries, so stay tuned for that.) With the Cloud
>> Translation client library (which hides a lot of low-level details), your
>> code sample can be as simple as:
>>
>> from __future__ import print_function
>> import google.auth
>> from google.cloud import translate
>>
>> TRANSLATE = translate.TranslationServiceClient()
>> _, PROJECT_ID = google.auth.default()
>> PARENT = 'projects/{}'.format(PROJECT_ID)
>> TARGET_LANG = 'es'
>> TEXT = 'Hello world'
>> DATA = {
>> 'parent': PARENT,
>> 'contents': [TEXT],
>> 'target_language_code': TARGET_LANG,
>> }
>> try:# Python 3/advanced/v3
>> rsp = TRANSLATE.translate_text(request=DATA)
>> except TypeError:   # Python 2/basic/v2
>> rsp = TRANSLATE.translate_text(**DATA)
>> print(TEXT, '=', rsp.translations[0].translated_text)
>>
>> It works in Python 2 and 3 without any modification:
>>
>> $ python2 translate_demo2.py
>> Hello world = Hola Mundo
>> $ python3 translate_demo2.py
>> Hello world = Hola Mundo
>>
>> You should be able to just drop something like this right into your App
>> Engine code (plus the necessary stuff in app.yaml and requirements.txt).
>> App Engine comes with a default service account
>> ,
>> so you don't need to mess with all you did unless you need to (create a
>> separate service account and public/private key-pair) for other reasons. To
>> run this script *locally* (as I did above), you *do* need to do that
>> (create a service acct & keypair, download the JSON credentials file to
>> your local system, then point GOOGLE_APPLICATION_CREDENTIALS to it), but
>> not on App Engine (nor Cloud Functions nor Cloud Run) as *all 3* have
>> default service accounts.
>>
>> 2. *Sample app:* I created a simple Python 2 GAE app that uses that
>> Cloud Translation code to get an idea of what you went through and
>> discovered it wasn't that bad if the product client library is used. Then I
>> wanted to see how challenging it would be to port it to Python 3 (since you
>> got to at some point) as well as running it locally. Then I thought, "Why
>> not try to throw the 

[google-appengine] Re: 500 - Request was aborted after waiting too long to attempt to service your reques

2021-09-28 Thread Will Reiher
Totally, not a huge amount of them but definitely more RPC errors and 
timeouts in the last week or so. I'd expect the odd one but it would seem 
that some infrastructure changes are causing issues.

On Tuesday, September 21, 2021 at 7:57:13 AM UTC-7 Leonard Cremer wrote:

> We are suddenly getting a lot of these type of errors on services that 
> have not changed recently. 
>
> Is anyone else experiencing similar errors. 
>

-- 


How we’re addressing COVID-19


Health and safety is our top priority. We 
have made arrangements for all staff to work remotely from home to continue 
to provide uninterrupted service, expertise and advice to our authors and 
prospective customers during the unfolding COVID-19 situation. Click here 
for more information .

Connect with 
us at:
 

FriesenPress Mailing Address 
| One Printers Way, Altona, MB, Canada, R0G 0B0
friesenpress.com 


You are receiving this email because you 
are a FriesenPress client or partner. This email and any documents attached 
to it may contain confidential information. If you are not the intended 
recipient, you are hereby notified that any disclosure, copying or 
distribution of the contents of this email is prohibited. 

If you no 
longer wish to receive emails from FriesenPress, *please click here to 
unsubscribe.*  The privacy 
of your information is important to us. To learn more, visit our *privacy 
policy. *

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/34da15c0-cfdc-4b7e-bd7d-782d318be9c0n%40googlegroups.com.


[google-appengine] operational error - attempt to write a readonly database

2021-09-28 Thread Asim Ahmed
Hi, 
I am new to GCP and I have deployed a toy django app. I am getting the 
following error when I try to access admin page while signing in.

I have added the user/password to the SQL instance. 

Regards
OperationalError at /admin/login/attempt to write a readonly 
databaseRequest Method:
POSTRequest URL:
https://asim800.appspot.com/admin/login/?next=/admin/Django Version:
3.2.7Exception Type:
OperationalErrorException Value:
attempt to write a readonly databaseException Location:
/layers/google.python.pip/pip/lib/python3.8/site-packages/django/db/backends/sqlite3/base.py,
 
line 423, in executePython Executable:
/layers/google.python.pip/pip/bin/python3Python Version:
3.8.12


  1416.  cursor.execute(sql, params)

Local Vars:
VariableValue
cursor

params
('btqx7y1ekdfpyt7toohi3jurcwo8lb1v', 
'e30:1mV3Q9:Meq3jN8qntWcl1QwRVnq7OVWT_jWP-MkHzsXJD3B5ks', '2021-10-12 
03:04:41.149250')
returning_fields
[]
self

sql
('INSERT INTO "django_session" ("session_key", "session_data", 
"expire_date") ' 'SELECT %s, %s, %s')

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/674d11f9-b9ff-4b1f-9ab2-783c27d351e5n%40googlegroups.com.