Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Commit e24d97c

Browse files
committed
README fixes and minor code cleanup
1 parent d2421fb commit e24d97c

File tree

7 files changed

+120
-74
lines changed

7 files changed

+120
-74
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
[Google App Engine](https://cloud.google.com/appengine) (standard) has undergone a number of product upgrades over the past few years, leaving some early adopters unable to easily move off the original platform. This repo supports various migration codelabs (free, self-paced, hands-on tutorials) aim to give developers hands-on experience and develop muscle memory in doing individual migrations so they can modernize their applications. This is done via a sample application meant to model basic elements found in existing first-generation apps and applying individual migration steps to each.
55

6+
67
## Prerequisites
78

89
- A Google account (G Suite accounts may require administrator approval)
@@ -13,20 +14,24 @@
1314

1415
The intended audiences of this tutorial and corresponding video content are Software Engineers, Information Technology decision-makers (ITDMs) as well as other technical practitioners tasked with investigating and/or carrying out such migrations.
1516

17+
1618
## Cost
1719

1820
Use of GCP products & APIs is not free. While you may not have needed to enable billing with early App Engine applications, all applications now require an active billing account. App Engine's [pricing](https://cloud.google.com/appengine/pricing) and [quota](https://cloud.google.com/appengine/quotas) information should be referenced. App Engine and other GCP products have an ["Always Free" tier](https://cloud.google.com/free/docs/gcp-free-tier#always-free). Users only incur billing when these daily/monthly quotas are exceeded. The migration exercises in these tutorials should not incur any billing so long as you stay within the limits described above.
1921

22+
2023
## Support for Python 2 & 3
2124

2225
It's important to note that for App Engine (Standard), Python 2 is only supported as a 1st generation ("Gen1") runtime whereas Python 3 is only supported by the 2nd generation ("Gen2") runtime. This means that porting application from Python 2 to 3 also means migrating from Gen1 to Gen2 where things are different. (Python 2 belongs in the same class as Java 6-8, PHP 5, and Go 1.8-1.11 first-gen apps.) See the exact differences on the [App Engine runtime documentation page](https://cloud.google.com/appengine/docs/standard/runtimes). One key change: bundled App Engine built-in services are absent from Gen2 (they have either matured to become standalone products or have been deprecated). The other key change: you must use web frameworks that do their own routing.
2326

2427
> **NOTE:** App Engine ([Flexible](https://cloud.google.com/appengine/docs/flexible/python/runtime?hl=en#interpreter)) is a Gen2 service but is not within the scope of these tutorials. Developers who are curious can compare App Engine [Standard vs. Flexible](https://cloud.google.com/appengine/docs/the-appengine-environments).
2528
29+
2630
## Description
2731

2832
Each folder represents a single migration step, and the plan is to have a corresponding code repo and developer video as well. It all starts with a basic Gen1 Python 2.7 app then makes the minimum "required" migrations away from built-in App Engine services such as `webapp2` micro web framework and the `ndb` Datastore library. These comprise the [Step 0](/step0-webapp2-gaendb-py2) 2.7 app.
2933

34+
3035
## Table of Contents
3136

3237
Each major migration step has its own codelab & corresponding overview video. The step numbers correspond to their own folders, and generally each have folders for Python 2 & 3 ports. Some have an alternative or secondary succeeding migration—these end with "a", i.e., "Step 3a".
@@ -52,9 +57,14 @@ Each major migration step has its own codelab & corresponding overview video. Th
5257
- "Containerize" your app (migrate your app to a container) with...
5358
- [Docker](http://docker.com) ([2.x w/Cloud NDB](/step4-cloudndb-cloudrun-py2) or [3.x w/Cloud Datastore](/step4-cloudds-cloudrun-py3))
5459
- Cloud Buildpacks ([Step 4a](/step4-cloudrun-bldpks-py3)) ; 3.x-only w/Cloud Datastore)
60+
1. **Migrate from App Engine (Push) Tasks to [Cloud Tasks](http://cloud.google.com/tasks)**
61+
- (5a) Add App Engine (Push) Tasks (`taskqueue`) to `webapp2` & `ndb` Flask 2.x app (from Step 1)
62+
- (5b) Migrate App Engine `ndb` & `taskqueue` app to Cloud NDB & Cloud Tasks *v1* (2.x)
63+
- (5c) Migrate Cloud NDB & Cloud Tasks v1 app to Cloud *Datastore* & Cloud Tasks *v2* (3.x)
5564

5665
Think of it as a train ride where the first pair of stops are required, then the passengers can "get off" at any upcoming station or continue their onward journey.
5766

67+
5868
### Considerations for mobile developers
5969
If your original app users does *not* have a user interface, i.e., mobile backends, etc., but still uses `webapp2` for routing, some migration must still be completed. Your options:
6070
- Migrate to Flask (or another) web framework but keep app on App Engine
@@ -66,6 +76,7 @@ If your original app users does *not* have a user interface, i.e., mobile backen
6676
> **NOTE:**
6777
Long-time users wishing to bring back apps on the inaugural Python 2.5 runtime, [deprecated in 2013](http://googleappengine.blogspot.com/2013/03/python-25-thanks-for-good-times.html) and [shutdown in 2017](https://cloud.google.com/appengine/docs/standard/python/python25), must [migrate from `db` to `ndb`](http://cloud.google.com/appengine/docs/standard/python/ndb/db_to_ndb) (and 2.5 to 2.7) before attempting these migrations.
6878

79+
6980
## Summary
7081

7182
The table below summarizes each migration step and which options are available for developers after each step. Each step has a corresponding directory representing the state of the sample app after the previous migration step. The first step ("step0") represents the initial Python 2.7 App Engine app built using `ndb` and `webapp2`.
@@ -79,6 +90,10 @@ Python 2 | Next | Python 3 | Description
7990
_N/A_ | _N/A_ | º[`step3a-flask-firestore-py3`](/step3a-flask-firestore-py3) | Migrate to Cloud Firestore (uncommon; see above)
8091
[ª`step4-cloudndb-cloudrun-py2`](/step4-cloudndb-cloudrun-py2) | → | [`step4-cloudds-cloudrun-py3`](/step4-cloudds-cloudrun-py3) | Migrate to Cloud Run (with Docker)
8192
_N/A_ | _N/A_ | +[`step4a-cloudrun-bldpks-py3`](/step4a-cloudrun-bldpks-py3) | Migrate to Cloud Run (with Cloud Buildpacks)
93+
[`step5a-gae-ndb-tasks-py2`](/step5a-gae-ndb-tasks-py2) | ↓ | _N/A_ | Updated Flask sample using GAE `ndb` & `taskqueue`
94+
[`step5b-cloud-ndb-tasks-py2`](/step5b-cloud-ndb-tasks-py2) | ↓ | _N/A_ | Migrate to Cloud Datastore & Cloud Tasks
95+
_N/A_ | _N/A_ | [`step5c-cloud-datastore-tasks-py3`](/step5c-cloud-datastore-tasks-py3) | Migrate to Cloud Datastore & Cloud Tasks
96+
8297

8398
### Canonical code samples
8499

@@ -87,17 +102,20 @@ _N/A_ | _N/A_ | +[`step4a-cloudrun-bldpks-py3`](/step4a-cloudrun-bldpks-py3) | M
87102
- [Canonical migration code samples repo](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/migration)
88103
- Example: [GAE NDB to Cloud NDB](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/migration/ndb/overview)
89104

105+
90106
## Next
91107

92108
- [**Step 0:**](/step0-webapp2-gaendb-py2) Take a look at the original Python 2.7 App Engine NDB Datastore `webapp2` app source code.
93109
- [**Step 1:**](/step1-flask-gaendb-py2) Take the first tutorial and migrate away from `webapp2` to Flask.
94110

111+
95112
## References
96113

97114
- App Engine Migration
98115
- [Migrate from GAE Gen1 to Gen2 (Python 2 to 3)](http://cloud.google.com/appengine/docs/standard/python/migrate-to-python3)
99-
- [Migrate from App Engine NDB to Cloud NDB](http://cloud.google.com/appengine/docs/standard/python/migrate-to-python3/migrate-to-cloud-ndb) (Step 2)
100-
- [App Engine NDB to Cloud NDB official sample app](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/migration/ndb/overview) (Step 2)
116+
- [Migrate from App Engine `ndb` to Cloud NDB](http://cloud.google.com/appengine/docs/standard/python/migrate-to-python3/migrate-to-cloud-ndb) (Step 2)
117+
- [App Engine `ndb` to Cloud NDB official sample app](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/migration/ndb/overview) (Step 2)
118+
- [Migrate from App Engine `taskqueue` to Cloud Tasks](http://cloud.google.com/appengine/docs/standard/python/migrate-to-python3/migrate-to-cloud-ndb) (Steps 5a-5c)
101119
- [App Engine `app.yaml` to Cloud Run `service.yaml` tool](http://googlecloudplatform.github.io/app-engine-cloud-run-converter) (Step 4a)
102120
- [Migrate from App Engine `db` to `ndb`](http://cloud.google.com/appengine/docs/standard/python/ndb/db_to_ndb) (Step -1 [before Step 0]; only for reviving "dead" Python 2.5 apps)
103121

step5a-gae-ndb-tasks-py2/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This codelab step adds a push task to delete all `Visit`s older than the oldest
1818

1919
---
2020

21-
## Augment sample with new feature
21+
## Augment sample with push tasks
2222

2323
Rather than a migration, this step adds use of push Task Queues to the existing Step 1 app. The only modifications required are for the `main.py` application file and `templates/index.html` web template. The steps:
2424

@@ -51,8 +51,8 @@ Following that recommendation, your imports should look like this when done:
5151
- AFTER:
5252

5353
```python
54-
import logging
5554
from datetime import datetime
55+
import logging
5656
import time
5757
from flask import Flask, render_template, request
5858
from google.appengine.api import taskqueue

step5a-gae-ndb-tasks-py2/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import logging
1615
from datetime import datetime
16+
import logging
1717
import time
1818
from flask import Flask, render_template, request
1919
from google.appengine.api import taskqueue

0 commit comments

Comments
 (0)