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

Commit 093ab91

Browse files
committed
README update, Mod9 2.x backport, Mod12 naming convention
1 parent 234b878 commit 093ab91

File tree

9 files changed

+29
-6
lines changed

9 files changed

+29
-6
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# Python App Engine app migration
2-
### To modern runtime, Cloud services, Python 3, and Cloud Run containers
1+
# Modernizing Google Cloud serverless compute applications
2+
### To newer Cloud services and other serverless platforms
3+
4+
This is the corresponding repository to the [Serverless Migration Station](https://bit.ly/3xk2Swi) video series whose goal is to help users on a Google Cloud serverless compute platform modernize to newer Cloud products or other serverless compute platforms. Each modernization migration aims to feature a video, codelab (self-paced, hands-on tutorial), and code samples. The content initially focuses on App Engine, the earliest Google Cloud users.
35

46
[Google App Engine](https://cloud.google.com/appengine) (Standard) has undergone significant changes between the legacy and next generation platforms. To address this, we've created a set of codelabs (free, online, self-paced, hands-on tutorials) and corresponding videos (when available) to show developers how to perform individual migrations they can apply to modernize their apps for the latest runtimes, with this repo managing the samples from those codelabs.
57

@@ -21,9 +23,9 @@ Each codelab begins with a "START" code base then walks developers through that
2123

2224
## Cost
2325

24-
App Engine is not a free service. While you may not have needed to enable billing in App Engine's early days, [all applications now require an active billing account](https://cloud.google.com/appengine/docs/standard/payment-instrument) backed by a financial instrument (usually a credit card). Don't worry, App Engine (and other GCP products) still have an ["Always Free" tier](https://cloud.google.com/free/docs/gcp-free-tier#free-tier-usage-limits) and as long as you stay within those limits, you won't incur any charges. Also check the App Engine [pricing](https://cloud.google.com/appengine/pricing) and [quotas](https://cloud.google.com/appengine/quotas) pages for more information.
26+
App Engine, Cloud Functions, and Cloud Run are not free services. While you may not have needed to enable billing in App Engine's early days, [all applications now require an active billing account](https://cloud.google.com/appengine/docs/standard/payment-instrument) backed by a financial instrument (usually a credit card). Don't worry, App Engine (and other GCP products) still have an ["Always Free" tier](https://cloud.google.com/free/docs/gcp-free-tier#free-tier-usage-limits) and as long as you stay within those limits, you won't incur any charges. Also check the App Engine [pricing](https://cloud.google.com/appengine/pricing) and [quotas](https://cloud.google.com/appengine/quotas) pages for more information.
2527

26-
Furthermore, deploying to GCP serverless platforms incur [minor build and storage costs](https://cloud.google.com/appengine/pricing#pricing-for-related-google-cloud-products). [Cloud Build](https://cloud.google.com/build/pricing) has its own free quota as does [Cloud Storage](https://cloud.google.com/storage/pricing#cloud-storage-always-free). For greater transparency, Cloud Build builds your application image which is than sent to the [Cloud Container Registry](https://cloud.google.com/container-registry/pricing); storage of that image uses up some of that (Cloud Storage) quota as does network egress when transferring that image to the service you're deploying to. However you may live in region that does not have such a free tier, so be aware of your storage usage to minimize potential costs. (You may look at what storage you're using and how much, including deleting build artifacts via [your Cloud Storage browser](https://console.cloud.google.com/storage/browser).)
28+
Furthermore, deploying to GCP serverless platforms incur [minor build and storage costs](https://cloud.google.com/appengine/pricing#pricing-for-related-google-cloud-products). [Cloud Build](https://cloud.google.com/build/pricing) has its own free quota as does [Cloud Storage](https://cloud.google.com/storage/pricing#cloud-storage-always-free). For greater transparency, Cloud Build builds your application image which is than sent to the [Cloud Container Registry](https://cloud.google.com/container-registry/pricing) or [Artifact Registry](https://cloud.google.com/artifact-registry/pricing), its successor; storage of that image uses up some of that (Cloud Storage) quota as does network egress when transferring that image to the service you're deploying to. However you may live in region that does not have such a free tier, so be aware of your storage usage to minimize potential costs. (You may look at what storage you're using and how much, including deleting build artifacts via [your Cloud Storage browser](https://console.cloud.google.com/storage/browser).)
2729

2830

2931
## Why
@@ -83,7 +85,7 @@ Module | Topic | Video | Codelab | START here | FINISH here
8385
9|Migrate to Python 3, Cloud Firestore & Cloud Tasks v2| _TBD_ | _TBD_ | Module 8 [code](/mod8-cloudtasks) (2.x) | Module 9 [code](/mod9-py3fstasks) (3.x)
8486
10|Migrate to Cloud Firestore (data)| _TBD_ | _N/A_ | _N/A_ | _TBD_
8587
11|Migrate to Cloud Functions| _TBD_ | _TBD_ | Module 2 [code](/mod2b-cloudndb) (3.x) | Module 11 [code](/mod11-functions) (3.x)
86-
12|Add App Engine `memcache`| _TBD_ | _TBD_ | Module 1 [code](/mod1-flask) (2.x) | Module 12 [code](/mod12a-memcache) (2.x) & [code](/mod12b-memcache) (3.x)
88+
12|Add App Engine `memcache`| _TBD_ | _TBD_ | Module 1 [code](/mod1-flask) (2.x) | Module 12 [code](/mod12-memcache) (2.x) & [code](/mod12b-memcache) (3.x)
8789

8890

8991
### Table of contents
File renamed without changes.

mod9-py3fstasks/README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This repo folder is the corresponding Python 3 code to the [Module 9 codelab](http://g.co/codelabs/pae-migrate-py3fstasks). The tutorial STARTs with the Python 2 code in the [Module 8 repo folder](/mod7-cloudtasks) and leads developers through migrating from Python 2 to 3, Cloud NDB to Cloud Firestore (skipping over a Cloud Datstore migration) plus any changes from Cloud Tasks v1 to v2, culminating in the code in this folder. One major addition to look for here vs. Module 8 is that App Engine `taskqueue` creates a `default` push queue while Cloud Tasks does not, so that now has to be done in code.
44

5-
NOTE: The deletion process in this app is "one-at-a-time." If your app requires deletion of more than a few documents, consider switching to the batch model. In this case, you would replace `_delete_docs()` with:
5+
**NOTE: Batch delete**: The deletion process in this app is "one-at-a-time." If your app requires deletion of more than a few documents, consider switching to the batch model. In this case, you would replace `_delete_docs()` with:
66

77
def _delete_docs(visits):
88
'app-internal generator deleting old FS visit documents'
@@ -11,3 +11,24 @@ NOTE: The deletion process in this app is "one-at-a-time." If your app requires
1111
batch.delete(visit.reference)
1212
yield visit.id
1313
batch.commit()
14+
15+
**NOTE: Backport to Python 2**: When migrating this app to Python 3, we added a Python 3 dependency: the `print()` function. If for any reason you need to get back on Python 2 App Engine, you would have to:
16+
17+
1. Decide on your logging strategy. The Python 2 App Engine runtime now allows writing to `stdout`, so you don't have to revert back to `logging.info()` (or preferred logging level), however writing to `stdout` defaults to `logging.error()`. If that is acceptable and to continue with `print()`, add a `__future__.print_function` import above the others so the top of `main.py` looks like this:
18+
19+
from __future__ import print_function
20+
from datetime import datetime
21+
import json
22+
import time
23+
from flask import Flask, render_template, request
24+
import google.auth
25+
from google.cloud import firestore, tasks
26+
27+
2. Revert back to your Python 2 configuration files. For this app, it would be Module 8's [`app.yaml`](https://github.com/googlecodelabs/migrate-python2-appengine/blob/master/mod8-cloudtasks/app.yaml) and [`appengine_config.py`](https://github.com/googlecodelabs/migrate-python2-appengine/blob/master/mod8-cloudtasks/appengine_config.py) files.
28+
29+
3. Revert all package versions from `requirements.txt` to get the latest/last(?) package versions for Python 2 as well as run `pip install -t lib -r requirements.txt` again. Here is what ours looks like:
30+
31+
flask==1.1.2
32+
google-cloud-firestore==1.9.0
33+
google-cloud-tasks==1.5.0
34+

0 commit comments

Comments
 (0)