Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
needs: Lint
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]
name: Test Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v3
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can create Rest APIs:
```python
from goblet import Goblet, jsonify, goblet_entrypoint

app = Goblet(function_name="goblet_example")
app = Goblet(function_name="goblet-example")
goblet_entrypoint(app)

@app.route('/home')
Expand All @@ -37,7 +37,7 @@ You can also create other GCP resources that are related to your REST api:
```python
from goblet import Goblet, jsonify, goblet_entrypoint

app = Goblet(function_name="goblet_example")
app = Goblet(function_name="goblet-example")
goblet_entrypoint(app)

# Scheduled job
Expand Down Expand Up @@ -69,13 +69,14 @@ $ curl https://api.uc.gateway.dev/home
{"hello": "world"}
```

> Note: Due to breaking changes in Cloudfunctions you will need to wrap your goblet class in a function. See [issue #88](https://github.com/goblet/goblet/issues/88). In the latest goblet version (0.5.0) there is a helper function `goblet_entrypoint` that can be used as well.
> Note: Due to breaking changes in Cloudfunctions you will need to wrap your goblet class in a function. See [issue #88](https://github.com/goblet/goblet/issues/88). In the latest goblet version (0.5.0) there is a helper function `goblet_entrypoint` that can be used as well.

> `goblet_entrypoint(app)`

## Resources Supported

#### Infrastructure

* vpc connector
* redis
* api gateway
Expand All @@ -84,15 +85,18 @@ $ curl https://api.uc.gateway.dev/home
* bq spark stored procedures

#### Backends

* cloudfunction
* cloudfunction V2
* cloudrun

#### Routing

* api gateway
* http

#### Handlers

* pubsub
* scheduler
* storage
Expand All @@ -103,6 +107,7 @@ $ curl https://api.uc.gateway.dev/home
* uptime checks

#### Alerts

* Backend Alerts
* Uptime Alerts
* PubSub DLQ Alerts
Expand Down Expand Up @@ -173,7 +178,7 @@ Let's take a look at the main.py file:
```python
from goblet import Goblet, goblet_entrypoint

app = Goblet(function_name="goblet_example")
app = Goblet(function_name="goblet-example")
goblet_entrypoint(app)

