Skip to content

Commit fad00bb

Browse files
committed
README & gcloudignore tweaks, minor memory usage fix in Mod9
1 parent 341e58c commit fad00bb

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -246,24 +246,23 @@ If your original app users does *not* have a user interface, i.e., mobile backen
246246
- This repo, along with corresponding codelabs & videos are complementary to the official docs & code samples.
247247
- The [official Python 2 to 3 migration documentation](https://cloud.google.com/appengine/docs/standard/python/migrate-to-python3)
248248
- [Canonical migration code samples repo](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/migration)
249-
- Example: [GAE `ndb` to Cloud NDB](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/migration/ndb/overview)
250-
- Example: [GAE `taskqueue` to Cloud Tasks](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/migration/taskqueue)
249+
- *Example:* [GAE `ndb` to Cloud NDB](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/migration/ndb/overview) (similar to Module 2)
250+
- *Example:* [GAE `taskqueue` to Cloud Tasks](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/migration/taskqueue) (similar to Module 8)
251251

252252

253253
## References
254254

255255
- App Engine Migration
256256
- [Migrate from Python 2 to 3](http://cloud.google.com/appengine/docs/standard/python/migrate-to-python3)
257257
- [Migrate from App Engine `ndb` to Cloud NDB](http://cloud.google.com/appengine/docs/standard/python/migrate-to-python3/migrate-to-cloud-ndb) (Module 2)
258-
- [App Engine `ndb` to Cloud NDB official sample app](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/migration/ndb/overview) (Module 2)
259258
- [Migrate from App Engine `taskqueue` to Cloud Tasks](http://cloud.google.com/appengine/docs/standard/python/migrate-to-python3/migrate-to-cloud-ndb) (Modules 7-9)
260-
- [App Engine `app.yaml` to Cloud Run `service.yaml` tool](http://googlecloudplatform.github.io/app-engine-cloud-run-converter) (Modules 4 and 5)
261259
- [Migrate from App Engine `db` to `ndb`](http://cloud.google.com/appengine/docs/standard/python/ndb/db_to_ndb) ("Module -1"; only for reviving "dead" Python 2.5 apps for 2.7)
262260
- [Community contributed migration samples](https://github.com/GoogleCloudPlatform/appengine-python2-3-migration)
263261

264262
- Python App Engine
265-
- [Python 2 App Engine (Standard)](https://cloud.google.com/appengine/docs/standard/python/runtime)
266-
- [Python 3 App Engine (Standard)](https://cloud.google.com/appengine/docs/standard/python3/runtime)
263+
- [App Engine 1st vs. 2nd generation runtimes](https://cloud.google.com/appengine/docs/standard/runtimes)
264+
- [Python 2 App Engine (Standard) runtime](https://cloud.google.com/appengine/docs/standard/python/runtime)
265+
- [Python 3 App Engine (Standard) runtime](https://cloud.google.com/appengine/docs/standard/python3/runtime)
267266
- [Python App Engine (Flexible)](https://cloud.google.com/appengine/docs/flexible/python)
268267

269268
- Google Cloud Platform (GCP)

mod0-baseline/.gcloudignore

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
.gcloudignore
1010

1111
# Ignore source code control maintenance files
12-
.git
12+
.git/
1313
.gitignore
1414
.hgignore
1515
.hg/
1616

1717
# Python files
18-
*.pyc
19-
*.pyo
18+
*.py[cod]
2019
__pycache__/
2120
/setup.cfg
2221

mod9-py3fstasks/main.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def store_visit(remote_addr, user_agent):
3737
'visitor': '{}: {}'.format(remote_addr, user_agent),
3838
})
3939

40-
def create_queue_if():
40+
def _create_queue_if():
4141
'app-internal function creating default queue if it does not exist'
4242
try:
4343
ts_client.get_queue(name=QUEUE_PATH)
@@ -64,7 +64,7 @@ def fetch_visits(limit):
6464
},
6565
}
6666
}
67-
if create_queue_if():
67+
if _create_queue_if():
6868
ts_client.create_task(parent=QUEUE_PATH, task=task)
6969
return visits, oldest_str
7070

@@ -79,12 +79,11 @@ def trim():
7979
'(push) task queue handler to delete oldest visits'
8080
oldest = float(request.get_json().get('oldest'))
8181
query = fs_client.collection('Visit')
82-
visits = list(query.where('timestamp', '<',
83-
datetime.fromtimestamp(oldest)).stream())
84-
nvisits = len(visits)
85-
if nvisits:
86-
print('Deleting %d entities: ' % nvisits, end='')
87-
print(', '.join(str(v_id) for v_id in _delete_docs(visits)))
82+
visits = query.where('timestamp', '<',
83+
datetime.fromtimestamp(oldest)).stream()
84+
dlist = ', '.join(str(v_id) for v_id in _delete_docs(visits))
85+
if dlist:
86+
print('Deleting %d entities: %s' % (dlist.count(',')+1, dlist))
8887
else:
8988
print('No entities older than: %s' % time.ctime(oldest))
9089
return '' # need to return SOME string w/200

0 commit comments

Comments
 (0)