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

Commit 68b399c

Browse files
committed
add CODEOWNERS & GCF code, revise pkg version#s, update README
1 parent ae466d6 commit 68b399c

File tree

25 files changed

+149
-56
lines changed

25 files changed

+149
-56
lines changed

.github/CODEOWNERS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Code owners file.
2+
# This file controls who is tagged for review for any given pull request.
3+
#
4+
# For syntax help see:
5+
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
6+
7+
# The python-samples-owners team is the default owner for anything not
8+
# explicitly taken by someone else.
9+
* @wescpy @GoogleCloudPlatform/python-samples-owners

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Each codelab begins with a "START" code base then walks developers through that
2121

2222
## Cost
2323

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#always-free), 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.
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.
2525

2626

2727
## Why
@@ -68,10 +68,12 @@ Module | Topic | Codelab | START folder | FINISH folder
6868
3|Migrate to Cloud Datastore| [link](http://g.co/codelabs/pae-migrate-datastore) | Module 2 [code](/mod2a-cloudndb) (2.x) & [code](/mod2b-cloudndb) (3.x) | Module 3 [code](/mod3a-datastore) (2.x) & [code](/mod3b-datastore) (3.x)
6969
4|Migrate to Cloud Run with Docker| [link](http://g.co/codelabs/pae-migrate-rundocker) | Module 2 [code](/mod2a-cloudndb) (2.x) & Module 3 [code](/mod3b-datastore) (3.x) | Module 4 [code](/mod4a-rundocker) (2.x) & [code](/mod4b-rundocker) (3.x)
7070
5|Migrate to Cloud Run with Buildpacks| [link](http://g.co/codelabs/pae-migrate-runbldpks) | Module 2 [code](/mod2b-cloudndb) (3.x) | Module 5 [code](/mod5-runbldpks) (3.x)
71-
6|Migrate to Cloud Firestore| [link](http://g.co/codelabs/pae-migrate-firestore) | Module 3 [code]() (3.x) | Module 6 [code](/mod6-firestore) (3.x)
71+
6|Migrate to Cloud Firestore (app)| [link](http://g.co/codelabs/pae-migrate-firestore) | Module 3 [code](/mod3b-datastore) (3.x) | Module 6 [code](/mod6-firestore) (3.x)
7272
7|Add App Engine push tasks| [link](http://g.co/codelabs/pae-migrate-gaetasks) | Module 1 [code]() (2.x) | Module 7 [code](/mod7-gaetasks) (2.x)
7373
8|Migrate to Cloud Tasks| [link](http://g.co/codelabs/pae-migrate-cloudtasks) | Module 7 [code](/mod7-gaetasks) (2.x) | Module 8 [code](/mod8-cloudtasks) (2.x)
7474
9|Migrate to Python 3 (Cloud Datastore & Cloud Tasks v2)| [link](http://g.co/codelabs/pae-migrate-py3dstasks) | Module 8 [code](/mod8-cloudtasks) (2.x) | Module 9 [code](/mod9-py3dstasks) (3.x)
75+
10|Migrate to Cloud Firestore (data)| _N/A_ | _N/A_ | _TBD_
76+
11|Migrate to Cloud Functions| _TBD_ | Module 2 [code](/mod2b-cloudndb) (3.x) | Module 11 [code](/mod11-functions) (3.x)
7577

7678

7779
### Table of contents
@@ -99,6 +101,7 @@ If there is a logical codelab to do immediately after completing one, they will
99101
- RECOMMENDED:
100102
- Module 7 - add App Engine (push) tasks
101103
- OTHERS (somewhat priority order):
104+
- Module 11 - migrate to Cloud Functions
102105
- Module 5 - migrate to Cloud Run container with Cloud Buildpacks
103106
- Module 4 - migrate to Cloud Run container with Docker
104107
- Module 3 - migrate to Cloud Datastore
@@ -129,6 +132,7 @@ If there is a logical codelab to do immediately after completing one, they will
129132
- Python 3
130133
- FINISH: [Module 9 code - Cloud Datastore & Tasks](/mod9-py3dstasks) (3.x)
131134
- RECOMMENDED:
135+
- Module 11 - migrate to Cloud Functions
132136
- Module 5 - migrate to Cloud Run container with Cloud Buildpacks
133137
- Module 4 - migrate to Cloud Run container with Docker
134138
- Module 6 - migrate to Cloud Firestore
@@ -146,6 +150,7 @@ If there is a logical codelab to do immediately after completing one, they will
146150
- Module 5 - migrate to Cloud Run container with Cloud Buildpacks
147151
- OTHER OPTIONS (in somewhat priority order):
148152
- Module 7 - add App Engine (push) tasks
153+
- Module 11 - migrate to Cloud Functions
149154

150155
- [Module 5 codelab](http://g.co/codelabs/pae-migrate-runbldpks): **Migrate from App Engine to [Cloud Run](http://cloud.google.com/run) with Cloud Buildpacks**
151156
- **Optional** migration
@@ -158,6 +163,7 @@ If there is a logical codelab to do immediately after completing one, they will
158163
- Module 4 - migrate to Cloud Run container with Docker
159164
- OTHER OPTIONS (in somewhat priority order):
160165
- Module 7 - add App Engine (push) tasks
166+
- Module 11 - migrate to Cloud Functions
161167

162168
- [Module 3 codelab](http://g.co/codelabs/pae-migrate-datastore): **Migrate from Cloud NDB to Cloud Datastore**
163169
- **Optional** migration
@@ -172,7 +178,9 @@ If there is a logical codelab to do immediately after completing one, they will
172178
- RECOMMENDED:
173179
- Module 7 - add App Engine (push) tasks
174180
- OTHER OPTIONS (in somewhat priority order):
181+
- Module 11 - migrate to Cloud Functions
175182
- Module 5 - migrate to Cloud Run container with Cloud Buildpacks
183+
- Module 4 - migrate to Cloud Run container with Docker
176184
- Module 6 - migrate to Cloud Firestore
177185

178186
- [Module 6 codelab](http://g.co/codelabs/pae-migrate-firestore): **Migrate from Cloud Datastore to [Cloud Firestore](http://cloud.google.com/firestore)**
@@ -185,7 +193,9 @@ If there is a logical codelab to do immediately after completing one, they will
185193
- RECOMMENDED:
186194
- Module 7 - add App Engine (push) tasks
187195
- OTHER OPTIONS (in somewhat priority order):
196+
- Module 11 - migrate to Cloud Functions
188197
- Module 5 - migrate to Cloud Run container with Cloud Buildpacks
198+
- Module 4 - migrate to Cloud Run container with Docker
189199

190200

191201
## Considerations for mobile developers
@@ -211,11 +221,11 @@ If your original app users does *not* have a user interface, i.e., mobile backen
211221

212222
- App Engine Migration
213223
- [Migrate from Python 2 to 3](http://cloud.google.com/appengine/docs/standard/python/migrate-to-python3)
214-
- [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)
215-
- [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)
216-
- [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)
217-
- [App Engine `app.yaml` to Cloud Run `service.yaml` tool](http://googlecloudplatform.github.io/app-engine-cloud-run-converter) (Step 4a)
218-
- [Migrate from App Engine `db` to `ndb`](http://cloud.google.com/appengine/docs/standard/python/ndb/db_to_ndb) ("Step -1"; only for reviving "dead" Python 2.5 apps for 2.7)
224+
- [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)
225+
- [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)
226+
- [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)
227+
- [App Engine `app.yaml` to Cloud Run `service.yaml` tool](http://googlecloudplatform.github.io/app-engine-cloud-run-converter) (Modules 4 and 5)
228+
- [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)
219229
- [Community contributed migration samples](https://github.com/GoogleCloudPlatform/appengine-python2-3-migration)
220230

221231
- Python App Engine

mod1-flask/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Flask==1.1.2
1+
flask==1.1.2

mod11-functions/.gcloudignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file specifies files that are *not* uploaded to Google Cloud Platform
2+
# using gcloud. It follows the same syntax as .gitignore, with the addition of
3+
# "#!include" directives (which insert the entries of the given .gitignore-style
4+
# file at that point).
5+
#
6+
# For more information, run:
7+
# $ gcloud topic gcloudignore
8+
#
9+
.gcloudignore
10+
11+
# Ignore source code control maintenance files
12+
.git
13+
.gitignore
14+
.hgignore
15+
.hg/
16+
17+
# Python files
18+
*.pyc
19+
*.pyo
20+
__pycache__/
21+
/setup.cfg
22+
23+
# no need to upload README
24+
README.md

mod11-functions/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Module 11 - Migrate from Google App Engine to Cloud Functions
2+
3+
This repo folder is the corresponding code to the [Module 11 codelab](http://g.co/codelabs/pae-migrate-functions). The tutorial STARTs with the Python 3 code in the [Module 2 repo Python3 folder](/mod2b-cloudndb) and leads developers through migrating away from App Engine to Cloud Functions, culminating in the code in this folder.

mod11-functions/main.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from flask import render_template
16+
from google.cloud import ndb
17+
18+
ds_client = ndb.Client()
19+
20+
class Visit(ndb.Model):
21+
'Visit entity registers visitor IP address & timestamp'
22+
visitor = ndb.StringProperty()
23+
timestamp = ndb.DateTimeProperty(auto_now_add=True)
24+
25+
def store_visit(remote_addr, user_agent):
26+
'create new Visit entity in Datastore'
27+
with ds_client.context():
28+
Visit(visitor='{}: {}'.format(remote_addr, user_agent)).put()
29+
30+
def fetch_visits(limit):
31+
'get most recent visits'
32+
with ds_client.context():
33+
return (v.to_dict() for v in Visit.query().order(
34+
-Visit.timestamp).fetch(limit))
35+
36+
def visitme(request):
37+
'main application (GET) handler'
38+
store_visit(request.remote_addr, request.user_agent)
39+
visits = fetch_visits(10)
40+
return render_template('index.html', visits=visits)

mod11-functions/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
flask==1.1.2
2+
google-cloud-ndb==1.8.0
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>VisitMe Example</title>
5+
<body>
6+
7+
<h1>VisitMe example</h1>
8+
<h3>Last 10 visits</h3>
9+
<ul>
10+
{% for visit in visits %}
11+
<li>{{ visit.timestamp.ctime() }} from {{ visit.visitor }}</li>
12+
{% endfor %}
13+
</ul>
14+
15+
</body>
16+
</html>

mod2a-cloudndb/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Flask==1.1.2
2-
google-cloud-ndb==1.7.1
1+
flask==1.1.2
2+
google-cloud-ndb==1.8.0

mod2b-cloudndb/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Flask==1.1.2
2-
google-cloud-ndb==1.7.1
1+
flask==1.1.2
2+
google-cloud-ndb==1.8.0

0 commit comments

Comments
 (0)