Skip to content

Commit 777a28b

Browse files
taeoldSalakar
andauthored
Update readme (#84)
Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com>
1 parent bbf183c commit 777a28b

File tree

2 files changed

+126
-3
lines changed

2 files changed

+126
-3
lines changed

.github/CONTRIBUTING.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# How to contribute
2+
3+
We'd love to accept your patches and contributions to this project. There are
4+
just a few small guidelines you need to follow.
5+
6+
## Contributor License Agreement
7+
8+
Contributions to this project must be accompanied by a Contributor License
9+
Agreement. You (or your employer) retain the copyright to your contribution,
10+
this simply gives us permission to use and redistribute your contributions as
11+
part of the project. Head over to <https://cla.developers.google.com/> to see
12+
your current agreements on file or to sign a new one.
13+
14+
You generally only need to submit a CLA once, so if you've already submitted one
15+
(even if it was for a different project), you probably don't need to do it
16+
again.
17+
18+
## Code reviews
19+
20+
All submissions, including submissions by project members, require review. We
21+
use GitHub pull requests for this purpose. Consult [GitHub Help] for more
22+
information on using pull requests.
23+
24+
## Setup local environment
25+
26+
Clone the project and run the following commands to setup your environment
27+
28+
```sh
29+
python3.11 -m venv venv
30+
source venv/bin/activate
31+
pip3 install --upgrade pip
32+
python3.11 -m pip install -e ".[dev]"
33+
```
34+
35+
(this also applies to setting up samples environment for each sample)
36+
37+
### Running tests
38+
39+
Without coverage:
40+
```bash
41+
python3.11 -m pytest
42+
```
43+
44+
With coverage:
45+
```bash
46+
python3.11 -m pytest --cov=src --cov-report term --cov-report html --cov-report xml -vv
47+
```
48+
49+
### Formatting code
50+
51+
```bash
52+
yapf -i -r -p .
53+
```
54+
55+
### Running lints & type checking
56+
57+
```bash
58+
# Type checking
59+
python3.11 -m mypy .
60+
# Linting
61+
python3.11 -m pylint $(git ls-files '*.py')
62+
```
63+
64+
### Generating Docs
65+
66+
Prerequisites:
67+
- On OSX, install getopt:
68+
- `brew install gnu-getopt`
69+
70+
```sh
71+
./docs/generate.sh --out=./docs/build/ --pypath=src/
72+
```
73+
74+
### Deploying a sample for testing
75+
76+
Example:
77+
78+
```sh
79+
cd samples/basic_https
80+
firebase deploy --only=functions
81+
```
82+
83+
Note to test your local changes of `firebase-functions` when deploying you should push your changes to a branch on GitHub and then locally in the `sample/*/requirements.txt` change `firebase-functions` dependency line to instead come from git, e.g. :
84+
85+
```
86+
git+https://github.com/YOUR_USERNAME/firebase-functions-python.git@YOURBRANCH#egg=firebase-functions
87+
```
88+
89+
[github help]: https://help.github.com/articles/about-pull-requests/

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
1-
# Firebase Functions Python SDK
1+
# Cloud Functions for Firebase Python SDK (Public Preview)
22

3-
Welcome GitHub lurker! This repository is a work in progress. It will eventually let users create Cloud Functions for Firebase in Python. This feature is under very early development and not ready for testing. When it is ready, you can get first access by signing up for the [Firebase Alpha Program](https://services.google.cn/fb/forms/firebasealphaprogram/).
3+
The [`firebase-functions`](https://pypi.org/project/firebase-functions/) package provides an SDK for defining Cloud Functions for Firebase in Python.
44

5-
While you wait for us to get this feature ready for the public, we'd really appreciate you not blowing this up. Let's keep things on the down low for now. 🤫
5+
Cloud Functions provides hosted, private, and scalable environment where you can run server code. The Firebase SDK for Cloud Functions integrates the Firebase platform by letting you write code that responds to events and invokes functionality exposed by other Firebase features.
6+
7+
## Learn more
8+
9+
Learn more about the Firebase SDK for Cloud Functions in the [Firebase documentation](https://firebase.google.com/docs/functions/) or [check out our samples](https://github.com/firebase/functions-samples).
10+
11+
Here are some resources to get help:
12+
13+
- Start with the quickstart: https://firebase.google.com/docs/functions/get-started
14+
- Go through the guide: https://firebase.google.com/docs/functions/
15+
- Read the full API reference: https://firebase.google.com/docs/reference/functions/2nd-gen/python
16+
- Browse some examples: https://github.com/firebase/functions-samples
17+
18+
If the official documentation doesn't help, try asking through our official support channels: https://firebase.google.com/support/
19+
20+
## Usage
21+
22+
```python
23+
# functions/main.py
24+
from firebase_functions import db_fn
25+
from notify_users import api
26+
27+
@db_fn.on_value_created(reference="/posts/{post_id}")
28+
def new_post(event):
29+
print(f"Received new post with ID: {event.params.get('post_id')}")
30+
return notifyUsers(event.data)
31+
```
32+
33+
## Contributing
34+
35+
To contribute a change, [check out the contributing guide](.github/CONTRIBUTING.md).
36+
37+
## License
38+
39+
© Google, 2023. Licensed under [Apache License](LICENSE).

0 commit comments

Comments
 (0)