You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 1, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff 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.
3
5
4
6
[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.
5
7
@@ -21,9 +23,9 @@ Each codelab begins with a "START" code base then walks developers through that
21
23
22
24
## Cost
23
25
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.
25
27
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).)
27
29
28
30
29
31
## Why
@@ -83,7 +85,7 @@ Module | Topic | Video | Codelab | START here | FINISH here
Copy file name to clipboardExpand all lines: mod9-py3fstasks/README.md
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
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.
4
4
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:
6
6
7
7
def _delete_docs(visits):
8
8
'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
11
11
batch.delete(visit.reference)
12
12
yield visit.id
13
13
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:
0 commit comments