-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
process input parameter with polygon
- Loading branch information
Showing
10 changed files
with
112 additions
and
29 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
App/functions/report-python-cloud-run/report/datasets/utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import base64 | ||
from io import BytesIO | ||
from matplotlib import pyplot as plt | ||
|
||
|
||
def plot_to_base64(fig: plt.Figure) -> str: | ||
"""Convert a matplotlib figure to base64""" | ||
img = BytesIO() | ||
fig.savefig(img, format="png", bbox_inches="tight") | ||
|
||
return base64.b64encode(img.getbuffer()).decode("ascii") | ||
|
||
|
||
def plot_to_svg(fig: plt.Figure) -> str: | ||
"""Convert a matplotlib figure to svg""" | ||
img = BytesIO() | ||
fig.savefig(img, format="svg", bbox_inches="tight") | ||
|
||
return img.getvalue().decode("ascii") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
html, | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} |
4 changes: 4 additions & 0 deletions
4
App/functions/report-python-cloud-run/report/template.html.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
import pytest | ||
|
||
import main # type: ignore | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
main.app.testing = True | ||
return main.app.test_client() | ||
|
||
|
||
# def test_handler_no_env_variable(client): | ||
# r = client.get("/") | ||
|
||
# assert r.data.decode() == "Hello World!" | ||
# assert r.status_code == 200 | ||
|
||
|
||
def test_main_handler(client): | ||
r = client.get( | ||
"/?polygon=%7B%22coordinates%22%3A%5B%5B%5B4.4548747899694945%2C53.1816853031429%5D%2C%5B4.156603653116093%2C52.553604613949375%5D%2C%5B3.2409806283587557%2C51.753524628396576%5D%2C%5B3.442140232282071%2C51.404367273499105%5D%2C%5B4.343890180908346%2C51.274368422568756%5D%2C%5B4.732336312623886%2C52.09148048735997%5D%2C%5B5.197084363068569%2C52.86878161448763%5D%2C%5B5.238703591466617%2C53.11095934419029%5D%2C%5B4.4548747899694945%2C53.1816853031429%5D%5D%5D%2C%22type%22%3A%22Polygon%22%7D" | ||
) | ||
|
||
# assert r.data.decode() == "Hello World!" | ||
assert r.status_code == 200 | ||
|
||
|
||
# def test_handler_with_env_variable(client): | ||
# os.environ["NAME"] = "Foo" | ||
# r = client.get("/") | ||
|
||
# assert r.data.decode() == "Hello Foo!" | ||
# assert r.status_code == 200 |
Empty file.