@app.route('/home')
Expand All @@ -190,7 +195,7 @@ Running your functions locally for testing and debugging is easy to do with gobl
```python
from goblet import Goblet

app = Goblet(function_name="goblet_example")
app = Goblet(function_name="goblet-example")
goblet_entrypoint(app)

@app.route('/home')
Expand Down Expand Up @@ -345,7 +350,6 @@ Please file any issues, bugs or feature requests as an issue on our [GitHub](htt
☑ Automatically add IAM invoker bindings on the backend based on deployed handlers \
☑ [Uptime Checks](https://cloud.google.com/monitoring/uptime-checks)


## Want to Contribute

If you would like to contribute to the library (e.g. by improving the documentation, solving a bug or adding a cool new feature) please follow the [contribution guide](CONTRIBUTING.md) and submit a [pull request](https://github.com/goblet/goblet/pulls).
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ You can create Rest APIs:

from goblet import Goblet

app = Goblet(function_name="goblet_example")
app = Goblet(function_name="goblet-example")

@app.route('/home')
def home():
Expand Down
2 changes: 1 addition & 1 deletion docs/source/local.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can have a custom local name by setting the local param in the goblet class

from goblet import Goblet

app = Goblet(function_name="goblet_example", local='test')
app = Goblet(function_name="goblet-example", local='test')


Then run ``goblet local test``
Expand Down
2 changes: 1 addition & 1 deletion docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Let's take a look at the main.py file:

from goblet import Goblet, goblet_entrypoint

app = Goblet(function_name="goblet_example")
app = Goblet(function_name="goblet-example")
goblet_entrypoint(app)

@app.route('/home')
Expand Down
2 changes: 1 addition & 1 deletion goblet/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (0, 13, 3)
VERSION = (0, 14, 0)


__version__ = ".".join(map(str, VERSION))
10 changes: 6 additions & 4 deletions goblet/alerts/alert_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ def __init__(self, name, filter, **kwargs) -> None:
super().__init__(
name=name,
log_match={
"filter": filter
if kwargs.get("replace_filter", False)
else 'resource.type="{monitoring_type}"\nresource.labels.{monitoring_label_key}="{resource_name}"\n'
+ filter
"filter": (
filter
if kwargs.get("replace_filter", False)
else 'resource.type="{monitoring_type}"\nresource.labels.{monitoring_label_key}="{resource_name}"\n'
+ filter
)
},
)
self.default_alert_kwargs = {
Expand Down
2 changes: 1 addition & 1 deletion goblet/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Goblet(Goblet_Decorators, Resource_Manager):
def __init__(
self,
function_name="goblet",
backend="cloudfunction",
backend="cloudfunctionv2",
local="local",
cors=None,
routes_type="apigateway",
Expand Down
8 changes: 4 additions & 4 deletions goblet/tests/test_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class TestAlerts:
def test_add_alert(self):
app = Goblet(function_name="goblet_example")
app = Goblet(function_name="goblet-example", backend="cloudfunction")

metric_alert = BackendAlert(
"metric",
Expand Down Expand Up @@ -79,7 +79,7 @@ def test_deploy_alerts(self, monkeypatch):

reset_replay_count()

app = Goblet(function_name="alerts-test")
app = Goblet(function_name="alerts-test", backend="cloudfunction")

metric_alert = BackendAlert(
"metric",
Expand Down Expand Up @@ -169,7 +169,7 @@ def test_destroy_alerts(self, monkeypatch):

reset_replay_count()

app = Goblet(function_name="alerts-test")
app = Goblet(function_name="alerts-test", backend="cloudfunction")

metric_alert = BackendAlert(
"metric",
Expand Down Expand Up @@ -210,7 +210,7 @@ def test_sync_alerts(self, monkeypatch):
monkeypatch.setenv("G_TEST_NAME", "alerts-sync")
monkeypatch.setenv("G_HTTP_TEST", "REPLAY")

app = Goblet(function_name="alerts-test")
app = Goblet(function_name="alerts-test", backend="cloudfunction")

custom_alert = BackendAlert(
"custom",
Expand Down
2 changes: 1 addition & 1 deletion goblet/tests/test_apigateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_deploy_api_gateway(self, monkeypatch, requests_mock):
"definitions": {},
}

app = Goblet("goblet_routes")
app = Goblet("goblet_routes", backend="cloudfunction")
app.apigateway("goblet-routes", "URL", openapi_dict=openapi_dict)
app.deploy(force=True, skip_handlers=True, skip_backend=True)

Expand Down
8 changes: 4 additions & 4 deletions goblet/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def start_response_status(status, response_headers, exc_info=None):

class TestDecoraters:
def test_add(self):
app1 = Goblet("test")
app2 = Goblet("test")
app1 = Goblet("test", backend="cloudfunction")
app2 = Goblet("test", backend="cloudfunction")

@app1.route("/home")
@app2.route("/home2")
Expand All @@ -76,8 +76,8 @@ def dummy_function2(self, home_id):
]

def test_add_current_request(self):
app1 = Goblet("test")
app2 = Goblet("test")
app1 = Goblet("test", backend="cloudfunction")
app2 = Goblet("test", backend="cloudfunction")

@app2.route("/app2")
def dummy_function():
Expand Down
14 changes: 7 additions & 7 deletions goblet/tests/test_bqremotefunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class TestBqRemoteFunction:
def test_register_bqremotefunction(self, monkeypatch):
app = Goblet(function_name="bqremotefunction_test")
app = Goblet(function_name="bqremotefunction_test", backend="cloudfunction")
monkeypatch.setenv("GOOGLE_PROJECT", "TEST_PROJECT")
monkeypatch.setenv("GOOGLE_LOCATION", "us-central1")

Expand Down Expand Up @@ -50,7 +50,7 @@ def test_call_bqremotefunction_vectorize(self, monkeypatch):
monkeypatch.setenv("GOOGLE_LOCATION", "us-central1")

test_name = "bqremotefunction_test"
app = Goblet(function_name=test_name)
app = Goblet(function_name=test_name, backend="cloudfunction")

@app.bqremotefunction(dataset_id="blogs", vectorize_func=True)
def function_test(x: List[int], y: List[str]) -> List[str]:
Expand All @@ -77,7 +77,7 @@ def test_call_bqremotefunction(self, monkeypatch):
monkeypatch.setenv("GOOGLE_LOCATION", "us-central1")

test_name = "bqremotefunction_test"
app = Goblet(function_name=test_name)
app = Goblet(function_name=test_name, backend="cloudfunction")

@app.bqremotefunction(dataset_id="blogs")
def function_test(x: int, y: int) -> int:
Expand Down Expand Up @@ -107,7 +107,7 @@ def test_deploy_bqremotefunction(self, monkeypatch):
monkeypatch.setenv("G_HTTP_TEST", "REPLAY")

test_name = "bqremotefunction_test"
app = Goblet(function_name=test_name)
app = Goblet(function_name=test_name, backend="cloudfunction")

@app.bqremotefunction(dataset_id="blogs")
def string_test_blogs_1(x: str, y: str) -> str:
Expand Down Expand Up @@ -170,7 +170,7 @@ def test_deploy_bqremotefunction_region(self, monkeypatch, requests_mock):
requests_mock.register_uri("PUT", "https://storage.googleapis.com/mock")

test_name = "bq-test-region"
app = Goblet(function_name=test_name)
app = Goblet(function_name=test_name, backend="cloudfunction")

@app.bqremotefunction(dataset_id="test", location="US")
def string_test_blogs_1(x: str, y: str) -> str:
Expand Down Expand Up @@ -228,7 +228,7 @@ def test_destroy_bqremotefunction(self, monkeypatch):
monkeypatch.setenv("G_HTTP_TEST", "REPLAY")

test_name = "bqremotefunction_test"
app = Goblet(function_name=test_name)
app = Goblet(function_name=test_name, backend="cloudfunction")

@app.bqremotefunction(dataset_id="blogs")
def string_test_blogs_1(x: str, y: str) -> str:
Expand Down Expand Up @@ -260,7 +260,7 @@ def test_destroy_bqremotefunction_region(self, monkeypatch):
monkeypatch.setenv("G_HTTP_TEST", "REPLAY")

test_name = "bqremotefunction_test"
app = Goblet(function_name=test_name)
app = Goblet(function_name=test_name, backend="cloudfunction")

@app.bqremotefunction(dataset_id="test", location="US")
def string_test_blogs_1(x: str, y: str) -> str:
Expand Down
12 changes: 7 additions & 5 deletions goblet/tests/test_bqsparkstoredprocedure.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

class TestBqSparkStoredProcedure:
def test_register_bqsparkstoredprocedure(self, monkeypatch):
app = Goblet(function_name="bqsparkstoredprocedure_test")
app = Goblet(
function_name="bqsparkstoredprocedure_test", backend="cloudfunction"
)
monkeypatch.setenv("GOOGLE_PROJECT", "goblet")
monkeypatch.setenv("GOOGLE_LOCATION", "us")
reset_replay_count()
Expand Down Expand Up @@ -62,7 +64,7 @@ def test_deploy_bqsparkstoredprocedure(self, monkeypatch):

test_name = "bqsparkstoredprocedure_test"
procedure_name = "test_spark_stored_procedure"
app = Goblet(function_name=test_name)
app = Goblet(function_name=test_name, backend="cloudfunction")
test_dataset_id = "blogs"

def spark_handler():
Expand Down Expand Up @@ -112,7 +114,7 @@ def test_destroy_bqsparkstoredprocedure(self, monkeypatch):
reset_replay_count()

test_name = "bqsparkstoredprocedure_test"
app = Goblet(function_name=test_name)
app = Goblet(function_name=test_name, backend="cloudfunction")
test_dataset_id = "blogs"

def spark_handler():
Expand All @@ -139,7 +141,7 @@ def test_deploy_bqsparkstoredprocedure_remote_code(self, monkeypatch):
reset_replay_count()

procedure_name = "test_spark_stored_procedure"
app = Goblet(function_name=test_name)
app = Goblet(function_name=test_name, backend="cloudfunction")
test_dataset_id = "blogs"

with open("spark.py", "w") as f:
Expand Down Expand Up @@ -199,7 +201,7 @@ def test_destroy_bqsparkstoredprocedure_remote_code(self, monkeypatch):

test_name = "bqsparkstoredprocedure-remote-deploy"
procedure_name = "test_spark_stored_procedure"
app = Goblet(function_name=test_name)
app = Goblet(function_name=test_name, backend="cloudfunction")
test_dataset_id = "blogs"

app.bqsparkstoredprocedure(
Expand Down
12 changes: 7 additions & 5 deletions goblet/tests/test_cloudtasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class TestCloudTasks:
def test_add_cloudtaskqueues(self):
app = Goblet(
function_name="goblet_example",
function_name="goblet-example",
config={"cloudtask": {"serviceAccount": "[email protected]"}},
)

Expand All @@ -28,7 +28,7 @@ def test_deploy_cloudtaskqueue(self, monkeypatch):
monkeypatch.setenv("G_HTTP_TEST", "REPLAY")

app = Goblet(
function_name="goblet_example",
function_name="goblet-example",
config={"cloudtask": {"serviceAccount": "[email protected]"}},
)

Expand Down Expand Up @@ -58,6 +58,7 @@ def test_destroy_cloudtaskqueue(self, monkeypatch):
app = Goblet(
function_name="goblet_example",
config={"cloudtask": {"serviceAccount": "[email protected]"}},
backend="cloudfunction",
)

client: CloudTaskClient = app.cloudtaskqueue( # noqa: F841
Expand All @@ -80,8 +81,9 @@ def test_enqueue_task(self, monkeypatch):
monkeypatch.setenv("G_HTTP_TEST", "REPLAY")

app = Goblet(
function_name="goblet_example",
function_name="goblet-example",
config={"cloudtask": {"serviceAccount": "[email protected]"}},
backend="cloudfunction",
)

client: CloudTaskClient = app.cloudtaskqueue(name="cloudtaskqueue")
Expand Down Expand Up @@ -137,7 +139,7 @@ def test_build_task(self):
)

def test_duplicate_targets(self):
app = Goblet(function_name="goblet_example")
app = Goblet(function_name="goblet-example")

with pytest.raises(Exception):

Expand All @@ -150,7 +152,7 @@ def dummy_function2(task):
return {}

def test_handle_cloud_task(self):
app = Goblet(function_name="goblet_example")
app = Goblet(function_name="goblet-example")

@app.cloudtasktarget(name="target")
def dummy_function(task):
Expand Down
Loading