From 8b55c1637e4c29647168969e2f505fb6180cb9a7 Mon Sep 17 00:00:00 2001
From: James Gray
Date: Wed, 1 Apr 2020 17:09:12 +0200
Subject: [PATCH 01/61] Setup a global aiohttp.ClientSession instance
---
Pipfile | 1 +
app/main.py | 3 +++
app/utils/httputils.py | 30 ++++++++++++++++++++++++++++++
tests/test_httputils.py | 0
4 files changed, 34 insertions(+)
create mode 100644 app/utils/httputils.py
create mode 100644 tests/test_httputils.py
diff --git a/Pipfile b/Pipfile
index 2e5b9a1f..84ec24f6 100644
--- a/Pipfile
+++ b/Pipfile
@@ -14,6 +14,7 @@ pytest = "*"
pytest-cov = "*"
[packages]
+aiohttp = "*"
cachetools = "*"
fastapi = "*"
gunicorn = "*"
diff --git a/app/main.py b/app/main.py
index 75805ebc..0018f8bf 100644
--- a/app/main.py
+++ b/app/main.py
@@ -13,6 +13,7 @@
from .data import data_source
from .router.v1 import V1
from .router.v2 import V2
+from .utils.httputils import setup_client_session, teardown_client_session
# ############
# FastAPI App
@@ -28,6 +29,8 @@
version="2.0.1",
docs_url="/",
redoc_url="/docs",
+ on_startup=[setup_client_session],
+ on_shutdown=[teardown_client_session],
)
# #####################
diff --git a/app/utils/httputils.py b/app/utils/httputils.py
new file mode 100644
index 00000000..de5d5b17
--- /dev/null
+++ b/app/utils/httputils.py
@@ -0,0 +1,30 @@
+import logging
+
+from aiohttp import ClientSession
+
+
+# Singleton aiohttp.ClientSession instance.
+client_session: ClientSession
+
+
+LOGGER = logging.getLogger(__name__)
+
+
+async def setup_client_session():
+ """Set up the application-global aiohttp.ClientSession instance.
+
+ aiohttp recommends that only one ClientSession exist for the lifetime of an application.
+ See: https://docs.aiohttp.org/en/stable/client_quickstart.html#make-a-request
+
+ """
+ global client_session
+ LOGGER.info("Setting up global aiohttp.ClientSession.")
+ client_session = ClientSession()
+
+
+async def teardown_client_session():
+ """Close the application-global aiohttp.ClientSession.
+ """
+ global client_session
+ LOGGER.info("Closing global aiohttp.ClientSession.")
+ await client_session.close()
diff --git a/tests/test_httputils.py b/tests/test_httputils.py
new file mode 100644
index 00000000..e69de29b
From 63f68841602b38bba3fa91a58f39608aae622ce4 Mon Sep 17 00:00:00 2001
From: James Gray
Date: Wed, 1 Apr 2020 17:11:32 +0200
Subject: [PATCH 02/61] Make core blocking functions async using aiohttp
---
app/services/location/csbs.py | 8 ++++----
app/services/location/jhu.py | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/services/location/csbs.py b/app/services/location/csbs.py
index 84654963..32aa429c 100644
--- a/app/services/location/csbs.py
+++ b/app/services/location/csbs.py
@@ -2,11 +2,11 @@
import csv
from datetime import datetime
-import requests
from cachetools import TTLCache, cached
from ...coordinates import Coordinates
from ...location.csbs import CSBSLocation
+from ...utils import httputils
from . import LocationService
@@ -28,15 +28,15 @@ def get(self, loc_id): # pylint: disable=arguments-differ
@cached(cache=TTLCache(maxsize=1, ttl=3600))
-def get_locations():
+async def get_locations():
"""
Retrieves county locations; locations are cached for 1 hour
:returns: The locations.
:rtype: dict
"""
- request = requests.get(BASE_URL)
- text = request.text
+ async with httputils.client_session.get(BASE_URL) as response:
+ text = await response.text()
data = list(csv.DictReader(text.splitlines()))
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index 0f02409f..72783ee4 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -2,7 +2,6 @@
import csv
from datetime import datetime
-import requests
from cachetools import TTLCache, cached
from ...coordinates import Coordinates
@@ -10,6 +9,7 @@
from ...timeline import Timeline
from ...utils import countries
from ...utils import date as date_util
+from ...utils import httputils
from . import LocationService
@@ -37,7 +37,7 @@ def get(self, loc_id): # pylint: disable=arguments-differ
@cached(cache=TTLCache(maxsize=1024, ttl=3600))
-def get_category(category):
+async def get_category(category):
"""
Retrieves the data for the provided category. The data is cached for 1 hour.
@@ -52,8 +52,8 @@ def get_category(category):
url = BASE_URL + "time_series_covid19_%s_global.csv" % category
# Request the data
- request = requests.get(url)
- text = request.text
+ async with httputils.client_session.get(url) as response:
+ text = await response.text()
# Parse the CSV.
data = list(csv.DictReader(text.splitlines()))
From 9b945738b5a33a12710c62acf74651d54080d06e Mon Sep 17 00:00:00 2001
From: James Gray
Date: Wed, 1 Apr 2020 17:12:10 +0200
Subject: [PATCH 03/61] Add async/await keywords as necessary up the call chain
---
app/router/v1/all.py | 8 ++++----
app/router/v1/confirmed.py | 6 ++++--
app/router/v1/deaths.py | 6 ++++--
app/router/v1/recovered.py | 6 ++++--
app/router/v2/latest.py | 4 ++--
app/router/v2/locations.py | 9 +++++----
app/services/location/__init__.py | 4 ++--
app/services/location/csbs.py | 15 +++++++++------
app/services/location/jhu.py | 30 ++++++++++++++++++------------
9 files changed, 52 insertions(+), 36 deletions(-)
diff --git a/app/router/v1/all.py b/app/router/v1/all.py
index b26fe25b..91b9e826 100644
--- a/app/router/v1/all.py
+++ b/app/router/v1/all.py
@@ -4,11 +4,11 @@
@V1.get("/all")
-def all(): # pylint: disable=redefined-builtin
+async def all(): # pylint: disable=redefined-builtin
"""Get all the categories."""
- confirmed = get_category("confirmed")
- deaths = get_category("deaths")
- recovered = get_category("recovered")
+ confirmed = await get_category("confirmed")
+ deaths = await get_category("deaths")
+ recovered = await get_category("recovered")
return {
# Data.
diff --git a/app/router/v1/confirmed.py b/app/router/v1/confirmed.py
index f3b97523..eda7702e 100644
--- a/app/router/v1/confirmed.py
+++ b/app/router/v1/confirmed.py
@@ -4,6 +4,8 @@
@V1.get("/confirmed")
-def confirmed():
+async def confirmed():
"""Confirmed cases."""
- return get_category("confirmed")
+ confirmed = await get_category("confirmed")
+
+ return confirmed
diff --git a/app/router/v1/deaths.py b/app/router/v1/deaths.py
index 65ed0967..d41d1d9d 100644
--- a/app/router/v1/deaths.py
+++ b/app/router/v1/deaths.py
@@ -4,6 +4,8 @@
@V1.get("/deaths")
-def deaths():
+async def deaths():
"""Total deaths."""
- return get_category("deaths")
+ deaths = await get_category("deaths")
+
+ return deaths
diff --git a/app/router/v1/recovered.py b/app/router/v1/recovered.py
index 254823ed..24fcb4fd 100644
--- a/app/router/v1/recovered.py
+++ b/app/router/v1/recovered.py
@@ -4,6 +4,8 @@
@V1.get("/recovered")
-def recovered():
+async def recovered():
"""Recovered cases."""
- return get_category("recovered")
+ recovered = await get_category("recovered")
+
+ return recovered
diff --git a/app/router/v2/latest.py b/app/router/v2/latest.py
index 071c3a22..105b16fe 100644
--- a/app/router/v2/latest.py
+++ b/app/router/v2/latest.py
@@ -7,11 +7,11 @@
@V2.get("/latest", response_model=Latest)
-def get_latest(request: Request, source: Sources = "jhu"): # pylint: disable=unused-argument
+async def get_latest(request: Request, source: Sources = "jhu"): # pylint: disable=unused-argument
"""
Getting latest amount of total confirmed cases, deaths, and recoveries.
"""
- locations = request.state.source.get_all()
+ locations = await request.state.source.get_all()
return {
"latest": {
"confirmed": sum(map(lambda location: location.confirmed, locations)),
diff --git a/app/router/v2/locations.py b/app/router/v2/locations.py
index 815b1eb8..649f9c9e 100644
--- a/app/router/v2/locations.py
+++ b/app/router/v2/locations.py
@@ -9,7 +9,7 @@
# pylint: disable=unused-argument,too-many-arguments,redefined-builtin
@V2.get("/locations", response_model=Locations, response_model_exclude_unset=True)
-def get_locations(
+async def get_locations(
request: Request,
source: Sources = "jhu",
country_code: str = None,
@@ -28,7 +28,7 @@ def get_locations(
params.pop("timelines", None)
# Retrieve all the locations.
- locations = request.state.source.get_all()
+ locations = await request.state.source.get_all()
# Attempt to filter out locations with properties matching the provided query params.
for key, value in params.items():
@@ -57,8 +57,9 @@ def get_locations(
# pylint: disable=invalid-name
@V2.get("/locations/{id}", response_model=Location)
-def get_location_by_id(request: Request, id: int, source: Sources = "jhu", timelines: bool = True):
+async def get_location_by_id(request: Request, id: int, source: Sources = "jhu", timelines: bool = True):
"""
Getting specific location by id.
"""
- return {"location": request.state.source.get(id).serialize(timelines)}
+ location = await request.state.source.get(id)
+ return {"location": location.serialize(timelines)}
diff --git a/app/services/location/__init__.py b/app/services/location/__init__.py
index 404e9f7e..6d292b54 100644
--- a/app/services/location/__init__.py
+++ b/app/services/location/__init__.py
@@ -8,7 +8,7 @@ class LocationService(ABC):
"""
@abstractmethod
- def get_all(self):
+ async def get_all(self):
"""
Gets and returns all of the locations.
@@ -18,7 +18,7 @@ def get_all(self):
raise NotImplementedError
@abstractmethod
- def get(self, id): # pylint: disable=redefined-builtin,invalid-name
+ async def get(self, id): # pylint: disable=redefined-builtin,invalid-name
"""
Gets and returns location with the provided id.
diff --git a/app/services/location/csbs.py b/app/services/location/csbs.py
index 32aa429c..8a1ded3e 100644
--- a/app/services/location/csbs.py
+++ b/app/services/location/csbs.py
@@ -12,15 +12,18 @@
class CSBSLocationService(LocationService):
"""
- Servive for retrieving locations from csbs
+ Service for retrieving locations from csbs
"""
- def get_all(self):
- # Get the locations
- return get_locations()
+ async def get_all(self):
+ # Get the locations.
+ locations = await get_locations()
+ return locations
- def get(self, loc_id): # pylint: disable=arguments-differ
- return self.get_all()[loc_id]
+ async def get(self, loc_id): # pylint: disable=arguments-differ
+ # Get location at the index equal to the provided id.
+ locations = await self.get_all()
+ return locations[loc_id]
# Base URL for fetching data
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index 72783ee4..c050d111 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -18,13 +18,15 @@ class JhuLocationService(LocationService):
Service for retrieving locations from Johns Hopkins CSSE (https://github.com/CSSEGISandData/COVID-19).
"""
- def get_all(self):
+ async def get_all(self):
# Get the locations.
- return get_locations()
+ locations = await get_locations()
+ return locations
- def get(self, loc_id): # pylint: disable=arguments-differ
+ async def get(self, loc_id): # pylint: disable=arguments-differ
# Get location at the index equal to provided id.
- return self.get_all()[loc_id]
+ locations = await self.get_all()
+ return locations[loc_id]
# ---------------------------------------------------------------
@@ -103,7 +105,7 @@ async def get_category(category):
@cached(cache=TTLCache(maxsize=1024, ttl=3600))
-def get_locations():
+async def get_locations():
"""
Retrieves the locations from the categories. The locations are cached for 1 hour.
@@ -111,20 +113,24 @@ def get_locations():
:rtype: List[Location]
"""
# Get all of the data categories locations.
- confirmed = get_category("confirmed")["locations"]
- deaths = get_category("deaths")["locations"]
- # recovered = get_category('recovered')['locations']
+ confirmed = await get_category("confirmed")
+ deaths = await get_category("deaths")
+ # recovered = await get_category("recovered")
+
+ locations_confirmed = confirmed["locations"]
+ locations_deaths = deaths["locations"]
+ # locations_recovered = recovered["locations"]
# Final locations to return.
locations = []
# Go through locations.
- for index, location in enumerate(confirmed):
+ for index, location in enumerate(locations_confirmed):
# Get the timelines.
timelines = {
- "confirmed": confirmed[index]["history"],
- "deaths": deaths[index]["history"],
- # 'recovered' : recovered[index]['history'],
+ "confirmed": locations_confirmed[index]["history"],
+ "deaths": locations_deaths[index]["history"],
+ # 'recovered' : locations_recovered[index]['history'],
}
# Grab coordinates.
From 2f40cea8fa190cebd0a80a03fb9a3982f6e1db74 Mon Sep 17 00:00:00 2001
From: James Gray
Date: Wed, 1 Apr 2020 17:13:09 +0200
Subject: [PATCH 04/61] Use asyncache to cache results of asyncio coroutines
See: https://github.com/hephex/asyncache
---
Pipfile | 1 +
app/services/location/csbs.py | 3 ++-
app/services/location/jhu.py | 3 ++-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/Pipfile b/Pipfile
index 84ec24f6..a2261aea 100644
--- a/Pipfile
+++ b/Pipfile
@@ -15,6 +15,7 @@ pytest-cov = "*"
[packages]
aiohttp = "*"
+asyncache = "*"
cachetools = "*"
fastapi = "*"
gunicorn = "*"
diff --git a/app/services/location/csbs.py b/app/services/location/csbs.py
index 8a1ded3e..95f1c4b2 100644
--- a/app/services/location/csbs.py
+++ b/app/services/location/csbs.py
@@ -2,7 +2,8 @@
import csv
from datetime import datetime
-from cachetools import TTLCache, cached
+from asyncache import cached
+from cachetools import TTLCache
from ...coordinates import Coordinates
from ...location.csbs import CSBSLocation
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index c050d111..adee6bdc 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -2,7 +2,8 @@
import csv
from datetime import datetime
-from cachetools import TTLCache, cached
+from asyncache import cached
+from cachetools import TTLCache
from ...coordinates import Coordinates
from ...location import TimelinedLocation
From 63675dc96364bd0406342afa40e646584879d599 Mon Sep 17 00:00:00 2001
From: James Gray
Date: Thu, 2 Apr 2020 11:49:58 +0200
Subject: [PATCH 05/61] Add test dependencies
These are required to be able to test asyncio functionality, as well as making ASGI test clients play nice asynchronously.
---
Pipfile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Pipfile b/Pipfile
index a2261aea..d5097194 100644
--- a/Pipfile
+++ b/Pipfile
@@ -4,6 +4,7 @@ url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
+async-asgi-testclient = "*"
bandit = "*"
black = "==19.10b0"
coveralls = "*"
@@ -11,6 +12,7 @@ invoke = "*"
isort = "*"
pylint = "*"
pytest = "*"
+pytest-asyncio = "*"
pytest-cov = "*"
[packages]
From 0e11daa44b8aeee1c700c9f5215092f4698e4446 Mon Sep 17 00:00:00 2001
From: James Gray
Date: Thu, 2 Apr 2020 11:49:04 +0200
Subject: [PATCH 06/61] Update test_jhu to handle asyncio
- Move test fixtures into tests/fixtures.py
- Update test fixtures to mock aiohttp.ClientSession.get, instead of requests.get
- Add a context manager to replace the global httputils.client_session with an AsyncMock
- Misc. cleanup
---
tests/fixtures.py | 89 +++++++++++++++++++++++++++++++++++++++++++++++
tests/test_jhu.py | 83 ++++++++-----------------------------------
2 files changed, 103 insertions(+), 69 deletions(-)
create mode 100644 tests/fixtures.py
diff --git a/tests/fixtures.py b/tests/fixtures.py
new file mode 100644
index 00000000..faea895f
--- /dev/null
+++ b/tests/fixtures.py
@@ -0,0 +1,89 @@
+import datetime
+import os
+from contextlib import asynccontextmanager
+from unittest import mock
+
+from app.utils import httputils
+
+
+class DateTimeStrpTime:
+ """Returns instance of `DateTimeStrpTime`
+ when calling `app.services.location.jhu.datetime.trptime(date, '%m/%d/%y').isoformat()`.
+ """
+
+ def __init__(self, date, strformat):
+ self.date = date
+ self.strformat = strformat
+
+ def isoformat(self):
+ return datetime.datetime.strptime(self.date, self.strformat).isoformat()
+
+
+class FakeRequestsGetResponse:
+ """Fake instance of a response from `aiohttp.ClientSession.get`.
+ """
+
+ def __init__(self, url, filename, state):
+ self.url = url
+ self.filename = filename
+ self.state = state
+
+ async def text(self):
+ return self.read_file(self.state)
+
+ def read_file(self, state):
+ """
+ Mock HTTP GET-method and return text from file
+ """
+ state = state.lower()
+
+ # Determine filepath.
+ filepath = os.path.join(os.path.dirname(__file__), "example_data/{}.csv".format(state))
+
+ # Return fake response.
+ print("Try to read {}".format(filepath))
+ with open(filepath, "r") as file:
+ return file.read()
+
+
+@asynccontextmanager
+async def mock_client_session():
+ """Context manager that replaces the global client_session with an AsyncMock instance.
+
+ :Example:
+
+ >>> async with mock_client_session() as mocked_client_session:
+ >>> mocked_client_session.get = mocked_session_get
+ >>> # test code...
+
+ """
+
+ httputils.client_session = mocked_client_session = mock.AsyncMock()
+ try:
+ yield mocked_client_session
+ finally:
+ del httputils.client_session
+
+
+@asynccontextmanager
+async def mocked_session_get(*args, **kwargs):
+ """Mock response from client_session.get.
+ """
+
+ url = args[0]
+ filename = url.split("/")[-1]
+
+ # clean up for id token (e.g. Deaths)
+ state = filename.split("-")[-1].replace(".csv", "").lower().capitalize()
+
+ yield FakeRequestsGetResponse(url, filename, state)
+
+
+def mocked_strptime_isoformat(*args, **kwargs):
+ """Mock return value from datetime.strptime().isoformat().
+ """
+
+ date = args[0]
+ strformat = args[1]
+
+ return DateTimeStrpTime(date, strformat)
diff --git a/tests/test_jhu.py b/tests/test_jhu.py
index f9c214a6..4f46becf 100644
--- a/tests/test_jhu.py
+++ b/tests/test_jhu.py
@@ -6,81 +6,26 @@
import app
from app import location
from app.services.location import jhu
-from app.utils import date
+from tests.fixtures import mock_client_session
+from tests.fixtures import mocked_session_get
+from tests.fixtures import mocked_strptime_isoformat
DATETIME_STRING = "2020-03-17T10:23:22.505550"
-def mocked_requests_get(*args, **kwargs):
- class FakeRequestsGetResponse:
- """
- Returns instance of `FakeRequestsGetResponse`
- when calling `app.services.location.jhu.requests.get()`
- """
-
- def __init__(self, url, filename, state):
- self.url = url
- self.filename = filename
- self.state = state
- self.text = self.read_file(self.state)
-
- def read_file(self, state):
- """
- Mock HTTP GET-method and return text from file
- """
- state = state.lower()
-
- # Determine filepath.
- filepath = "tests/example_data/{}.csv".format(state)
-
- # Return fake response.
- print("Try to read {}".format(filepath))
- with open(filepath, "r") as file:
- return file.read()
-
- # get url from `request.get`
- url = args[0]
-
- # get filename from url
- filename = url.split("/")[-1]
-
- # clean up for id token (e.g. Deaths)
- state = filename.split("-")[-1].replace(".csv", "").lower().capitalize()
-
- return FakeRequestsGetResponse(url, filename, state)
-
-
-def mocked_strptime_isoformat(*args, **kwargs):
- class DateTimeStrpTime:
- """
- Returns instance of `DateTimeStrpTime`
- when calling `app.services.location.jhu.datetime.trptime(date, '%m/%d/%y').isoformat()`
- """
-
- def __init__(self, date, strformat):
- self.date = date
- self.strformat = strformat
-
- def isoformat(self):
- return datetime.datetime.strptime(self.date, self.strformat).isoformat()
-
- date = args[0]
- strformat = args[1]
-
- return DateTimeStrpTime(date, strformat)
-
-
+@pytest.mark.asyncio
@mock.patch("app.services.location.jhu.datetime")
-@mock.patch("app.services.location.jhu.requests.get", side_effect=mocked_requests_get)
-def test_get_locations(mock_request_get, mock_datetime):
- # mock app.services.location.jhu.datetime.utcnow().isoformat()
+async def test_get_locations(mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
- output = jhu.get_locations()
- assert isinstance(output, list)
- assert isinstance(output[0], location.Location)
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ output = await jhu.get_locations()
+
+ assert isinstance(output, list)
+ assert isinstance(output[0], location.Location)
- # `jhu.get_locations()` creates id based on confirmed list
- location_confirmed = jhu.get_category("confirmed")
- assert len(output) == len(location_confirmed["locations"])
+ # `jhu.get_locations()` creates id based on confirmed list
+ location_confirmed = await jhu.get_category("confirmed")
+ assert len(output) == len(location_confirmed["locations"])
From 3bfc94eff8caa84291507e3f24caf90003dfd06c Mon Sep 17 00:00:00 2001
From: James Gray
Date: Thu, 2 Apr 2020 11:50:37 +0200
Subject: [PATCH 07/61] Update test_csbs to handle asyncio
---
...sample_covid19_county.csv => covid19_county.csv} | 0
tests/test_csbs.py | 13 +++++++++----
2 files changed, 9 insertions(+), 4 deletions(-)
rename tests/example_data/{sample_covid19_county.csv => covid19_county.csv} (100%)
diff --git a/tests/example_data/sample_covid19_county.csv b/tests/example_data/covid19_county.csv
similarity index 100%
rename from tests/example_data/sample_covid19_county.csv
rename to tests/example_data/covid19_county.csv
diff --git a/tests/test_csbs.py b/tests/test_csbs.py
index 64852102..087e483a 100644
--- a/tests/test_csbs.py
+++ b/tests/test_csbs.py
@@ -5,6 +5,8 @@
import app
from app.services.location import csbs
+from tests.fixtures import mock_client_session
+from tests.fixtures import mocked_session_get
def mocked_csbs_requests_get(*args, **kwargs):
@@ -21,7 +23,7 @@ def read_file(self):
"""
Mock HTTP GET-method and return text from file
"""
- filepath = "tests/example_data/sample_covid19_county.csv"
+ filepath = "tests/example_data/covid19_county.csv"
print("Try to read {}".format(filepath))
with open(filepath, "r") as file:
return file.read()
@@ -29,9 +31,12 @@ def read_file(self):
return FakeRequestsGetResponse()
-@mock.patch("app.services.location.csbs.requests.get", side_effect=mocked_csbs_requests_get)
-def test_get_locations(mock_request_get):
- data = csbs.get_locations()
+@pytest.mark.asyncio
+async def test_get_locations():
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ data = await csbs.get_locations()
+
assert isinstance(data, list)
# check to see that Unknown/Unassigned has been filtered
From c4a6c9ed2ba19a96f173fb6a07d445d31bd0cbde Mon Sep 17 00:00:00 2001
From: James Gray
Date: Thu, 2 Apr 2020 11:50:54 +0200
Subject: [PATCH 08/61] Update test_routes to handle asyncio
---
tests/test_routes.py | 90 ++++++++++++++++++++++++++++++--------------
1 file changed, 61 insertions(+), 29 deletions(-)
diff --git a/tests/test_routes.py b/tests/test_routes.py
index 48d804e5..fa657ed1 100644
--- a/tests/test_routes.py
+++ b/tests/test_routes.py
@@ -4,17 +4,17 @@
from unittest import mock
import pytest
-from fastapi.testclient import TestClient
+from async_asgi_testclient import TestClient
-# import app
-# from app import services
+from .fixtures import mock_client_session
+from .fixtures import mocked_session_get
+from .fixtures import mocked_strptime_isoformat
+from .test_jhu import DATETIME_STRING
from app.main import APP
-from .test_jhu import DATETIME_STRING, mocked_requests_get, mocked_strptime_isoformat
-
+@pytest.mark.asyncio
@mock.patch("app.services.location.jhu.datetime")
-@mock.patch("app.services.location.jhu.requests.get", side_effect=mocked_requests_get)
class FlaskRoutesTest(unittest.TestCase):
"""
Need to mock some objects to control testing data locally
@@ -32,89 +32,112 @@ def read_file_v1(self, state):
expected_json_output = file.read()
return expected_json_output
- def test_root_api(self, mock_request_get, mock_datetime):
+ async def test_root_api(self, mock_datetime):
"""Validate that / returns a 200 and is not a redirect."""
- response = self.asgi_client.get("/")
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ response = await self.asgi_client.get("/")
assert response.status_code == 200
assert not response.is_redirect
- def test_v1_confirmed(self, mock_request_get, mock_datetime):
+ async def test_v1_confirmed(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
state = "confirmed"
expected_json_output = self.read_file_v1(state=state)
- return_data = self.asgi_client.get("/{}".format(state)).json()
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ response = await self.asgi_client.get("/{}".format(state))
+ return_data = response.json()
assert return_data == json.loads(expected_json_output)
- def test_v1_deaths(self, mock_request_get, mock_datetime):
+ async def test_v1_deaths(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
state = "deaths"
expected_json_output = self.read_file_v1(state=state)
- return_data = self.asgi_client.get("/{}".format(state)).json()
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ response = await self.asgi_client.get("/{}".format(state))
+ return_data = response.json()
assert return_data == json.loads(expected_json_output)
- def test_v1_recovered(self, mock_request_get, mock_datetime):
+ async def test_v1_recovered(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
state = "recovered"
expected_json_output = self.read_file_v1(state=state)
- return_data = self.asgi_client.get("/{}".format(state)).json()
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ response = await self.asgi_client.get("/{}".format(state))
+ return_data = response.json()
assert return_data == json.loads(expected_json_output)
- def test_v1_all(self, mock_request_get, mock_datetime):
+ async def test_v1_all(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
state = "all"
expected_json_output = self.read_file_v1(state=state)
- return_data = self.asgi_client.get("/{}".format(state)).json()
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ response = await self.asgi_client.get("/{}".format(state))
+ return_data = response.json()
assert return_data == json.loads(expected_json_output)
- def test_v2_latest(self, mock_request_get, mock_datetime):
+ async def test_v2_latest(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
state = "latest"
- return_data = self.asgi_client.get(f"/v2/{state}").json()
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ response = await self.asgi_client.get(f"/v2/{state}")
+ return_data = response.json()
check_dict = {"latest": {"confirmed": 1940, "deaths": 1940, "recovered": 0}}
assert return_data == check_dict
- def test_v2_locations(self, mock_request_get, mock_datetime):
+ async def test_v2_locations(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
state = "locations"
- return_data = self.asgi_client.get("/v2/{}".format(state)).json()
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ response = await self.asgi_client.get("/v2/{}".format(state))
+ return_data = response.json()
filepath = "tests/expected_output/v2_{state}.json".format(state=state)
with open(filepath, "r") as file:
expected_json_output = file.read()
+ # TODO: Why is this failing?
# assert return_data == json.loads(expected_json_output)
- def test_v2_locations_id(self, mock_request_get, mock_datetime):
+ async def test_v2_locations_id(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
state = "locations"
test_id = 1
- return_data = self.asgi_client.get("/v2/{}/{}".format(state, test_id)).json()
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ response = await self.asgi_client.get("/v2/{}/{}".format(state, test_id))
+ return_data = response.json()
filepath = "tests/expected_output/v2_{state}_id_{test_id}.json".format(state=state, test_id=test_id)
with open(filepath, "r") as file:
expected_json_output = file.read()
+ # TODO: Why is this failing?
# assert return_data == expected_json_output
- def tearDown(self):
- pass
-
+@pytest.mark.asyncio
@pytest.mark.parametrize(
"query_params,expected_status",
[
@@ -128,13 +151,18 @@ def tearDown(self):
({"source": "jhu", "country_code": "US"}, 404),
],
)
-def test_locations_status_code(api_client, query_params, expected_status):
- response = api_client.get("/v2/locations", params=query_params)
+async def test_locations_status_code(query_params, expected_status):
+ api_client = TestClient(APP)
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ response = await api_client.get("/v2/locations", query_string=query_params)
+
print(f"GET {response.url}\n{response}")
print(f"\tjson:\n{pf(response.json())[:1000]}\n\t...")
assert response.status_code == expected_status
+@pytest.mark.asyncio
@pytest.mark.parametrize(
"query_params",
[
@@ -146,8 +174,12 @@ def test_locations_status_code(api_client, query_params, expected_status):
{"source": "jhu", "timelines": True},
],
)
-def test_latest(api_client, query_params):
- response = api_client.get("/v2/latest", params=query_params)
+async def test_latest(query_params):
+ api_client = TestClient(APP)
+ async with mock_client_session() as mocked_client_session:
+ mocked_client_session.get = mocked_session_get
+ response = await api_client.get("/v2/latest", query_string=query_params)
+
print(f"GET {response.url}\n{response}")
response_json = response.json()
From 5b798c59a29bd9bb27d19c08fceb10373ba61add Mon Sep 17 00:00:00 2001
From: James Gray
Date: Thu, 2 Apr 2020 11:51:12 +0200
Subject: [PATCH 09/61] Remove unused imports
---
tests/test_csbs.py | 4 ----
tests/test_jhu.py | 2 --
2 files changed, 6 deletions(-)
diff --git a/tests/test_csbs.py b/tests/test_csbs.py
index 087e483a..255125b1 100644
--- a/tests/test_csbs.py
+++ b/tests/test_csbs.py
@@ -1,9 +1,5 @@
-import datetime
-from unittest import mock
-
import pytest
-import app
from app.services.location import csbs
from tests.fixtures import mock_client_session
from tests.fixtures import mocked_session_get
diff --git a/tests/test_jhu.py b/tests/test_jhu.py
index 4f46becf..80c17ee2 100644
--- a/tests/test_jhu.py
+++ b/tests/test_jhu.py
@@ -1,9 +1,7 @@
-import datetime
from unittest import mock
import pytest
-import app
from app import location
from app.services.location import jhu
from tests.fixtures import mock_client_session
From 711ad5f3a03e726f23d0c1603f2446f7cdbaae26 Mon Sep 17 00:00:00 2001
From: James Gray
Date: Thu, 2 Apr 2020 11:55:58 +0200
Subject: [PATCH 10/61] Ignore intelliJ meta folder
---
.gitignore | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index efd5545c..9c41818c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,4 +66,7 @@ docs/_build/
target/
# OSX Stuff
-.DS_Store
\ No newline at end of file
+.DS_Store
+
+# IntelliJ/Pycharm
+.idea/
From 0e827fb37308edf6d01cac364d1ada868ae899e3 Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 12:20:23 +0200
Subject: [PATCH 11/61] Add an async_api_client pytest fixture
---
tests/conftest.py | 11 ++++++++++-
tests/test_routes.py | 10 ++++------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index a9811d22..22c33432 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -5,6 +5,7 @@
"""
import pytest
from fastapi.testclient import TestClient
+from async_asgi_testclient import TestClient as AsyncTestClient
from app.main import APP
@@ -12,7 +13,15 @@
@pytest.fixture
def api_client():
"""
- Returns a TestClient.
+ Returns a fastapi.testclient.TestClient.
The test client uses the requests library for making http requests.
"""
return TestClient(APP)
+
+
+@pytest.fixture
+async def async_api_client():
+ """
+ Returns an async_asgi_testclient.TestClient.
+ """
+ return AsyncTestClient(APP)
diff --git a/tests/test_routes.py b/tests/test_routes.py
index fa657ed1..17112666 100644
--- a/tests/test_routes.py
+++ b/tests/test_routes.py
@@ -151,11 +151,10 @@ async def test_v2_locations_id(self, mock_datetime):
({"source": "jhu", "country_code": "US"}, 404),
],
)
-async def test_locations_status_code(query_params, expected_status):
- api_client = TestClient(APP)
+async def test_locations_status_code(async_api_client, query_params, expected_status):
async with mock_client_session() as mocked_client_session:
mocked_client_session.get = mocked_session_get
- response = await api_client.get("/v2/locations", query_string=query_params)
+ response = await async_api_client.get("/v2/locations", query_string=query_params)
print(f"GET {response.url}\n{response}")
print(f"\tjson:\n{pf(response.json())[:1000]}\n\t...")
@@ -174,11 +173,10 @@ async def test_locations_status_code(query_params, expected_status):
{"source": "jhu", "timelines": True},
],
)
-async def test_latest(query_params):
- api_client = TestClient(APP)
+async def test_latest(async_api_client, query_params):
async with mock_client_session() as mocked_client_session:
mocked_client_session.get = mocked_session_get
- response = await api_client.get("/v2/latest", query_string=query_params)
+ response = await async_api_client.get("/v2/latest", query_string=query_params)
print(f"GET {response.url}\n{response}")
From afca2a934130652d0d8152595387bfd2a4fdbbc5 Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 12:21:40 +0200
Subject: [PATCH 12/61] Consolidate fixtures into conftest.py
I didn't see this file when I first added the new fixtures.
---
tests/conftest.py | 91 +++++++++++++++++++++++++++++++++++++++++++-
tests/fixtures.py | 89 -------------------------------------------
tests/test_csbs.py | 4 +-
tests/test_jhu.py | 6 +--
tests/test_routes.py | 6 +--
5 files changed, 98 insertions(+), 98 deletions(-)
delete mode 100644 tests/fixtures.py
diff --git a/tests/conftest.py b/tests/conftest.py
index 22c33432..39f1d15f 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -3,11 +3,17 @@
Global conftest file for shared pytest fixtures
"""
+import datetime
+import os
+from contextlib import asynccontextmanager
+from unittest import mock
+
import pytest
-from fastapi.testclient import TestClient
from async_asgi_testclient import TestClient as AsyncTestClient
+from fastapi.testclient import TestClient
from app.main import APP
+from app.utils import httputils
@pytest.fixture
@@ -25,3 +31,86 @@ async def async_api_client():
Returns an async_asgi_testclient.TestClient.
"""
return AsyncTestClient(APP)
+
+
+class DateTimeStrpTime:
+ """Returns instance of `DateTimeStrpTime`
+ when calling `app.services.location.jhu.datetime.trptime(date, '%m/%d/%y').isoformat()`.
+ """
+
+ def __init__(self, date, strformat):
+ self.date = date
+ self.strformat = strformat
+
+ def isoformat(self):
+ return datetime.datetime.strptime(self.date, self.strformat).isoformat()
+
+
+class FakeRequestsGetResponse:
+ """Fake instance of a response from `aiohttp.ClientSession.get`.
+ """
+
+ def __init__(self, url, filename, state):
+ self.url = url
+ self.filename = filename
+ self.state = state
+
+ async def text(self):
+ return self.read_file(self.state)
+
+ def read_file(self, state):
+ """
+ Mock HTTP GET-method and return text from file
+ """
+ state = state.lower()
+
+ # Determine filepath.
+ filepath = os.path.join(os.path.dirname(__file__), "example_data/{}.csv".format(state))
+
+ # Return fake response.
+ print("Try to read {}".format(filepath))
+ with open(filepath, "r") as file:
+ return file.read()
+
+
+@asynccontextmanager
+async def mock_client_session():
+ """Context manager that replaces the global client_session with an AsyncMock instance.
+
+ :Example:
+
+ >>> async with mock_client_session() as mocked_client_session:
+ >>> mocked_client_session.get = mocked_session_get
+ >>> # test code...
+
+ """
+
+ httputils.client_session = mocked_client_session = mock.AsyncMock()
+ try:
+ yield mocked_client_session
+ finally:
+ del httputils.client_session
+
+
+@asynccontextmanager
+async def mocked_session_get(*args, **kwargs):
+ """Mock response from client_session.get.
+ """
+
+ url = args[0]
+ filename = url.split("/")[-1]
+
+ # clean up for id token (e.g. Deaths)
+ state = filename.split("-")[-1].replace(".csv", "").lower().capitalize()
+
+ yield FakeRequestsGetResponse(url, filename, state)
+
+
+def mocked_strptime_isoformat(*args, **kwargs):
+ """Mock return value from datetime.strptime().isoformat().
+ """
+
+ date = args[0]
+ strformat = args[1]
+
+ return DateTimeStrpTime(date, strformat)
diff --git a/tests/fixtures.py b/tests/fixtures.py
deleted file mode 100644
index faea895f..00000000
--- a/tests/fixtures.py
+++ /dev/null
@@ -1,89 +0,0 @@
-import datetime
-import os
-from contextlib import asynccontextmanager
-from unittest import mock
-
-from app.utils import httputils
-
-
-class DateTimeStrpTime:
- """Returns instance of `DateTimeStrpTime`
- when calling `app.services.location.jhu.datetime.trptime(date, '%m/%d/%y').isoformat()`.
- """
-
- def __init__(self, date, strformat):
- self.date = date
- self.strformat = strformat
-
- def isoformat(self):
- return datetime.datetime.strptime(self.date, self.strformat).isoformat()
-
-
-class FakeRequestsGetResponse:
- """Fake instance of a response from `aiohttp.ClientSession.get`.
- """
-
- def __init__(self, url, filename, state):
- self.url = url
- self.filename = filename
- self.state = state
-
- async def text(self):
- return self.read_file(self.state)
-
- def read_file(self, state):
- """
- Mock HTTP GET-method and return text from file
- """
- state = state.lower()
-
- # Determine filepath.
- filepath = os.path.join(os.path.dirname(__file__), "example_data/{}.csv".format(state))
-
- # Return fake response.
- print("Try to read {}".format(filepath))
- with open(filepath, "r") as file:
- return file.read()
-
-
-@asynccontextmanager
-async def mock_client_session():
- """Context manager that replaces the global client_session with an AsyncMock instance.
-
- :Example:
-
- >>> async with mock_client_session() as mocked_client_session:
- >>> mocked_client_session.get = mocked_session_get
- >>> # test code...
-
- """
-
- httputils.client_session = mocked_client_session = mock.AsyncMock()
- try:
- yield mocked_client_session
- finally:
- del httputils.client_session
-
-
-@asynccontextmanager
-async def mocked_session_get(*args, **kwargs):
- """Mock response from client_session.get.
- """
-
- url = args[0]
- filename = url.split("/")[-1]
-
- # clean up for id token (e.g. Deaths)
- state = filename.split("-")[-1].replace(".csv", "").lower().capitalize()
-
- yield FakeRequestsGetResponse(url, filename, state)
-
-
-def mocked_strptime_isoformat(*args, **kwargs):
- """Mock return value from datetime.strptime().isoformat().
- """
-
- date = args[0]
- strformat = args[1]
-
- return DateTimeStrpTime(date, strformat)
diff --git a/tests/test_csbs.py b/tests/test_csbs.py
index 255125b1..a018b98e 100644
--- a/tests/test_csbs.py
+++ b/tests/test_csbs.py
@@ -1,8 +1,8 @@
import pytest
from app.services.location import csbs
-from tests.fixtures import mock_client_session
-from tests.fixtures import mocked_session_get
+from tests.conftest import mock_client_session
+from tests.conftest import mocked_session_get
def mocked_csbs_requests_get(*args, **kwargs):
diff --git a/tests/test_jhu.py b/tests/test_jhu.py
index 80c17ee2..1ef36f37 100644
--- a/tests/test_jhu.py
+++ b/tests/test_jhu.py
@@ -4,9 +4,9 @@
from app import location
from app.services.location import jhu
-from tests.fixtures import mock_client_session
-from tests.fixtures import mocked_session_get
-from tests.fixtures import mocked_strptime_isoformat
+from tests.conftest import mock_client_session
+from tests.conftest import mocked_session_get
+from tests.conftest import mocked_strptime_isoformat
DATETIME_STRING = "2020-03-17T10:23:22.505550"
diff --git a/tests/test_routes.py b/tests/test_routes.py
index 17112666..f7623965 100644
--- a/tests/test_routes.py
+++ b/tests/test_routes.py
@@ -6,9 +6,9 @@
import pytest
from async_asgi_testclient import TestClient
-from .fixtures import mock_client_session
-from .fixtures import mocked_session_get
-from .fixtures import mocked_strptime_isoformat
+from .conftest import mock_client_session
+from .conftest import mocked_session_get
+from .conftest import mocked_strptime_isoformat
from .test_jhu import DATETIME_STRING
from app.main import APP
From 3dfe15f34c5f4f216caffb66a67b11a7b8ccd21a Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 12:37:55 +0200
Subject: [PATCH 13/61] Make mock_client_session a proper Pytest fixture
---
tests/conftest.py | 26 +++++++++-----
tests/test_csbs.py | 8 ++---
tests/test_jhu.py | 18 +++++-----
tests/test_routes.py | 86 +++++++++++++++++++++++---------------------
4 files changed, 73 insertions(+), 65 deletions(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index 39f1d15f..9fde87d9 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -73,21 +73,29 @@ def read_file(self, state):
return file.read()
-@asynccontextmanager
-async def mock_client_session():
- """Context manager that replaces the global client_session with an AsyncMock instance.
+@pytest.fixture(scope="class")
+def mock_client_session_class(request):
+ """Class fixture to expose an AsyncMock to unittest.TestCase subclasses.
- :Example:
+ See: https://docs.pytest.org/en/5.4.1/unittest.html#mixing-pytest-fixtures-into-unittest-testcase-subclasses-using-marks
+ """
+
+ httputils.client_session = request.cls.mock_client_session = mock.AsyncMock()
+ try:
+ yield
+ finally:
+ del httputils.client_session
- >>> async with mock_client_session() as mocked_client_session:
- >>> mocked_client_session.get = mocked_session_get
- >>> # test code...
+@pytest.fixture
+async def mock_client_session():
+ """Context manager fixture that replaces the global client_session with an AsyncMock
+ instance.
"""
- httputils.client_session = mocked_client_session = mock.AsyncMock()
+ httputils.client_session = mock.AsyncMock()
try:
- yield mocked_client_session
+ yield httputils.client_session
finally:
del httputils.client_session
diff --git a/tests/test_csbs.py b/tests/test_csbs.py
index a018b98e..912bdd11 100644
--- a/tests/test_csbs.py
+++ b/tests/test_csbs.py
@@ -1,7 +1,6 @@
import pytest
from app.services.location import csbs
-from tests.conftest import mock_client_session
from tests.conftest import mocked_session_get
@@ -28,10 +27,9 @@ def read_file(self):
@pytest.mark.asyncio
-async def test_get_locations():
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- data = await csbs.get_locations()
+async def test_get_locations(mock_client_session):
+ mock_client_session.get = mocked_session_get
+ data = await csbs.get_locations()
assert isinstance(data, list)
diff --git a/tests/test_jhu.py b/tests/test_jhu.py
index 1ef36f37..12a3f704 100644
--- a/tests/test_jhu.py
+++ b/tests/test_jhu.py
@@ -4,7 +4,6 @@
from app import location
from app.services.location import jhu
-from tests.conftest import mock_client_session
from tests.conftest import mocked_session_get
from tests.conftest import mocked_strptime_isoformat
@@ -13,17 +12,16 @@
@pytest.mark.asyncio
@mock.patch("app.services.location.jhu.datetime")
-async def test_get_locations(mock_datetime):
+async def test_get_locations(mock_datetime, mock_client_session):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- output = await jhu.get_locations()
+ mock_client_session.get = mocked_session_get
+ output = await jhu.get_locations()
- assert isinstance(output, list)
- assert isinstance(output[0], location.Location)
+ assert isinstance(output, list)
+ assert isinstance(output[0], location.Location)
- # `jhu.get_locations()` creates id based on confirmed list
- location_confirmed = await jhu.get_category("confirmed")
- assert len(output) == len(location_confirmed["locations"])
+ # `jhu.get_locations()` creates id based on confirmed list
+ location_confirmed = await jhu.get_category("confirmed")
+ assert len(output) == len(location_confirmed["locations"])
diff --git a/tests/test_routes.py b/tests/test_routes.py
index f7623965..0f38c353 100644
--- a/tests/test_routes.py
+++ b/tests/test_routes.py
@@ -6,15 +6,14 @@
import pytest
from async_asgi_testclient import TestClient
-from .conftest import mock_client_session
from .conftest import mocked_session_get
from .conftest import mocked_strptime_isoformat
from .test_jhu import DATETIME_STRING
from app.main import APP
+@pytest.mark.usefixtures("mock_client_session_class")
@pytest.mark.asyncio
-@mock.patch("app.services.location.jhu.datetime")
class FlaskRoutesTest(unittest.TestCase):
"""
Need to mock some objects to control testing data locally
@@ -32,84 +31,91 @@ def read_file_v1(self, state):
expected_json_output = file.read()
return expected_json_output
+ @mock.patch("app.services.location.jhu.datetime")
async def test_root_api(self, mock_datetime):
"""Validate that / returns a 200 and is not a redirect."""
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- response = await self.asgi_client.get("/")
+ self.mock_client_session.get = mocked_session_get
+
+ response = await self.asgi_client.get("/")
assert response.status_code == 200
assert not response.is_redirect
+ @mock.patch("app.services.location.jhu.datetime")
async def test_v1_confirmed(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ self.mock_client_session.get = mocked_session_get
+
state = "confirmed"
expected_json_output = self.read_file_v1(state=state)
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- response = await self.asgi_client.get("/{}".format(state))
- return_data = response.json()
+ response = await self.asgi_client.get("/{}".format(state))
+ return_data = response.json()
assert return_data == json.loads(expected_json_output)
+ @mock.patch("app.services.location.jhu.datetime")
async def test_v1_deaths(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ self.mock_client_session.get = mocked_session_get
+
state = "deaths"
expected_json_output = self.read_file_v1(state=state)
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- response = await self.asgi_client.get("/{}".format(state))
- return_data = response.json()
+ response = await self.asgi_client.get("/{}".format(state))
+ return_data = response.json()
assert return_data == json.loads(expected_json_output)
+ @mock.patch("app.services.location.jhu.datetime")
async def test_v1_recovered(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ self.mock_client_session.get = mocked_session_get
+
state = "recovered"
expected_json_output = self.read_file_v1(state=state)
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- response = await self.asgi_client.get("/{}".format(state))
- return_data = response.json()
+ response = await self.asgi_client.get("/{}".format(state))
+ return_data = response.json()
assert return_data == json.loads(expected_json_output)
+ @mock.patch("app.services.location.jhu.datetime")
async def test_v1_all(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ self.mock_client_session.get = mocked_session_get
+
state = "all"
expected_json_output = self.read_file_v1(state=state)
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- response = await self.asgi_client.get("/{}".format(state))
- return_data = response.json()
+ response = await self.asgi_client.get("/{}".format(state))
+ return_data = response.json()
assert return_data == json.loads(expected_json_output)
+ @mock.patch("app.services.location.jhu.datetime")
async def test_v2_latest(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ self.mock_client_session.get = mocked_session_get
+
state = "latest"
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- response = await self.asgi_client.get(f"/v2/{state}")
- return_data = response.json()
+ response = await self.asgi_client.get(f"/v2/{state}")
+ return_data = response.json()
check_dict = {"latest": {"confirmed": 1940, "deaths": 1940, "recovered": 0}}
assert return_data == check_dict
+ @mock.patch("app.services.location.jhu.datetime")
async def test_v2_locations(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ self.mock_client_session.get = mocked_session_get
+
state = "locations"
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- response = await self.asgi_client.get("/v2/{}".format(state))
- return_data = response.json()
+ response = await self.asgi_client.get("/v2/{}".format(state))
+ return_data = response.json()
filepath = "tests/expected_output/v2_{state}.json".format(state=state)
with open(filepath, "r") as file:
@@ -118,16 +124,16 @@ async def test_v2_locations(self, mock_datetime):
# TODO: Why is this failing?
# assert return_data == json.loads(expected_json_output)
+ @mock.patch("app.services.location.jhu.datetime")
async def test_v2_locations_id(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ self.mock_client_session.get = mocked_session_get
state = "locations"
test_id = 1
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- response = await self.asgi_client.get("/v2/{}/{}".format(state, test_id))
- return_data = response.json()
+ response = await self.asgi_client.get("/v2/{}/{}".format(state, test_id))
+ return_data = response.json()
filepath = "tests/expected_output/v2_{state}_id_{test_id}.json".format(state=state, test_id=test_id)
with open(filepath, "r") as file:
@@ -151,10 +157,9 @@ async def test_v2_locations_id(self, mock_datetime):
({"source": "jhu", "country_code": "US"}, 404),
],
)
-async def test_locations_status_code(async_api_client, query_params, expected_status):
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- response = await async_api_client.get("/v2/locations", query_string=query_params)
+async def test_locations_status_code(async_api_client, query_params, expected_status, mock_client_session):
+ mock_client_session.get = mocked_session_get
+ response = await async_api_client.get("/v2/locations", query_string=query_params)
print(f"GET {response.url}\n{response}")
print(f"\tjson:\n{pf(response.json())[:1000]}\n\t...")
@@ -173,10 +178,9 @@ async def test_locations_status_code(async_api_client, query_params, expected_st
{"source": "jhu", "timelines": True},
],
)
-async def test_latest(async_api_client, query_params):
- async with mock_client_session() as mocked_client_session:
- mocked_client_session.get = mocked_session_get
- response = await async_api_client.get("/v2/latest", query_string=query_params)
+async def test_latest(async_api_client, query_params, mock_client_session):
+ mock_client_session.get = mocked_session_get
+ response = await async_api_client.get("/v2/latest", query_string=query_params)
print(f"GET {response.url}\n{response}")
From 990c82c866fc70bc343762031ca7658f10d977ed Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 12:42:17 +0200
Subject: [PATCH 14/61] Use mocked_session_get by default
One can still define a separate responder function here, but since this is the
only response defined for the tests thus far, this seems like a reasonable default.
---
tests/conftest.py | 2 ++
tests/test_csbs.py | 2 --
tests/test_jhu.py | 2 --
tests/test_routes.py | 12 ------------
4 files changed, 2 insertions(+), 16 deletions(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index 9fde87d9..3cab02f0 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -81,6 +81,7 @@ def mock_client_session_class(request):
"""
httputils.client_session = request.cls.mock_client_session = mock.AsyncMock()
+ httputils.client_session.get = mocked_session_get
try:
yield
finally:
@@ -94,6 +95,7 @@ async def mock_client_session():
"""
httputils.client_session = mock.AsyncMock()
+ httputils.client_session.get = mocked_session_get
try:
yield httputils.client_session
finally:
diff --git a/tests/test_csbs.py b/tests/test_csbs.py
index 912bdd11..828a5b65 100644
--- a/tests/test_csbs.py
+++ b/tests/test_csbs.py
@@ -1,7 +1,6 @@
import pytest
from app.services.location import csbs
-from tests.conftest import mocked_session_get
def mocked_csbs_requests_get(*args, **kwargs):
@@ -28,7 +27,6 @@ def read_file(self):
@pytest.mark.asyncio
async def test_get_locations(mock_client_session):
- mock_client_session.get = mocked_session_get
data = await csbs.get_locations()
assert isinstance(data, list)
diff --git a/tests/test_jhu.py b/tests/test_jhu.py
index 12a3f704..1244d6dd 100644
--- a/tests/test_jhu.py
+++ b/tests/test_jhu.py
@@ -4,7 +4,6 @@
from app import location
from app.services.location import jhu
-from tests.conftest import mocked_session_get
from tests.conftest import mocked_strptime_isoformat
DATETIME_STRING = "2020-03-17T10:23:22.505550"
@@ -16,7 +15,6 @@ async def test_get_locations(mock_datetime, mock_client_session):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
- mock_client_session.get = mocked_session_get
output = await jhu.get_locations()
assert isinstance(output, list)
diff --git a/tests/test_routes.py b/tests/test_routes.py
index 0f38c353..d88372b2 100644
--- a/tests/test_routes.py
+++ b/tests/test_routes.py
@@ -6,7 +6,6 @@
import pytest
from async_asgi_testclient import TestClient
-from .conftest import mocked_session_get
from .conftest import mocked_strptime_isoformat
from .test_jhu import DATETIME_STRING
from app.main import APP
@@ -34,8 +33,6 @@ def read_file_v1(self, state):
@mock.patch("app.services.location.jhu.datetime")
async def test_root_api(self, mock_datetime):
"""Validate that / returns a 200 and is not a redirect."""
- self.mock_client_session.get = mocked_session_get
-
response = await self.asgi_client.get("/")
assert response.status_code == 200
@@ -45,7 +42,6 @@ async def test_root_api(self, mock_datetime):
async def test_v1_confirmed(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
- self.mock_client_session.get = mocked_session_get
state = "confirmed"
expected_json_output = self.read_file_v1(state=state)
@@ -58,7 +54,6 @@ async def test_v1_confirmed(self, mock_datetime):
async def test_v1_deaths(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
- self.mock_client_session.get = mocked_session_get
state = "deaths"
expected_json_output = self.read_file_v1(state=state)
@@ -71,7 +66,6 @@ async def test_v1_deaths(self, mock_datetime):
async def test_v1_recovered(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
- self.mock_client_session.get = mocked_session_get
state = "recovered"
expected_json_output = self.read_file_v1(state=state)
@@ -84,7 +78,6 @@ async def test_v1_recovered(self, mock_datetime):
async def test_v1_all(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = self.date
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
- self.mock_client_session.get = mocked_session_get
state = "all"
expected_json_output = self.read_file_v1(state=state)
@@ -97,7 +90,6 @@ async def test_v1_all(self, mock_datetime):
async def test_v2_latest(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
- self.mock_client_session.get = mocked_session_get
state = "latest"
response = await self.asgi_client.get(f"/v2/{state}")
@@ -111,7 +103,6 @@ async def test_v2_latest(self, mock_datetime):
async def test_v2_locations(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
- self.mock_client_session.get = mocked_session_get
state = "locations"
response = await self.asgi_client.get("/v2/{}".format(state))
@@ -128,7 +119,6 @@ async def test_v2_locations(self, mock_datetime):
async def test_v2_locations_id(self, mock_datetime):
mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
mock_datetime.strptime.side_effect = mocked_strptime_isoformat
- self.mock_client_session.get = mocked_session_get
state = "locations"
test_id = 1
@@ -158,7 +148,6 @@ async def test_v2_locations_id(self, mock_datetime):
],
)
async def test_locations_status_code(async_api_client, query_params, expected_status, mock_client_session):
- mock_client_session.get = mocked_session_get
response = await async_api_client.get("/v2/locations", query_string=query_params)
print(f"GET {response.url}\n{response}")
@@ -179,7 +168,6 @@ async def test_locations_status_code(async_api_client, query_params, expected_st
],
)
async def test_latest(async_api_client, query_params, mock_client_session):
- mock_client_session.get = mocked_session_get
response = await async_api_client.get("/v2/latest", query_string=query_params)
print(f"GET {response.url}\n{response}")
From 6f231ce30c569ea2b0ed1f75304a5483329caae5 Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 12:58:16 +0200
Subject: [PATCH 15/61] Add test for ClientSession setup/teardown
---
tests/test_httputils.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tests/test_httputils.py b/tests/test_httputils.py
index e69de29b..b5742afa 100644
--- a/tests/test_httputils.py
+++ b/tests/test_httputils.py
@@ -0,0 +1,19 @@
+import pytest
+
+from app.utils import httputils
+
+
+@pytest.mark.asyncio
+async def test_setup_teardown_client_session():
+ with pytest.raises(AttributeError):
+ # Ensure client_session is undefined prior to setup
+ httputils.client_session
+
+ await httputils.setup_client_session()
+
+ assert httputils.client_session
+
+ await httputils.teardown_client_session()
+ assert httputils.client_session.closed
+
+ del httputils.client_session
From b25fe73dce75b575bc87fe31815580d0c76af9a4 Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 13:27:58 +0200
Subject: [PATCH 16/61] Update Pipfile.lock
---
Pipfile.lock | 128 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 124 insertions(+), 4 deletions(-)
diff --git a/Pipfile.lock b/Pipfile.lock
index 6d4da039..500275a9 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "6135cc5a7f50377967629ba129a9747170d933706e42b8b74e29a5d4713aa4e0"
+ "sha256": "71ab11be8ac956d1b6ebb10f6bbd7496331b749cfaf1f540536321c5ad328e40"
},
"pipfile-spec": 6,
"requires": {
@@ -16,6 +16,45 @@
]
},
"default": {
+ "aiohttp": {
+ "hashes": [
+ "sha256:1e984191d1ec186881ffaed4581092ba04f7c61582a177b187d3a2f07ed9719e",
+ "sha256:259ab809ff0727d0e834ac5e8a283dc5e3e0ecc30c4d80b3cd17a4139ce1f326",
+ "sha256:2f4d1a4fdce595c947162333353d4a44952a724fba9ca3205a3df99a33d1307a",
+ "sha256:32e5f3b7e511aa850829fbe5aa32eb455e5534eaa4b1ce93231d00e2f76e5654",
+ "sha256:344c780466b73095a72c616fac5ea9c4665add7fc129f285fbdbca3cccf4612a",
+ "sha256:460bd4237d2dbecc3b5ed57e122992f60188afe46e7319116da5eb8a9dfedba4",
+ "sha256:4c6efd824d44ae697814a2a85604d8e992b875462c6655da161ff18fd4f29f17",
+ "sha256:50aaad128e6ac62e7bf7bd1f0c0a24bc968a0c0590a726d5a955af193544bcec",
+ "sha256:6206a135d072f88da3e71cc501c59d5abffa9d0bb43269a6dcd28d66bfafdbdd",
+ "sha256:65f31b622af739a802ca6fd1a3076fd0ae523f8485c52924a89561ba10c49b48",
+ "sha256:ae55bac364c405caa23a4f2d6cfecc6a0daada500274ffca4a9230e7129eac59",
+ "sha256:b778ce0c909a2653741cb4b1ac7015b5c130ab9c897611df43ae6a58523cb965"
+ ],
+ "index": "pypi",
+ "version": "==3.6.2"
+ },
+ "async-timeout": {
+ "hashes": [
+ "sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f",
+ "sha256:4291ca197d287d274d0b6cb5d6f8f8f82d434ed288f962539ff18cc9012f9ea3"
+ ],
+ "version": "==3.0.1"
+ },
+ "asyncache": {
+ "hashes": [
+ "sha256:c741b3ccef2c5291b3da05d97bab3cc8d50f2ac8efd7fd79d47e3d7b6a3774de"
+ ],
+ "index": "pypi",
+ "version": "==0.1.1"
+ },
+ "attrs": {
+ "hashes": [
+ "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c",
+ "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"
+ ],
+ "version": "==19.3.0"
+ },
"cachetools": {
"hashes": [
"sha256:9a52dd97a85f257f4e4127f15818e71a0c7899f121b34591fcc1173ea79a0198",
@@ -47,11 +86,11 @@
},
"fastapi": {
"hashes": [
- "sha256:c2d572370153a6b74d62a73252d75934e2bfdbb0f620fecfd489b5d4789f5c48",
- "sha256:c478bc513d192f6776fd3f0355b7ff5414e94ed842677294c06e348105aaa237"
+ "sha256:a5cb9100d5f2b5dd82addbc2cdf8009258bce45b03ba21d3f5eecc88c7b5a716",
+ "sha256:cf26d47ede6bc6e179df951312f55fea7d4005dd53370245e216436ca4e22f22"
],
"index": "pypi",
- "version": "==0.53.1"
+ "version": "==0.53.2"
},
"gunicorn": {
"hashes": [
@@ -93,6 +132,28 @@
],
"version": "==2.9"
},
+ "multidict": {
+ "hashes": [
+ "sha256:317f96bc0950d249e96d8d29ab556d01dd38888fbe68324f46fd834b430169f1",
+ "sha256:42f56542166040b4474c0c608ed051732033cd821126493cf25b6c276df7dd35",
+ "sha256:4b7df040fb5fe826d689204f9b544af469593fb3ff3a069a6ad3409f742f5928",
+ "sha256:544fae9261232a97102e27a926019100a9db75bec7b37feedd74b3aa82f29969",
+ "sha256:620b37c3fea181dab09267cd5a84b0f23fa043beb8bc50d8474dd9694de1fa6e",
+ "sha256:6e6fef114741c4d7ca46da8449038ec8b1e880bbe68674c01ceeb1ac8a648e78",
+ "sha256:7774e9f6c9af3f12f296131453f7b81dabb7ebdb948483362f5afcaac8a826f1",
+ "sha256:85cb26c38c96f76b7ff38b86c9d560dea10cf3459bb5f4caf72fc1bb932c7136",
+ "sha256:a326f4240123a2ac66bb163eeba99578e9d63a8654a59f4688a79198f9aa10f8",
+ "sha256:ae402f43604e3b2bc41e8ea8b8526c7fa7139ed76b0d64fc48e28125925275b2",
+ "sha256:aee283c49601fa4c13adc64c09c978838a7e812f85377ae130a24d7198c0331e",
+ "sha256:b51249fdd2923739cd3efc95a3d6c363b67bbf779208e9f37fd5e68540d1a4d4",
+ "sha256:bb519becc46275c594410c6c28a8a0adc66fe24fef154a9addea54c1adb006f5",
+ "sha256:c2c37185fb0af79d5c117b8d2764f4321eeb12ba8c141a95d0aa8c2c1d0a11dd",
+ "sha256:dc561313279f9d05a3d0ffa89cd15ae477528ea37aa9795c4654588a3287a9ab",
+ "sha256:e439c9a10a95cb32abd708bb8be83b2134fa93790a4fb0535ca36db3dda94d20",
+ "sha256:fc3b4adc2ee8474cb3cd2a155305d5f8eda0a9c91320f83e55748e1fcb68f8e3"
+ ],
+ "version": "==4.7.5"
+ },
"pydantic": {
"hashes": [
"sha256:012c422859bac2e03ab3151ea6624fecf0e249486be7eb8c6ee69c91740c6752",
@@ -206,6 +267,28 @@
"sha256:f8a7bff6e8664afc4e6c28b983845c5bc14965030e3fb98789734d416af77c4b"
],
"version": "==8.1"
+ },
+ "yarl": {
+ "hashes": [
+ "sha256:0c2ab325d33f1b824734b3ef51d4d54a54e0e7a23d13b86974507602334c2cce",
+ "sha256:0ca2f395591bbd85ddd50a82eb1fde9c1066fafe888c5c7cc1d810cf03fd3cc6",
+ "sha256:2098a4b4b9d75ee352807a95cdf5f10180db903bc5b7270715c6bbe2551f64ce",
+ "sha256:25e66e5e2007c7a39541ca13b559cd8ebc2ad8fe00ea94a2aad28a9b1e44e5ae",
+ "sha256:26d7c90cb04dee1665282a5d1a998defc1a9e012fdca0f33396f81508f49696d",
+ "sha256:308b98b0c8cd1dfef1a0311dc5e38ae8f9b58349226aa0533f15a16717ad702f",
+ "sha256:3ce3d4f7c6b69c4e4f0704b32eca8123b9c58ae91af740481aa57d7857b5e41b",
+ "sha256:58cd9c469eced558cd81aa3f484b2924e8897049e06889e8ff2510435b7ef74b",
+ "sha256:5b10eb0e7f044cf0b035112446b26a3a2946bca9d7d7edb5e54a2ad2f6652abb",
+ "sha256:6faa19d3824c21bcbfdfce5171e193c8b4ddafdf0ac3f129ccf0cdfcb083e462",
+ "sha256:944494be42fa630134bf907714d40207e646fd5a94423c90d5b514f7b0713fea",
+ "sha256:a161de7e50224e8e3de6e184707476b5a989037dcb24292b391a3d66ff158e70",
+ "sha256:a4844ebb2be14768f7994f2017f70aca39d658a96c786211be5ddbe1c68794c1",
+ "sha256:c2b509ac3d4b988ae8769901c66345425e361d518aecbe4acbfc2567e416626a",
+ "sha256:c9959d49a77b0e07559e579f38b2f3711c2b8716b8410b320bf9713013215a1b",
+ "sha256:d8cdee92bc930d8b09d8bd2043cedd544d9c8bd7436a77678dd602467a993080",
+ "sha256:e15199cdb423316e15f108f51249e44eb156ae5dba232cb73be555324a1d49c2"
+ ],
+ "version": "==1.4.2"
}
},
"develop": {
@@ -223,6 +306,13 @@
],
"version": "==2.3.3"
},
+ "async-asgi-testclient": {
+ "hashes": [
+ "sha256:e961c61123eca6dc30c4f67df7fe8a3f695ca9c8b013d97272b930d6d5af4509"
+ ],
+ "index": "pypi",
+ "version": "==1.4.4"
+ },
"attrs": {
"hashes": [
"sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c",
@@ -395,6 +485,28 @@
],
"version": "==8.2.0"
},
+ "multidict": {
+ "hashes": [
+ "sha256:317f96bc0950d249e96d8d29ab556d01dd38888fbe68324f46fd834b430169f1",
+ "sha256:42f56542166040b4474c0c608ed051732033cd821126493cf25b6c276df7dd35",
+ "sha256:4b7df040fb5fe826d689204f9b544af469593fb3ff3a069a6ad3409f742f5928",
+ "sha256:544fae9261232a97102e27a926019100a9db75bec7b37feedd74b3aa82f29969",
+ "sha256:620b37c3fea181dab09267cd5a84b0f23fa043beb8bc50d8474dd9694de1fa6e",
+ "sha256:6e6fef114741c4d7ca46da8449038ec8b1e880bbe68674c01ceeb1ac8a648e78",
+ "sha256:7774e9f6c9af3f12f296131453f7b81dabb7ebdb948483362f5afcaac8a826f1",
+ "sha256:85cb26c38c96f76b7ff38b86c9d560dea10cf3459bb5f4caf72fc1bb932c7136",
+ "sha256:a326f4240123a2ac66bb163eeba99578e9d63a8654a59f4688a79198f9aa10f8",
+ "sha256:ae402f43604e3b2bc41e8ea8b8526c7fa7139ed76b0d64fc48e28125925275b2",
+ "sha256:aee283c49601fa4c13adc64c09c978838a7e812f85377ae130a24d7198c0331e",
+ "sha256:b51249fdd2923739cd3efc95a3d6c363b67bbf779208e9f37fd5e68540d1a4d4",
+ "sha256:bb519becc46275c594410c6c28a8a0adc66fe24fef154a9addea54c1adb006f5",
+ "sha256:c2c37185fb0af79d5c117b8d2764f4321eeb12ba8c141a95d0aa8c2c1d0a11dd",
+ "sha256:dc561313279f9d05a3d0ffa89cd15ae477528ea37aa9795c4654588a3287a9ab",
+ "sha256:e439c9a10a95cb32abd708bb8be83b2134fa93790a4fb0535ca36db3dda94d20",
+ "sha256:fc3b4adc2ee8474cb3cd2a155305d5f8eda0a9c91320f83e55748e1fcb68f8e3"
+ ],
+ "version": "==4.7.5"
+ },
"packaging": {
"hashes": [
"sha256:3c292b474fda1671ec57d46d739d072bfd495a4f51ad01a055121d81e952b7a3",
@@ -453,6 +565,14 @@
"index": "pypi",
"version": "==5.4.1"
},
+ "pytest-asyncio": {
+ "hashes": [
+ "sha256:9fac5100fd716cbecf6ef89233e8590a4ad61d729d1732e0a96b84182df1daaf",
+ "sha256:d734718e25cfc32d2bf78d346e99d33724deeba774cc4afdf491530c6184b63b"
+ ],
+ "index": "pypi",
+ "version": "==0.10.0"
+ },
"pytest-cov": {
"hashes": [
"sha256:cc6742d8bac45070217169f5f72ceee1e0e55b0221f54bcf24845972d3a47f2b",
From 77100b0d9039b3baeaabac5394ca755f34bdaa81 Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 14:42:27 +0200
Subject: [PATCH 17/61] Fix linter warnings
---
app/router/v1/confirmed.py | 4 ++--
app/router/v1/deaths.py | 4 ++--
app/router/v1/recovered.py | 4 ++--
app/services/location/csbs.py | 2 +-
app/services/location/jhu.py | 2 +-
app/utils/httputils.py | 11 ++++++-----
tests/conftest.py | 14 +++++++-------
tests/test_httputils.py | 8 ++++----
8 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/app/router/v1/confirmed.py b/app/router/v1/confirmed.py
index eda7702e..13365e32 100644
--- a/app/router/v1/confirmed.py
+++ b/app/router/v1/confirmed.py
@@ -6,6 +6,6 @@
@V1.get("/confirmed")
async def confirmed():
"""Confirmed cases."""
- confirmed = await get_category("confirmed")
+ confirmed_data = await get_category("confirmed")
- return confirmed
+ return confirmed_data
diff --git a/app/router/v1/deaths.py b/app/router/v1/deaths.py
index d41d1d9d..fb45498c 100644
--- a/app/router/v1/deaths.py
+++ b/app/router/v1/deaths.py
@@ -6,6 +6,6 @@
@V1.get("/deaths")
async def deaths():
"""Total deaths."""
- deaths = await get_category("deaths")
+ deaths_data = await get_category("deaths")
- return deaths
+ return deaths_data
diff --git a/app/router/v1/recovered.py b/app/router/v1/recovered.py
index 24fcb4fd..3a3a85b7 100644
--- a/app/router/v1/recovered.py
+++ b/app/router/v1/recovered.py
@@ -6,6 +6,6 @@
@V1.get("/recovered")
async def recovered():
"""Recovered cases."""
- recovered = await get_category("recovered")
+ recovered_data = await get_category("recovered")
- return recovered
+ return recovered_data
diff --git a/app/services/location/csbs.py b/app/services/location/csbs.py
index 95f1c4b2..dbd8d82d 100644
--- a/app/services/location/csbs.py
+++ b/app/services/location/csbs.py
@@ -39,7 +39,7 @@ async def get_locations():
:returns: The locations.
:rtype: dict
"""
- async with httputils.client_session.get(BASE_URL) as response:
+ async with httputils.CLIENT_SESSION.get(BASE_URL) as response:
text = await response.text()
data = list(csv.DictReader(text.splitlines()))
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index adee6bdc..316de367 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -55,7 +55,7 @@ async def get_category(category):
url = BASE_URL + "time_series_covid19_%s_global.csv" % category
# Request the data
- async with httputils.client_session.get(url) as response:
+ async with httputils.CLIENT_SESSION.get(url) as response:
text = await response.text()
# Parse the CSV.
diff --git a/app/utils/httputils.py b/app/utils/httputils.py
index de5d5b17..191bba87 100644
--- a/app/utils/httputils.py
+++ b/app/utils/httputils.py
@@ -1,10 +1,11 @@
+"""app.utils.httputils.py"""
import logging
from aiohttp import ClientSession
# Singleton aiohttp.ClientSession instance.
-client_session: ClientSession
+CLIENT_SESSION: ClientSession
LOGGER = logging.getLogger(__name__)
@@ -17,14 +18,14 @@ async def setup_client_session():
See: https://docs.aiohttp.org/en/stable/client_quickstart.html#make-a-request
"""
- global client_session
+ global CLIENT_SESSION # pylint: disable=global-statement
LOGGER.info("Setting up global aiohttp.ClientSession.")
- client_session = ClientSession()
+ CLIENT_SESSION = ClientSession()
async def teardown_client_session():
"""Close the application-global aiohttp.ClientSession.
"""
- global client_session
+ global CLIENT_SESSION # pylint: disable=global-statement
LOGGER.info("Closing global aiohttp.ClientSession.")
- await client_session.close()
+ await CLIENT_SESSION.close()
diff --git a/tests/conftest.py b/tests/conftest.py
index 3cab02f0..fe58a6b9 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -80,12 +80,12 @@ def mock_client_session_class(request):
See: https://docs.pytest.org/en/5.4.1/unittest.html#mixing-pytest-fixtures-into-unittest-testcase-subclasses-using-marks
"""
- httputils.client_session = request.cls.mock_client_session = mock.AsyncMock()
- httputils.client_session.get = mocked_session_get
+ httputils.CLIENT_SESSION = request.cls.mock_client_session = mock.AsyncMock()
+ httputils.CLIENT_SESSION.get = mocked_session_get
try:
yield
finally:
- del httputils.client_session
+ del httputils.CLIENT_SESSION
@pytest.fixture
@@ -94,12 +94,12 @@ async def mock_client_session():
instance.
"""
- httputils.client_session = mock.AsyncMock()
- httputils.client_session.get = mocked_session_get
+ httputils.CLIENT_SESSION = mock.AsyncMock()
+ httputils.CLIENT_SESSION.get = mocked_session_get
try:
- yield httputils.client_session
+ yield httputils.CLIENT_SESSION
finally:
- del httputils.client_session
+ del httputils.CLIENT_SESSION
@asynccontextmanager
diff --git a/tests/test_httputils.py b/tests/test_httputils.py
index b5742afa..547f3725 100644
--- a/tests/test_httputils.py
+++ b/tests/test_httputils.py
@@ -7,13 +7,13 @@
async def test_setup_teardown_client_session():
with pytest.raises(AttributeError):
# Ensure client_session is undefined prior to setup
- httputils.client_session
+ httputils.CLIENT_SESSION
await httputils.setup_client_session()
- assert httputils.client_session
+ assert httputils.CLIENT_SESSION
await httputils.teardown_client_session()
- assert httputils.client_session.closed
+ assert httputils.CLIENT_SESSION.closed
- del httputils.client_session
+ del httputils.CLIENT_SESSION
From f9b0ce1e24232695132d0a32de3ed6e5962ca61a Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 14:42:41 +0200
Subject: [PATCH 18/61] Black formatting
---
app/utils/httputils.py | 1 -
tests/test_routes.py | 3 ++-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/utils/httputils.py b/app/utils/httputils.py
index 191bba87..a0793170 100644
--- a/app/utils/httputils.py
+++ b/app/utils/httputils.py
@@ -3,7 +3,6 @@
from aiohttp import ClientSession
-
# Singleton aiohttp.ClientSession instance.
CLIENT_SESSION: ClientSession
diff --git a/tests/test_routes.py b/tests/test_routes.py
index d88372b2..540372ea 100644
--- a/tests/test_routes.py
+++ b/tests/test_routes.py
@@ -6,9 +6,10 @@
import pytest
from async_asgi_testclient import TestClient
+from app.main import APP
+
from .conftest import mocked_strptime_isoformat
from .test_jhu import DATETIME_STRING
-from app.main import APP
@pytest.mark.usefixtures("mock_client_session_class")
From 99ea07e8a5fba816fe8afa1d2e4c21b94d4f067b Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 15:30:55 +0200
Subject: [PATCH 19/61] Fallback to pypi-provided backports for async test
utils
---
Pipfile | 2 ++
Pipfile.lock | 25 ++++++++++++++++++++++++-
app/services/location/csbs.py | 1 +
app/services/location/jhu.py | 1 +
tests/conftest.py | 22 +++++++++++++++++-----
5 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/Pipfile b/Pipfile
index d5097194..be7444e3 100644
--- a/Pipfile
+++ b/Pipfile
@@ -5,6 +5,8 @@ verify_ssl = true
[dev-packages]
async-asgi-testclient = "*"
+async_generator = "*"
+asyncmock = "*"
bandit = "*"
black = "==19.10b0"
coveralls = "*"
diff --git a/Pipfile.lock b/Pipfile.lock
index 500275a9..8b71e7cd 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "71ab11be8ac956d1b6ebb10f6bbd7496331b749cfaf1f540536321c5ad328e40"
+ "sha256": "72d35102ae55e8201c5f3f950096e40b4ff279fcb9c5a009f1e25f8778f83808"
},
"pipfile-spec": 6,
"requires": {
@@ -313,6 +313,22 @@
"index": "pypi",
"version": "==1.4.4"
},
+ "async-generator": {
+ "hashes": [
+ "sha256:01c7bf666359b4967d2cda0000cc2e4af16a0ae098cbffcb8472fb9e8ad6585b",
+ "sha256:6ebb3d106c12920aaae42ccb6f787ef5eefdcdd166ea3d628fa8476abe712144"
+ ],
+ "index": "pypi",
+ "version": "==1.10"
+ },
+ "asyncmock": {
+ "hashes": [
+ "sha256:c251889d542e98fe5f7ece2b5b8643b7d62b50a5657d34a4cbce8a1d5170d750",
+ "sha256:fd8bc4e7813251a8959d1140924ccba3adbbc7af885dba7047c67f73c0b664b1"
+ ],
+ "index": "pypi",
+ "version": "==0.4.2"
+ },
"attrs": {
"hashes": [
"sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c",
@@ -478,6 +494,13 @@
],
"version": "==0.6.1"
},
+ "mock": {
+ "hashes": [
+ "sha256:3f9b2c0196c60d21838f307f5825a7b86b678cedc58ab9e50a8988187b4d81e0",
+ "sha256:dd33eb70232b6118298d516bbcecd26704689c386594f0f3c4f13867b2c56f72"
+ ],
+ "version": "==4.0.2"
+ },
"more-itertools": {
"hashes": [
"sha256:5dd8bcf33e5f9513ffa06d5ad33d78f31e1931ac9a18f33d37e77a180d393a7c",
diff --git a/app/services/location/csbs.py b/app/services/location/csbs.py
index dbd8d82d..8487c387 100644
--- a/app/services/location/csbs.py
+++ b/app/services/location/csbs.py
@@ -3,6 +3,7 @@
from datetime import datetime
from asyncache import cached
+
from cachetools import TTLCache
from ...coordinates import Coordinates
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index 316de367..269292ab 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -3,6 +3,7 @@
from datetime import datetime
from asyncache import cached
+
from cachetools import TTLCache
from ...coordinates import Coordinates
diff --git a/tests/conftest.py b/tests/conftest.py
index fe58a6b9..99ce7b96 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -5,15 +5,27 @@
"""
import datetime
import os
-from contextlib import asynccontextmanager
-from unittest import mock
import pytest
from async_asgi_testclient import TestClient as AsyncTestClient
-from fastapi.testclient import TestClient
from app.main import APP
from app.utils import httputils
+from fastapi.testclient import TestClient
+
+try:
+ from unittest.mock import AsyncMock
+except ImportError:
+ # Python 3.7 backwards compat
+ from asyncmock import AsyncMock
+
+try:
+ from contextlib import asynccontextmanager
+except ImportError:
+ # Python 3.6 backwards compat
+ from async_generator import asynccontextmanager
+
+
@pytest.fixture
@@ -80,7 +92,7 @@ def mock_client_session_class(request):
See: https://docs.pytest.org/en/5.4.1/unittest.html#mixing-pytest-fixtures-into-unittest-testcase-subclasses-using-marks
"""
- httputils.CLIENT_SESSION = request.cls.mock_client_session = mock.AsyncMock()
+ httputils.CLIENT_SESSION = request.cls.mock_client_session = AsyncMock()
httputils.CLIENT_SESSION.get = mocked_session_get
try:
yield
@@ -94,7 +106,7 @@ async def mock_client_session():
instance.
"""
- httputils.CLIENT_SESSION = mock.AsyncMock()
+ httputils.CLIENT_SESSION = AsyncMock()
httputils.CLIENT_SESSION.get = mocked_session_get
try:
yield httputils.CLIENT_SESSION
From 71e2190021b680d4e80bac29ae963348ee44b2d2 Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 16:11:44 +0200
Subject: [PATCH 20/61] Avoid mock.patch decorators
Using these as decorators causes a lot of problems when combined with Pytest fixtures, often resulting in the mock not applying.
---
tests/test_jhu.py | 11 +++--
tests/test_routes.py | 100 +++++++++++++++++++++----------------------
2 files changed, 55 insertions(+), 56 deletions(-)
diff --git a/tests/test_jhu.py b/tests/test_jhu.py
index 1244d6dd..3790218d 100644
--- a/tests/test_jhu.py
+++ b/tests/test_jhu.py
@@ -10,12 +10,11 @@
@pytest.mark.asyncio
-@mock.patch("app.services.location.jhu.datetime")
-async def test_get_locations(mock_datetime, mock_client_session):
- mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
- mock_datetime.strptime.side_effect = mocked_strptime_isoformat
-
- output = await jhu.get_locations()
+async def test_get_locations(mock_client_session):
+ with mock.patch("app.services.location.jhu.datetime") as mock_datetime:
+ mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
+ mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ output = await jhu.get_locations()
assert isinstance(output, list)
assert isinstance(output[0], location.Location)
diff --git a/tests/test_routes.py b/tests/test_routes.py
index 540372ea..605ce2c0 100644
--- a/tests/test_routes.py
+++ b/tests/test_routes.py
@@ -31,82 +31,81 @@ def read_file_v1(self, state):
expected_json_output = file.read()
return expected_json_output
- @mock.patch("app.services.location.jhu.datetime")
- async def test_root_api(self, mock_datetime):
+ async def test_root_api(self):
"""Validate that / returns a 200 and is not a redirect."""
response = await self.asgi_client.get("/")
assert response.status_code == 200
assert not response.is_redirect
- @mock.patch("app.services.location.jhu.datetime")
- async def test_v1_confirmed(self, mock_datetime):
- mock_datetime.utcnow.return_value.isoformat.return_value = self.date
- mock_datetime.strptime.side_effect = mocked_strptime_isoformat
-
+ async def test_v1_confirmed(self):
state = "confirmed"
expected_json_output = self.read_file_v1(state=state)
- response = await self.asgi_client.get("/{}".format(state))
- return_data = response.json()
- assert return_data == json.loads(expected_json_output)
+ with mock.patch("app.services.location.jhu.datetime") as mock_datetime:
+ mock_datetime.utcnow.return_value.isoformat.return_value = self.date
+ mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ response = await self.asgi_client.get("/{}".format(state))
- @mock.patch("app.services.location.jhu.datetime")
- async def test_v1_deaths(self, mock_datetime):
- mock_datetime.utcnow.return_value.isoformat.return_value = self.date
- mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ return_data = response.json()
+ assert return_data == json.loads(expected_json_output)
+ async def test_v1_deaths(self):
state = "deaths"
expected_json_output = self.read_file_v1(state=state)
- response = await self.asgi_client.get("/{}".format(state))
- return_data = response.json()
- assert return_data == json.loads(expected_json_output)
+ with mock.patch("app.services.location.jhu.datetime") as mock_datetime:
+ mock_datetime.utcnow.return_value.isoformat.return_value = self.date
+ mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ response = await self.asgi_client.get("/{}".format(state))
- @mock.patch("app.services.location.jhu.datetime")
- async def test_v1_recovered(self, mock_datetime):
- mock_datetime.utcnow.return_value.isoformat.return_value = self.date
- mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ return_data = response.json()
+ assert return_data == json.loads(expected_json_output)
+ async def test_v1_recovered(self):
state = "recovered"
expected_json_output = self.read_file_v1(state=state)
- response = await self.asgi_client.get("/{}".format(state))
- return_data = response.json()
- assert return_data == json.loads(expected_json_output)
+ with mock.patch("app.services.location.jhu.datetime") as mock_datetime:
+ mock_datetime.utcnow.return_value.isoformat.return_value = self.date
+ mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ response = await self.asgi_client.get("/{}".format(state))
- @mock.patch("app.services.location.jhu.datetime")
- async def test_v1_all(self, mock_datetime):
- mock_datetime.utcnow.return_value.isoformat.return_value = self.date
- mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ return_data = response.json()
+ assert return_data == json.loads(expected_json_output)
+ async def test_v1_all(self):
state = "all"
expected_json_output = self.read_file_v1(state=state)
- response = await self.asgi_client.get("/{}".format(state))
- return_data = response.json()
- assert return_data == json.loads(expected_json_output)
+ with mock.patch("app.services.location.jhu.datetime") as mock_datetime:
+ mock_datetime.utcnow.return_value.isoformat.return_value = self.date
+ mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ response = await self.asgi_client.get("/{}".format(state))
- @mock.patch("app.services.location.jhu.datetime")
- async def test_v2_latest(self, mock_datetime):
- mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
- mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ return_data = response.json()
+ assert return_data == json.loads(expected_json_output)
+ async def test_v2_latest(self):
state = "latest"
- response = await self.asgi_client.get(f"/v2/{state}")
- return_data = response.json()
- check_dict = {"latest": {"confirmed": 1940, "deaths": 1940, "recovered": 0}}
+ with mock.patch("app.services.location.jhu.datetime") as mock_datetime:
+ mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
+ mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ response = await self.asgi_client.get(f"/v2/{state}")
+ return_data = response.json()
+ check_dict = {"latest": {"confirmed": 1940, "deaths": 1940, "recovered": 0}}
assert return_data == check_dict
- @mock.patch("app.services.location.jhu.datetime")
- async def test_v2_locations(self, mock_datetime):
- mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
- mock_datetime.strptime.side_effect = mocked_strptime_isoformat
-
+ async def test_v2_locations(self):
state = "locations"
- response = await self.asgi_client.get("/v2/{}".format(state))
+
+ with mock.patch("app.services.location.jhu.datetime") as mock_datetime:
+ mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
+ mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ response = await self.asgi_client.get("/v2/{}".format(state))
+
return_data = response.json()
filepath = "tests/expected_output/v2_{state}.json".format(state=state)
@@ -116,14 +115,15 @@ async def test_v2_locations(self, mock_datetime):
# TODO: Why is this failing?
# assert return_data == json.loads(expected_json_output)
- @mock.patch("app.services.location.jhu.datetime")
- async def test_v2_locations_id(self, mock_datetime):
- mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
- mock_datetime.strptime.side_effect = mocked_strptime_isoformat
-
+ async def test_v2_locations_id(self):
state = "locations"
test_id = 1
- response = await self.asgi_client.get("/v2/{}/{}".format(state, test_id))
+
+ with mock.patch("app.services.location.jhu.datetime") as mock_datetime:
+ mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
+ mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ response = await self.asgi_client.get("/v2/{}/{}".format(state, test_id))
+
return_data = response.json()
filepath = "tests/expected_output/v2_{state}_id_{test_id}.json".format(state=state, test_id=test_id)
From 90394da019aa162d6f82feac477ab41ea4788447 Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 16:12:34 +0200
Subject: [PATCH 21/61] Run formatter
---
app/services/location/csbs.py | 1 -
app/services/location/jhu.py | 1 -
tests/conftest.py | 4 +---
3 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/app/services/location/csbs.py b/app/services/location/csbs.py
index 8487c387..dbd8d82d 100644
--- a/app/services/location/csbs.py
+++ b/app/services/location/csbs.py
@@ -3,7 +3,6 @@
from datetime import datetime
from asyncache import cached
-
from cachetools import TTLCache
from ...coordinates import Coordinates
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index 269292ab..316de367 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -3,7 +3,6 @@
from datetime import datetime
from asyncache import cached
-
from cachetools import TTLCache
from ...coordinates import Coordinates
diff --git a/tests/conftest.py b/tests/conftest.py
index 99ce7b96..b6399fec 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -8,10 +8,10 @@
import pytest
from async_asgi_testclient import TestClient as AsyncTestClient
+from fastapi.testclient import TestClient
from app.main import APP
from app.utils import httputils
-from fastapi.testclient import TestClient
try:
from unittest.mock import AsyncMock
@@ -26,8 +26,6 @@
from async_generator import asynccontextmanager
-
-
@pytest.fixture
def api_client():
"""
From 4d9b8487db33e82931c7e1a6e4add647f97fbb24 Mon Sep 17 00:00:00 2001
From: james-gray
Date: Thu, 2 Apr 2020 16:14:47 +0200
Subject: [PATCH 22/61] Add missing dependency
---
Pipfile | 3 +++
Pipfile.lock | 32 +++++++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/Pipfile b/Pipfile
index be7444e3..0db88935 100644
--- a/Pipfile
+++ b/Pipfile
@@ -10,6 +10,7 @@ asyncmock = "*"
bandit = "*"
black = "==19.10b0"
coveralls = "*"
+importlib-metadata = "*"
invoke = "*"
isort = "*"
pylint = "*"
@@ -21,8 +22,10 @@ pytest-cov = "*"
aiohttp = "*"
asyncache = "*"
cachetools = "*"
+dataclasses = "*"
fastapi = "*"
gunicorn = "*"
+idna_ssl = "*"
python-dateutil = "*"
python-dotenv = "*"
requests = "*"
diff --git a/Pipfile.lock b/Pipfile.lock
index 8b71e7cd..7915caf7 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "72d35102ae55e8201c5f3f950096e40b4ff279fcb9c5a009f1e25f8778f83808"
+ "sha256": "fbd18d0bdfc45ec9e02a2f72483d8c0289f0226e87883ee6da7ed75f4f4800a9"
},
"pipfile-spec": 6,
"requires": {
@@ -84,6 +84,14 @@
],
"version": "==7.1.1"
},
+ "dataclasses": {
+ "hashes": [
+ "sha256:454a69d788c7fda44efd71e259be79577822f5e3f53f029a22d08004e951dc9f",
+ "sha256:6988bd2b895eef432d562370bb707d540f32f7360ab13da45340101bc2307d84"
+ ],
+ "index": "pypi",
+ "version": "==0.6"
+ },
"fastapi": {
"hashes": [
"sha256:a5cb9100d5f2b5dd82addbc2cdf8009258bce45b03ba21d3f5eecc88c7b5a716",
@@ -132,6 +140,13 @@
],
"version": "==2.9"
},
+ "idna-ssl": {
+ "hashes": [
+ "sha256:a933e3bb13da54383f9e8f35dc4f9cb9eb9b3b78c6b36f311254d6d0d92c6c7c"
+ ],
+ "index": "pypi",
+ "version": "==1.1.0"
+ },
"multidict": {
"hashes": [
"sha256:317f96bc0950d249e96d8d29ab556d01dd38888fbe68324f46fd834b430169f1",
@@ -444,6 +459,14 @@
],
"version": "==2.9"
},
+ "importlib-metadata": {
+ "hashes": [
+ "sha256:2a688cbaa90e0cc587f1df48bdc97a6eadccdcd9c35fb3f976a09e3b5016d90f",
+ "sha256:34513a8a0c4962bc66d35b359558fd8a5e10cd472d37aec5f66858addef32c1e"
+ ],
+ "index": "pypi",
+ "version": "==1.6.0"
+ },
"invoke": {
"hashes": [
"sha256:87b3ef9d72a1667e104f89b159eaf8a514dbf2f3576885b2bbdefe74c3fb2132",
@@ -727,6 +750,13 @@
"sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1"
],
"version": "==1.11.2"
+ },
+ "zipp": {
+ "hashes": [
+ "sha256:aa36550ff0c0b7ef7fa639055d797116ee891440eac1a56f378e2d3179e0320b",
+ "sha256:c599e4d75c98f6798c509911d08a22e6c021d074469042177c8c86fb92eefd96"
+ ],
+ "version": "==3.1.0"
}
}
}
From c1880583a3496a88083a85d6d23c56d9611cf053 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Thu, 2 Apr 2020 22:00:48 -0400
Subject: [PATCH 23/61] add markers to backports
---
Pipfile | 6 +++---
Pipfile.lock | 5 ++++-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/Pipfile b/Pipfile
index 0db88935..b337c22a 100644
--- a/Pipfile
+++ b/Pipfile
@@ -10,7 +10,7 @@ asyncmock = "*"
bandit = "*"
black = "==19.10b0"
coveralls = "*"
-importlib-metadata = "*"
+importlib-metadata = {version="*", markers="python_version<'3.8'"}
invoke = "*"
isort = "*"
pylint = "*"
@@ -22,10 +22,10 @@ pytest-cov = "*"
aiohttp = "*"
asyncache = "*"
cachetools = "*"
-dataclasses = "*"
+dataclasses = {version="*", markers="python_version<'3.7'"}
fastapi = "*"
gunicorn = "*"
-idna_ssl = "*"
+idna_ssl = {version="*", markers="python_version<'3.7'"}
python-dateutil = "*"
python-dotenv = "*"
requests = "*"
diff --git a/Pipfile.lock b/Pipfile.lock
index 7915caf7..a699f880 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "fbd18d0bdfc45ec9e02a2f72483d8c0289f0226e87883ee6da7ed75f4f4800a9"
+ "sha256": "1911b081cecdda482b2a9c7c03ebba985c447846506b607df01563600c23126b"
},
"pipfile-spec": 6,
"requires": {
@@ -90,6 +90,7 @@
"sha256:6988bd2b895eef432d562370bb707d540f32f7360ab13da45340101bc2307d84"
],
"index": "pypi",
+ "markers": "python_version < '3.7'",
"version": "==0.6"
},
"fastapi": {
@@ -145,6 +146,7 @@
"sha256:a933e3bb13da54383f9e8f35dc4f9cb9eb9b3b78c6b36f311254d6d0d92c6c7c"
],
"index": "pypi",
+ "markers": "python_version < '3.7'",
"version": "==1.1.0"
},
"multidict": {
@@ -465,6 +467,7 @@
"sha256:34513a8a0c4962bc66d35b359558fd8a5e10cd472d37aec5f66858addef32c1e"
],
"index": "pypi",
+ "markers": "python_version < '3.8'",
"version": "==1.6.0"
},
"invoke": {
From 1f205f4cb44d14366259941ba95ead5112e22577 Mon Sep 17 00:00:00 2001
From: GRIBOK <40306040+gribok@users.noreply.github.com>
Date: Fri, 3 Apr 2020 23:27:28 +0200
Subject: [PATCH 24/61] Add requirements.txt files (#245)
* Add requirements.txt files ExpDev07/coronavirus-tracker-api#244
* Add testcases to validate requirements.txt
* update reqs and contrib guide
* fix formatting for edit files
---
CONTRIBUTING.md | 1 +
README.md | 18 +++++++++++-----
requirements-dev.txt | 48 +++++++++++++++++++++++++++++++++++++++++
requirements.txt | 28 ++++++++++++++++++++++++
tasks.py | 7 ++++++
tests/test_cli.py | 51 ++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 148 insertions(+), 5 deletions(-)
create mode 100644 requirements-dev.txt
create mode 100644 requirements.txt
create mode 100644 tests/test_cli.py
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1fde2f33..4ecdd0b6 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -13,6 +13,7 @@ Please write new test cases for new code you create.
* If you're unable to find an open issue, [open a new one](https://github.com/ExpDev07/coronavirus-tracker-api/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible
* Open a new [GitHub Pull Request to coronavirus-tracker-api](https://github.com/ExpDev07/coronavirus-tracker-api/pulls) with a clear list of what you've done (read more about [pull requests](http://help.github.com/pull-requests/)). Include the relevant issue number if applicable.
* We will love you forever if you include unit tests. We can always use more test coverage
+* If you have updated [Pipefile](./Pipfile), you have to update `Pipfile.lock`, `requirements.txt` and `requirements-dev.txt`. See section [Update requirements files](./README.md#update-requirements-files).
## Your First Code Contribution
diff --git a/README.md b/README.md
index 8fb2e962..cf8be2c3 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ Support multiple data-sources.
Currently 2 different data-sources are available to retrieve the data:
-* **jhu** - https://github.com/CSSEGISandData/COVID-19 - Worldwide Data repository operated by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE).
+* **jhu** - https://github.com/CSSEGISandData/COVID-19 - Worldwide Data repository operated by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE).
* **csbs** - https://www.csbs.org/information-covid-19-coronavirus - U.S. County data that comes from the Conference of State Bank Supervisors.
@@ -40,7 +40,7 @@ __jhu__ data-source will be used as a default source if you don't specify a *sou
## API Reference
-All endpoints are located at ``coronavirus-tracker-api.herokuapp.com/v2/`` and are accessible via https. For instance: you can get data per location by using this URL:
+All endpoints are located at ``coronavirus-tracker-api.herokuapp.com/v2/`` and are accessible via https. For instance: you can get data per location by using this URL:
*[https://coronavirus-tracker-api.herokuapp.com/v2/locations](https://coronavirus-tracker-api.herokuapp.com/v2/locations)*
You can open the URL in your browser to further inspect the response. Or you can make this curl call in your terminal to see the prettified response:
@@ -56,7 +56,7 @@ Consume our API through [our super awesome and interactive SwaggerUI](https://co
The [OpenAPI](https://swagger.io/docs/specification/about/) json definition can be downloaded at https://coronavirus-tracker-api.herokuapp.com/openapi.json
-## API Endpoints
+## API Endpoints
### Sources Endpoint
@@ -365,7 +365,7 @@ These are the available API wrappers created by the community. They are not nece
### C#
-* [CovidSharp by @Abdirahiim](https://github.com/Abdirahiim/covidtrackerapiwrapper)
+* [CovidSharp by @Abdirahiim](https://github.com/Abdirahiim/covidtrackerapiwrapper)
* [Covid19Tracker.NET by @egbakou](https://github.com/egbakou/Covid19Tracker.NET)
### Python
@@ -408,7 +408,7 @@ You will need the following things properly installed on your computer.
3. Create virtual environment and install all dependencies `$ pipenv sync --dev`
4. Activate/enter the virtual environment `$ pipenv shell`
-And don't despair if don't get the python setup working on the first try. No one did. Guido got pretty close... once. But that's another story. Good luck.
+And don't despair if don't get the python setup working on the first try. No one did. Guido got pretty close... once. But that's another story. Good luck.
## Running / Development
@@ -437,6 +437,14 @@ pipenv run lint
pipenv run fmt
```
+### Update requirements files
+
+```bash
+invoke generate-reqs
+```
+
+[Pipfile.lock](./Pipfile.lock) will be automatically updated during `pipenv install`.
+
### Building
### Deploying
diff --git a/requirements-dev.txt b/requirements-dev.txt
new file mode 100644
index 00000000..e85f4e9c
--- /dev/null
+++ b/requirements-dev.txt
@@ -0,0 +1,48 @@
+-i https://pypi.org/simple
+appdirs==1.4.3
+astroid==2.3.3
+async-asgi-testclient==1.4.4
+async-generator==1.10
+asyncmock==0.4.2
+attrs==19.3.0
+bandit==1.6.2
+black==19.10b0
+certifi==2019.11.28
+chardet==3.0.4
+click==7.1.1
+coverage==5.0.4
+coveralls==1.11.1
+docopt==0.6.2
+gitdb==4.0.2
+gitpython==3.1.0
+idna==2.9
+importlib-metadata==1.6.0 ; python_version < '3.8'
+invoke==1.4.1
+isort==4.3.21
+lazy-object-proxy==1.4.3
+mccabe==0.6.1
+mock==4.0.2
+more-itertools==8.2.0
+multidict==4.7.5
+packaging==20.3
+pathspec==0.7.0
+pbr==5.4.4
+pluggy==0.13.1
+py==1.8.1
+pylint==2.4.4
+pyparsing==2.4.6
+pytest-asyncio==0.10.0
+pytest-cov==2.8.1
+pytest==5.4.1
+pyyaml==5.3.1
+regex==2020.2.20
+requests==2.23.0
+six==1.14.0
+smmap==3.0.1
+stevedore==1.32.0
+toml==0.10.0
+typed-ast==1.4.1
+urllib3==1.25.8
+wcwidth==0.1.9
+wrapt==1.11.2
+zipp==3.1.0
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 00000000..0d7a2c46
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,28 @@
+-i https://pypi.org/simple
+aiohttp==3.6.2
+async-timeout==3.0.1
+asyncache==0.1.1
+attrs==19.3.0
+cachetools==4.0.0
+certifi==2019.11.28
+chardet==3.0.4
+click==7.1.1
+dataclasses==0.6 ; python_version < '3.7'
+fastapi==0.53.2
+gunicorn==20.0.4
+h11==0.9.0
+httptools==0.1.1 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
+idna-ssl==1.1.0 ; python_version < '3.7'
+idna==2.9
+multidict==4.7.5
+pydantic==1.4
+python-dateutil==2.8.1
+python-dotenv==0.12.0
+requests==2.23.0
+six==1.14.0
+starlette==0.13.2
+urllib3==1.25.8
+uvicorn==0.11.3
+uvloop==0.14.0 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
+websockets==8.1
+yarl==1.4.2
diff --git a/tasks.py b/tasks.py
index 3ff5f24c..bf2a60df 100644
--- a/tasks.py
+++ b/tasks.py
@@ -64,3 +64,10 @@ def lint(ctx):
def test(ctx):
"""Run pytest tests."""
ctx.run(" ".join(["pytest", "-v"]))
+
+
+@invoke.task
+def generate_reqs(ctx):
+ """Generate requirements.txt"""
+ reqs = ["pipenv lock -r > requirements.txt", "pipenv lock -r --dev > requirements-dev.txt"]
+ [ctx.run(req) for req in reqs]
diff --git a/tests/test_cli.py b/tests/test_cli.py
new file mode 100644
index 00000000..ec92cd25
--- /dev/null
+++ b/tests/test_cli.py
@@ -0,0 +1,51 @@
+import subprocess
+
+
+def test_invoke_list():
+ """Test invoke --list"""
+ return_code = subprocess.call("invoke --list", shell=True)
+
+ assert return_code == 0
+
+
+def test_requirements_txt():
+ """Validate that requirements.txt and requirements-dev.txt
+ are up2date with Pipefile"""
+ temp_output_dir = "tests/temp_output"
+ req_test_file_path = "{}/test-requirements.txt".format(temp_output_dir)
+ req_dev_test_file_path = "{}/test-requirements-dev.txt".format(temp_output_dir)
+
+ return_code_0 = subprocess.call("mkdir -p {}".format(temp_output_dir), shell=True)
+ return_code_1 = subprocess.call(
+ "pipenv lock -r \
+ > {}".format(
+ req_test_file_path
+ ),
+ shell=True,
+ )
+
+ return_code_2 = subprocess.call(
+ "pipenv lock -r --dev \
+ > {}".format(
+ req_dev_test_file_path
+ ),
+ shell=True,
+ )
+
+ with open("requirements.txt") as file:
+ req_file = file.read()
+
+ with open("requirements-dev.txt") as file:
+ req_dev_file = file.read()
+
+ with open(req_test_file_path) as file:
+ req_test_file = file.read()
+
+ with open(req_dev_test_file_path) as file:
+ req_dev_test_file = file.read()
+
+ return_code_z = subprocess.call("rm -rf {}".format(temp_output_dir), shell=True)
+
+ assert req_file == req_test_file
+
+ assert req_dev_file == req_dev_test_file
From 6898dead890d272f635f8d96a2354522c34a3088 Mon Sep 17 00:00:00 2001
From: "allcontributors[bot]"
<46447321+allcontributors[bot]@users.noreply.github.com>
Date: Fri, 3 Apr 2020 17:33:06 -0400
Subject: [PATCH 25/61] docs: add james-gray as a contributor (#258)
* docs: update README.md [skip ci]
* docs: update .all-contributorsrc [skip ci]
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
---
.all-contributorsrc | 9 +++++++++
README.md | 1 +
2 files changed, 10 insertions(+)
diff --git a/.all-contributorsrc b/.all-contributorsrc
index bbf06353..e8633cc8 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -162,6 +162,15 @@
"contributions": [
"code"
]
+ },
+ {
+ "login": "james-gray",
+ "name": "James Gray",
+ "avatar_url": "https://avatars1.githubusercontent.com/u/2904597?v=4",
+ "profile": "https://github.com/james-gray",
+ "contributions": [
+ "code"
+ ]
}
],
"contributorsPerLine": 7,
diff --git a/README.md b/README.md
index cf8be2c3..2f58de1d 100644
--- a/README.md
+++ b/README.md
@@ -478,6 +478,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
 Turreted 💻 |
 Ibtida Bhuiyan 💻 |
+  James Gray 💻 |
From 2fcce78dacb117b6b3c703220d2cccf934bdcce8 Mon Sep 17 00:00:00 2001
From: Bost
Date: Tue, 7 Apr 2020 03:42:35 +0200
Subject: [PATCH 26/61] Doc fix: port of the localhost is 8000 (#257)
Co-authored-by: Rostislav Svoboda
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 2f58de1d..ad1892de 100644
--- a/README.md
+++ b/README.md
@@ -413,7 +413,7 @@ And don't despair if don't get the python setup working on the first try. No one
## Running / Development
* `pipenv run dev`
-* Visit your app at [http://localhost:5000](http://localhost:5000).
+* Visit your app at [http://localhost:8000](http://localhost:8000).
### Running Tests
> [pytest](https://docs.pytest.org/en/latest/)
From c39abeebc344d182566a3b44d8ba3dc919c102e2 Mon Sep 17 00:00:00 2001
From: Degant Puri
Date: Mon, 6 Apr 2020 18:46:43 -0700
Subject: [PATCH 27/61] Adding another C# client for the APIs (#250)
Hi great work putting this API together! :)
I've added another C# client for consuming the APIs based on the latest v2 contracts with support for all data types that should make it easier for any C# developers (.NET standard / core / framework) to use the API.
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index ad1892de..fb5ad988 100644
--- a/README.md
+++ b/README.md
@@ -367,6 +367,7 @@ These are the available API wrappers created by the community. They are not nece
* [CovidSharp by @Abdirahiim](https://github.com/Abdirahiim/covidtrackerapiwrapper)
* [Covid19Tracker.NET by @egbakou](https://github.com/egbakou/Covid19Tracker.NET)
+* [CovidDotNet by @degant](https://github.com/degant/CovidDotNet)
### Python
From 5b0197993fcb3eb573ae1dc9a94de9d93902fad7 Mon Sep 17 00:00:00 2001
From: Gabriel Dos Santos
Date: Tue, 7 Apr 2020 14:33:17 -0300
Subject: [PATCH 28/61] Add Docker files (#252)
---
.dockerignore | 5 +++++
Dockerfile | 17 +++++++++++++++++
docker-compose.yml | 14 ++++++++++++++
3 files changed, 36 insertions(+)
create mode 100644 .dockerignore
create mode 100644 Dockerfile
create mode 100644 docker-compose.yml
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..02346aa4
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,5 @@
+.gitignore
+README.md
+.github
+.travis.yml
+.env.example
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..083e2f90
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,17 @@
+FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
+
+# ENVS RECOMENDATIONS
+ENV PYTHONDONTWRITEBYTECODE 1
+ENV PYTHONUNBUFFERED 1
+
+# PREPARE FOLDER
+WORKDIR /api
+
+# COPY DEPENDENCIES
+COPY requirements.txt ./
+
+# INSTALL DEPENDENCIES
+RUN pip install -r requirements.txt
+
+# COPY PROJECT
+COPY . /
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 00000000..d78e92ac
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,14 @@
+version: '3.7'
+
+services:
+ api:
+ build: .
+ image: expdev07/coronavirus-tracker-api:2.0
+ restart: always
+ command: uvicorn --host 0.0.0.0 app.main:APP
+ volumes:
+ - .:/api
+ ports:
+ - "8000:8000"
+ stdin_open: true
+ tty: true
From 9eba6a7d321948459924d6e5c8f1ba71d048b53c Mon Sep 17 00:00:00 2001
From: Gabriel Dos Santos
Date: Fri, 10 Apr 2020 12:12:19 -0300
Subject: [PATCH 29/61] Fix COPY on dockerfile. (#272)
---
Dockerfile | 6 ++++--
docker-compose.yml | 1 -
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 083e2f90..b9cab02a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -11,7 +11,9 @@ WORKDIR /api
COPY requirements.txt ./
# INSTALL DEPENDENCIES
-RUN pip install -r requirements.txt
+RUN pip install --no-cache-dir -r requirements.txt
# COPY PROJECT
-COPY . /
+COPY . /api/
+
+CMD ["uvicorn", "--host", "0.0.0.0", "app.main:APP"]
\ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
index d78e92ac..6f599be8 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -5,7 +5,6 @@ services:
build: .
image: expdev07/coronavirus-tracker-api:2.0
restart: always
- command: uvicorn --host 0.0.0.0 app.main:APP
volumes:
- .:/api
ports:
From 17eaceafc8475c69c14b211b86ca8c14ea090a6f Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Fri, 10 Apr 2020 22:42:16 -0400
Subject: [PATCH 30/61] Fix Docker ports & +Gunicorn (#273)
* Docker fix & invoke tasks
* Use gunicorn
* add docker build + run invoke tasks
* Update docker-compose.yml
* hardcode published port
* Add docker and project task runner to readme
---
Dockerfile | 15 +++++----------
README.md | 28 ++++++++++++++++++++++++++--
docker-compose.yml | 4 ++--
tasks.py | 14 ++++++++++++++
4 files changed, 47 insertions(+), 14 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index b9cab02a..25e21bc5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,19 +1,14 @@
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
-# ENVS RECOMENDATIONS
-ENV PYTHONDONTWRITEBYTECODE 1
-ENV PYTHONUNBUFFERED 1
-
-# PREPARE FOLDER
-WORKDIR /api
+ENV VARIABLE_NAME APP
# COPY DEPENDENCIES
COPY requirements.txt ./
+# COPY PROJECT
+COPY ./app /app/app
+
# INSTALL DEPENDENCIES
RUN pip install --no-cache-dir -r requirements.txt
-# COPY PROJECT
-COPY . /api/
-
-CMD ["uvicorn", "--host", "0.0.0.0", "app.main:APP"]
\ No newline at end of file
+EXPOSE 80
diff --git a/README.md b/README.md
index fb5ad988..4fdbd3a2 100644
--- a/README.md
+++ b/README.md
@@ -413,8 +413,17 @@ And don't despair if don't get the python setup working on the first try. No one
## Running / Development
+For a live reloading on code changes.
+
* `pipenv run dev`
-* Visit your app at [http://localhost:8000](http://localhost:8000).
+
+Without live reloading.
+
+* `pipenv run start`
+
+Visit your app at [http://localhost:8000](http://localhost:8000).
+
+Alternatively run our API with Docker.
### Running Tests
> [pytest](https://docs.pytest.org/en/latest/)
@@ -446,7 +455,22 @@ invoke generate-reqs
[Pipfile.lock](./Pipfile.lock) will be automatically updated during `pipenv install`.
-### Building
+### Docker
+
+Our Docker image is based on [tiangolo/uvicorn-gunicorn-fastapi/](https://hub.docker.com/r/tiangolo/uvicorn-gunicorn-fastapi/).
+
+```bash
+invoke docker --build
+```
+
+Run with `docker run` or `docker-compose`
+
+### Invoke
+
+Additional developer commands can be run by calling them with the [python `invoke` task runner](http://www.pyinvoke.org/).
+```bash
+invoke --list
+```
### Deploying
diff --git a/docker-compose.yml b/docker-compose.yml
index 6f599be8..aa870110 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,4 +1,4 @@
-version: '3.7'
+version: "3.7"
services:
api:
@@ -8,6 +8,6 @@ services:
volumes:
- .:/api
ports:
- - "8000:8000"
+ - "80:80"
stdin_open: true
tty: true
diff --git a/tasks.py b/tasks.py
index bf2a60df..06a52486 100644
--- a/tasks.py
+++ b/tasks.py
@@ -9,6 +9,8 @@
invoke sort
invoke check
"""
+import random
+
import invoke
TARGETS_DESCRIPTION = "Paths/directories to format. [default: . ]"
@@ -71,3 +73,15 @@ def generate_reqs(ctx):
"""Generate requirements.txt"""
reqs = ["pipenv lock -r > requirements.txt", "pipenv lock -r --dev > requirements-dev.txt"]
[ctx.run(req) for req in reqs]
+
+
+@invoke.task
+def docker(ctx, build=False, run=False, tag="covid-tracker-api:latest", name=f"covid-api-{random.randint(0,999)}"):
+ """Build and run docker container."""
+ if not any([build, run]):
+ raise invoke.Exit(message="Specify either --build or --run", code=1)
+ if build:
+ docker_cmds = ["build", "."]
+ else:
+ docker_cmds = ["run", "--publish", "80", "--name", name]
+ ctx.run(" ".join(["docker", *docker_cmds, "-t", tag]))
From 78da9fa529913f0b602d656114a3fb3c421f47e8 Mon Sep 17 00:00:00 2001
From: Ibtida Bhuiyan
Date: Sun, 12 Apr 2020 21:16:09 -0400
Subject: [PATCH 31/61] Source NYT (#259)
* Started adding documentation for NYT source
* Started nyt.py file in services.location module
* Testing nischal pushing to branch
* Temp directory to test parsing nyt timeseries
* Locally working nyt source on v2
* Deleted temporary folder so it hopefully passes build
* Added mock data, unit tests, and regression tests for source NYT
* Updated README to reflect new NYT source
* Fixed requested points from PR
Co-authored-by: nischalshankar
---
README.md | 19 +-
app/data/__init__.py | 3 +-
app/enums/sources.py | 1 +
app/location/nyt.py | 32 +++
app/services/location/nyt.py | 123 +++++++++
tests/example_data/counties.csv | 49 ++++
tests/expected_output/nyt_locations.json | 302 +++++++++++++++++++++++
tests/test_nyt.py | 42 ++++
tests/test_routes.py | 5 +
9 files changed, 569 insertions(+), 7 deletions(-)
create mode 100644 app/location/nyt.py
create mode 100644 app/services/location/nyt.py
create mode 100644 tests/example_data/counties.csv
create mode 100644 tests/expected_output/nyt_locations.json
create mode 100644 tests/test_nyt.py
diff --git a/README.md b/README.md
index 4fdbd3a2..6115bb5f 100644
--- a/README.md
+++ b/README.md
@@ -24,18 +24,24 @@ Support multiple data-sources.


+## New York Times is now available as a source!
+
+**Specify source parameter with ?source=nyt. NYT also provides a timeseries! To view timelines of cases by US counties use ?source=nyt&timelines=true**
+
## Recovered cases showing 0
-**JHU (our main data provider) [no longer provides data for amount of recoveries](https://github.com/CSSEGISandData/COVID-19/issues/1250), and as a result, the API will be showing 0 for this statistic. Apolegies for any inconvenience. Hopefully we'll be able to find an alternative data-source that offers this.**
+**JHU (our main data provider) [no longer provides data for amount of recoveries](https://github.com/CSSEGISandData/COVID-19/issues/1250), and as a result, the API will be showing 0 for this statistic. Apologies for any inconvenience. Hopefully we'll be able to find an alternative data-source that offers this.**
## Available data-sources:
-Currently 2 different data-sources are available to retrieve the data:
+Currently 3 different data-sources are available to retrieve the data:
* **jhu** - https://github.com/CSSEGISandData/COVID-19 - Worldwide Data repository operated by the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE).
* **csbs** - https://www.csbs.org/information-covid-19-coronavirus - U.S. County data that comes from the Conference of State Bank Supervisors.
+* **nyt** - https://github.com/nytimes/covid-19-data - The New York Times is releasing a series of data files with cumulative counts of coronavirus cases in the United States, at the state and county level, over time.
+
__jhu__ data-source will be used as a default source if you don't specify a *source parameter* in your request.
## API Reference
@@ -71,7 +77,8 @@ __Sample response__
{
"sources": [
"jhu",
- "csbs"
+ "csbs",
+ "nyt"
]
}
```
@@ -87,7 +94,7 @@ GET /v2/latest
__Query String Parameters__
| __Query string parameter__ | __Description__ | __Type__ |
| -------------------------- | -------------------------------------------------------------------------------- | -------- |
-| source | The data-source where data will be retrieved from *(jhu/csbs)*. Default is *jhu* | String |
+| source | The data-source where data will be retrieved from *(jhu/csbs/nyt)*. Default is *jhu* | String |
__Sample response__
```json
@@ -117,7 +124,7 @@ __Path Parameters__
__Query String Parameters__
| __Query string parameter__ | __Description__ | __Type__ |
| -------------------------- | -------------------------------------------------------------------------------- | -------- |
-| source | The data-source where data will be retrieved from *(jhu/csbs)*. Default is *jhu* | String |
+| source | The data-source where data will be retrieved from *(jhu/csbs/nyt)*. Default is *jhu* | String |
#### Example Request
```http
@@ -160,7 +167,7 @@ GET /v2/locations
__Query String Parameters__
| __Query string parameter__ | __Description__ | __Type__ |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |
-| source | The data-source where data will be retrieved from.
__Value__ can be: *jhu/csbs*. __Default__ is *jhu* | String |
+| source | The data-source where data will be retrieved from.
__Value__ can be: *jhu/csbs/nyt*. __Default__ is *jhu* | String |
| country_code | The ISO ([alpha-2 country_code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)) to the Country/Province for which you're calling the Endpoint | String |
| timelines | To set the visibility of timelines (*daily tracking*).
__Value__ can be: *0/1*. __Default__ is *0* (timelines are not visible) | Integer |
diff --git a/app/data/__init__.py b/app/data/__init__.py
index aef58e8c..265bf3d3 100644
--- a/app/data/__init__.py
+++ b/app/data/__init__.py
@@ -1,9 +1,10 @@
"""app.data"""
from ..services.location.csbs import CSBSLocationService
from ..services.location.jhu import JhuLocationService
+from ..services.location.nyt import NYTLocationService
# Mapping of services to data-sources.
-DATA_SOURCES = {"jhu": JhuLocationService(), "csbs": CSBSLocationService()}
+DATA_SOURCES = {"jhu": JhuLocationService(), "csbs": CSBSLocationService(), "nyt": NYTLocationService()}
def data_source(source):
diff --git a/app/enums/sources.py b/app/enums/sources.py
index b4538c45..9fc00744 100644
--- a/app/enums/sources.py
+++ b/app/enums/sources.py
@@ -8,3 +8,4 @@ class Sources(str, Enum):
jhu = "jhu"
csbs = "csbs"
+ nyt = "nyt"
diff --git a/app/location/nyt.py b/app/location/nyt.py
new file mode 100644
index 00000000..ad92212e
--- /dev/null
+++ b/app/location/nyt.py
@@ -0,0 +1,32 @@
+"""app.locations.nyt.py"""
+from . import TimelinedLocation
+
+
+class NYTLocation(TimelinedLocation):
+ """
+ A NYT (county) Timelinedlocation.
+ """
+
+ # pylint: disable=too-many-arguments,redefined-builtin
+ def __init__(self, id, state, county, coordinates, last_updated, timelines):
+ super().__init__(id, "US", state, coordinates, last_updated, timelines)
+
+ self.state = state
+ self.county = county
+
+ def serialize(self, timelines=False): # pylint: disable=arguments-differ,unused-argument
+ """
+ Serializes the location into a dict.
+
+ :returns: The serialized location.
+ :rtype: dict
+ """
+ serialized = super().serialize(timelines)
+
+ # Update with new fields.
+ serialized.update(
+ {"state": self.state, "county": self.county,}
+ )
+
+ # Return the serialized location.
+ return serialized
diff --git a/app/services/location/nyt.py b/app/services/location/nyt.py
new file mode 100644
index 00000000..7f73c1de
--- /dev/null
+++ b/app/services/location/nyt.py
@@ -0,0 +1,123 @@
+"""app.services.location.nyt.py"""
+import csv
+from datetime import datetime
+
+from asyncache import cached
+from cachetools import TTLCache
+
+from ...coordinates import Coordinates
+from ...location.nyt import NYTLocation
+from ...timeline import Timeline
+from ...utils import httputils
+from . import LocationService
+
+
+class NYTLocationService(LocationService):
+ """
+ Service for retrieving locations from New York Times (https://github.com/nytimes/covid-19-data).
+ """
+
+ async def get_all(self):
+ # Get the locations.
+ locations = await get_locations()
+ return locations
+
+ async def get(self, loc_id): # pylint: disable=arguments-differ
+ # Get location at the index equal to provided id.
+ locations = await self.get_all()
+ return locations[loc_id]
+
+
+# ---------------------------------------------------------------
+
+
+# Base URL for fetching category.
+BASE_URL = "https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv"
+
+
+def get_grouped_locations_dict(data):
+ """
+ Helper function to group history for locations into one dict.
+
+ :returns: The complete data for each unique US county
+ :rdata: dict
+ """
+ grouped_locations = {}
+
+ # in increasing order of dates
+ for row in data:
+ county_state = (row["county"], row["state"])
+ date = row["date"]
+ confirmed = row["cases"]
+ deaths = row["deaths"]
+
+ # initialize if not existing
+ if county_state not in grouped_locations:
+ grouped_locations[county_state] = {"confirmed": [], "deaths": []}
+
+ # append confirmed tuple to county_state (date, # confirmed)
+ grouped_locations[county_state]["confirmed"].append((date, confirmed))
+ # append deaths tuple to county_state (date, # deaths)
+ grouped_locations[county_state]["deaths"].append((date, deaths))
+
+ return grouped_locations
+
+
+@cached(cache=TTLCache(maxsize=1024, ttl=3600))
+async def get_locations():
+ """
+ Returns a list containing parsed NYT data by US county. The data is cached for 1 hour.
+
+ :returns: The complete data for US Counties.
+ :rtype: dict
+ """
+
+ # Request the data.
+ async with httputils.CLIENT_SESSION.get(BASE_URL) as response:
+ text = await response.text()
+
+ # Parse the CSV.
+ data = list(csv.DictReader(text.splitlines()))
+
+ # Group together locations (NYT data ordered by dates not location).
+ grouped_locations = get_grouped_locations_dict(data)
+
+ # The normalized locations.
+ locations = []
+
+ for idx, (county_state, histories) in enumerate(grouped_locations.items()):
+ # Make location history for confirmed and deaths from dates.
+ # List is tuples of (date, amount) in order of increasing dates.
+ confirmed_list = histories["confirmed"]
+ confirmed_history = {date: int(amount or 0) for date, amount in confirmed_list}
+
+ deaths_list = histories["deaths"]
+ deaths_history = {date: int(amount or 0) for date, amount in deaths_list}
+
+ # Normalize the item and append to locations.
+ locations.append(
+ NYTLocation(
+ id=idx,
+ state=county_state[1],
+ county=county_state[0],
+ coordinates=Coordinates(None, None), # NYT does not provide coordinates
+ last_updated=datetime.utcnow().isoformat() + "Z", # since last request
+ timelines={
+ "confirmed": Timeline(
+ {
+ datetime.strptime(date, "%Y-%m-%d").isoformat() + "Z": amount
+ for date, amount in confirmed_history.items()
+ }
+ ),
+ "deaths": Timeline(
+ {
+ datetime.strptime(date, "%Y-%m-%d").isoformat() + "Z": amount
+ for date, amount in deaths_history.items()
+ }
+ ),
+ "recovered": Timeline({}),
+ },
+ )
+ )
+
+ return locations
diff --git a/tests/example_data/counties.csv b/tests/example_data/counties.csv
new file mode 100644
index 00000000..0e76bf0d
--- /dev/null
+++ b/tests/example_data/counties.csv
@@ -0,0 +1,49 @@
+date,county,state,fips,cases,deaths
+2020-01-21,Snohomish,Washington,53061,1,0
+2020-01-22,Snohomish,Washington,53061,1,0
+2020-01-23,Snohomish,Washington,53061,1,0
+2020-01-24,Cook,Illinois,17031,1,0
+2020-01-24,Snohomish,Washington,53061,1,0
+2020-01-25,Orange,California,06059,1,0
+2020-01-25,Cook,Illinois,17031,1,0
+2020-01-25,Snohomish,Washington,53061,1,0
+2020-01-26,Maricopa,Arizona,04013,1,0
+2020-01-26,Los Angeles,California,06037,1,0
+2020-01-26,Orange,California,06059,1,0
+2020-01-26,Cook,Illinois,17031,1,0
+2020-01-26,Snohomish,Washington,53061,1,0
+2020-01-27,Maricopa,Arizona,04013,1,0
+2020-01-27,Los Angeles,California,06037,1,0
+2020-01-27,Orange,California,06059,1,0
+2020-01-27,Cook,Illinois,17031,1,0
+2020-01-27,Snohomish,Washington,53061,1,0
+2020-01-28,Maricopa,Arizona,04013,1,0
+2020-01-28,Los Angeles,California,06037,1,0
+2020-01-28,Orange,California,06059,1,0
+2020-01-28,Cook,Illinois,17031,1,0
+2020-01-28,Snohomish,Washington,53061,1,0
+2020-01-29,Maricopa,Arizona,04013,1,0
+2020-01-29,Los Angeles,California,06037,1,0
+2020-01-29,Orange,California,06059,1,0
+2020-01-29,Cook,Illinois,17031,1,0
+2020-01-29,Snohomish,Washington,53061,1,0
+2020-01-30,Maricopa,Arizona,04013,1,0
+2020-01-30,Los Angeles,California,06037,1,0
+2020-01-30,Orange,California,06059,1,0
+2020-01-30,Cook,Illinois,17031,2,0
+2020-01-30,Snohomish,Washington,53061,1,0
+2020-01-31,Maricopa,Arizona,04013,1,0
+2020-01-31,Los Angeles,California,06037,1,0
+2020-01-31,Orange,California,06059,1,0
+2020-01-31,Santa Clara,California,06085,1,0
+2020-01-31,Cook,Illinois,17031,2,0
+2020-01-31,Snohomish,Washington,53061,1,0
+2020-02-28,Snohomish,Washington,53061,2,0
+2020-03-10,Snohomish,Washington,53061,61,0
+2020-03-11,Snohomish,Washington,53061,69,1
+2020-03-12,Snohomish,Washington,53061,107,3
+2020-03-15,Snohomish,Washington,53061,175,3
+2020-03-17,Snohomish,Washington,53061,265,4
+2020-03-18,Snohomish,Washington,53061,309,5
+2020-03-19,Snohomish,Washington,53061,347,6
+2020-03-20,Snohomish,Washington,53061,384,7
\ No newline at end of file
diff --git a/tests/expected_output/nyt_locations.json b/tests/expected_output/nyt_locations.json
new file mode 100644
index 00000000..3af82c40
--- /dev/null
+++ b/tests/expected_output/nyt_locations.json
@@ -0,0 +1,302 @@
+[
+ {
+ "id": 0,
+ "country": "US",
+ "country_code": "US",
+ "province": "Washington",
+ "coordinates": {
+ "latitude": null,
+ "longitude": null
+ },
+ "last_updated": "2020-04-12T19:14:59.638001Z",
+ "latest": {
+ "confirmed": 384,
+ "deaths": 7,
+ "recovered": 0
+ },
+ "timelines": {
+ "confirmed": {
+ "latest": 384,
+ "timeline": {
+ "2020-01-21T00:00:00Z": 1,
+ "2020-01-22T00:00:00Z": 1,
+ "2020-01-23T00:00:00Z": 1,
+ "2020-01-24T00:00:00Z": 1,
+ "2020-01-25T00:00:00Z": 1,
+ "2020-01-26T00:00:00Z": 1,
+ "2020-01-27T00:00:00Z": 1,
+ "2020-01-28T00:00:00Z": 1,
+ "2020-01-29T00:00:00Z": 1,
+ "2020-01-30T00:00:00Z": 1,
+ "2020-01-31T00:00:00Z": 1,
+ "2020-02-28T00:00:00Z": 2,
+ "2020-03-10T00:00:00Z": 61,
+ "2020-03-11T00:00:00Z": 69,
+ "2020-03-12T00:00:00Z": 107,
+ "2020-03-15T00:00:00Z": 175,
+ "2020-03-17T00:00:00Z": 265,
+ "2020-03-18T00:00:00Z": 309,
+ "2020-03-19T00:00:00Z": 347,
+ "2020-03-20T00:00:00Z": 384
+ }
+ },
+ "deaths": {
+ "latest": 7,
+ "timeline": {
+ "2020-01-21T00:00:00Z": 0,
+ "2020-01-22T00:00:00Z": 0,
+ "2020-01-23T00:00:00Z": 0,
+ "2020-01-24T00:00:00Z": 0,
+ "2020-01-25T00:00:00Z": 0,
+ "2020-01-26T00:00:00Z": 0,
+ "2020-01-27T00:00:00Z": 0,
+ "2020-01-28T00:00:00Z": 0,
+ "2020-01-29T00:00:00Z": 0,
+ "2020-01-30T00:00:00Z": 0,
+ "2020-01-31T00:00:00Z": 0,
+ "2020-02-28T00:00:00Z": 0,
+ "2020-03-10T00:00:00Z": 0,
+ "2020-03-11T00:00:00Z": 1,
+ "2020-03-12T00:00:00Z": 3,
+ "2020-03-15T00:00:00Z": 3,
+ "2020-03-17T00:00:00Z": 4,
+ "2020-03-18T00:00:00Z": 5,
+ "2020-03-19T00:00:00Z": 6,
+ "2020-03-20T00:00:00Z": 7
+ }
+ },
+ "recovered": {
+ "latest": 0,
+ "timeline": {}
+ }
+ },
+ "state": "Washington",
+ "county": "Snohomish"
+ },
+ {
+ "id": 1,
+ "country": "US",
+ "country_code": "US",
+ "province": "Illinois",
+ "coordinates": {
+ "latitude": null,
+ "longitude": null
+ },
+ "last_updated": "2020-04-12T19:14:59.638001Z",
+ "latest": {
+ "confirmed": 2,
+ "deaths": 0,
+ "recovered": 0
+ },
+ "timelines": {
+ "confirmed": {
+ "latest": 2,
+ "timeline": {
+ "2020-01-24T00:00:00Z": 1,
+ "2020-01-25T00:00:00Z": 1,
+ "2020-01-26T00:00:00Z": 1,
+ "2020-01-27T00:00:00Z": 1,
+ "2020-01-28T00:00:00Z": 1,
+ "2020-01-29T00:00:00Z": 1,
+ "2020-01-30T00:00:00Z": 2,
+ "2020-01-31T00:00:00Z": 2
+ }
+ },
+ "deaths": {
+ "latest": 0,
+ "timeline": {
+ "2020-01-24T00:00:00Z": 0,
+ "2020-01-25T00:00:00Z": 0,
+ "2020-01-26T00:00:00Z": 0,
+ "2020-01-27T00:00:00Z": 0,
+ "2020-01-28T00:00:00Z": 0,
+ "2020-01-29T00:00:00Z": 0,
+ "2020-01-30T00:00:00Z": 0,
+ "2020-01-31T00:00:00Z": 0
+ }
+ },
+ "recovered": {
+ "latest": 0,
+ "timeline": {}
+ }
+ },
+ "state": "Illinois",
+ "county": "Cook"
+ },
+ {
+ "id": 2,
+ "country": "US",
+ "country_code": "US",
+ "province": "California",
+ "coordinates": {
+ "latitude": null,
+ "longitude": null
+ },
+ "last_updated": "2020-04-12T19:14:59.638001Z",
+ "latest": {
+ "confirmed": 1,
+ "deaths": 0,
+ "recovered": 0
+ },
+ "timelines": {
+ "confirmed": {
+ "latest": 1,
+ "timeline": {
+ "2020-01-25T00:00:00Z": 1,
+ "2020-01-26T00:00:00Z": 1,
+ "2020-01-27T00:00:00Z": 1,
+ "2020-01-28T00:00:00Z": 1,
+ "2020-01-29T00:00:00Z": 1,
+ "2020-01-30T00:00:00Z": 1,
+ "2020-01-31T00:00:00Z": 1
+ }
+ },
+ "deaths": {
+ "latest": 0,
+ "timeline": {
+ "2020-01-25T00:00:00Z": 0,
+ "2020-01-26T00:00:00Z": 0,
+ "2020-01-27T00:00:00Z": 0,
+ "2020-01-28T00:00:00Z": 0,
+ "2020-01-29T00:00:00Z": 0,
+ "2020-01-30T00:00:00Z": 0,
+ "2020-01-31T00:00:00Z": 0
+ }
+ },
+ "recovered": {
+ "latest": 0,
+ "timeline": {}
+ }
+ },
+ "state": "California",
+ "county": "Orange"
+ },
+ {
+ "id": 3,
+ "country": "US",
+ "country_code": "US",
+ "province": "Arizona",
+ "coordinates": {
+ "latitude": null,
+ "longitude": null
+ },
+ "last_updated": "2020-04-12T19:14:59.638001Z",
+ "latest": {
+ "confirmed": 1,
+ "deaths": 0,
+ "recovered": 0
+ },
+ "timelines": {
+ "confirmed": {
+ "latest": 1,
+ "timeline": {
+ "2020-01-26T00:00:00Z": 1,
+ "2020-01-27T00:00:00Z": 1,
+ "2020-01-28T00:00:00Z": 1,
+ "2020-01-29T00:00:00Z": 1,
+ "2020-01-30T00:00:00Z": 1,
+ "2020-01-31T00:00:00Z": 1
+ }
+ },
+ "deaths": {
+ "latest": 0,
+ "timeline": {
+ "2020-01-26T00:00:00Z": 0,
+ "2020-01-27T00:00:00Z": 0,
+ "2020-01-28T00:00:00Z": 0,
+ "2020-01-29T00:00:00Z": 0,
+ "2020-01-30T00:00:00Z": 0,
+ "2020-01-31T00:00:00Z": 0
+ }
+ },
+ "recovered": {
+ "latest": 0,
+ "timeline": {}
+ }
+ },
+ "state": "Arizona",
+ "county": "Maricopa"
+ },
+ {
+ "id": 4,
+ "country": "US",
+ "country_code": "US",
+ "province": "California",
+ "coordinates": {
+ "latitude": null,
+ "longitude": null
+ },
+ "last_updated": "2020-04-12T19:14:59.638001Z",
+ "latest": {
+ "confirmed": 1,
+ "deaths": 0,
+ "recovered": 0
+ },
+ "timelines": {
+ "confirmed": {
+ "latest": 1,
+ "timeline": {
+ "2020-01-26T00:00:00Z": 1,
+ "2020-01-27T00:00:00Z": 1,
+ "2020-01-28T00:00:00Z": 1,
+ "2020-01-29T00:00:00Z": 1,
+ "2020-01-30T00:00:00Z": 1,
+ "2020-01-31T00:00:00Z": 1
+ }
+ },
+ "deaths": {
+ "latest": 0,
+ "timeline": {
+ "2020-01-26T00:00:00Z": 0,
+ "2020-01-27T00:00:00Z": 0,
+ "2020-01-28T00:00:00Z": 0,
+ "2020-01-29T00:00:00Z": 0,
+ "2020-01-30T00:00:00Z": 0,
+ "2020-01-31T00:00:00Z": 0
+ }
+ },
+ "recovered": {
+ "latest": 0,
+ "timeline": {}
+ }
+ },
+ "state": "California",
+ "county": "Los Angeles"
+ },
+ {
+ "id": 5,
+ "country": "US",
+ "country_code": "US",
+ "province": "California",
+ "coordinates": {
+ "latitude": null,
+ "longitude": null
+ },
+ "last_updated": "2020-04-12T19:14:59.638001Z",
+ "latest": {
+ "confirmed": 1,
+ "deaths": 0,
+ "recovered": 0
+ },
+ "timelines": {
+ "confirmed": {
+ "latest": 1,
+ "timeline": {
+ "2020-01-31T00:00:00Z": 1
+ }
+ },
+ "deaths": {
+ "latest": 0,
+ "timeline": {
+ "2020-01-31T00:00:00Z": 0
+ }
+ },
+ "recovered": {
+ "latest": 0,
+ "timeline": {}
+ }
+ },
+ "state": "California",
+ "county": "Santa Clara"
+ }
+]
\ No newline at end of file
diff --git a/tests/test_nyt.py b/tests/test_nyt.py
new file mode 100644
index 00000000..ca9c9dca
--- /dev/null
+++ b/tests/test_nyt.py
@@ -0,0 +1,42 @@
+import json
+from unittest import mock
+
+import pytest
+
+from app.location import TimelinedLocation
+from app.location.nyt import NYTLocation
+from app.services.location import nyt
+from tests.conftest import mocked_strptime_isoformat
+
+DATETIME_STRING = "2020-04-12T19:14:59.638001"
+
+
+@pytest.mark.asyncio
+async def test_get_locations(mock_client_session):
+ with mock.patch("app.services.location.nyt.datetime") as mock_datetime:
+ mock_datetime.utcnow.return_value.isoformat.return_value = DATETIME_STRING
+ mock_datetime.strptime.side_effect = mocked_strptime_isoformat
+ locations = await nyt.get_locations()
+
+ assert isinstance(locations, list)
+
+ serialized_locations = []
+ for location in locations:
+ assert isinstance(location, NYTLocation)
+ assert isinstance(location, TimelinedLocation)
+
+ # Making sure country population is a non-zero value
+ assert location.country_population != 0
+ serialized_location = location.serialize(timelines=True)
+ # Not checking for exact value of country population
+ del serialized_location["country_population"]
+
+ serialized_locations.append(serialized_location)
+
+ produced_json_output = json.dumps(serialized_locations)
+
+ with open("tests/expected_output/nyt_locations.json", "r") as file:
+ expected_json_output = file.read()
+
+ # translate them into python lists for ordering
+ assert json.loads(expected_json_output) == json.loads(produced_json_output)
diff --git a/tests/test_routes.py b/tests/test_routes.py
index 605ce2c0..52d26843 100644
--- a/tests/test_routes.py
+++ b/tests/test_routes.py
@@ -140,11 +140,14 @@ async def test_v2_locations_id(self):
[
({"source": "csbs"}, 200),
({"source": "jhu"}, 200),
+ ({"source": "nyt"}, 200),
({"timelines": True}, 200),
({"timelines": "true"}, 200),
({"timelines": 1}, 200),
({"source": "jhu", "timelines": True}, 200),
+ ({"source": "nyt", "timelines": True}, 200),
({"source": "csbs", "country_code": "US"}, 200),
+ ({"source": "nyt", "country_code": "US"}, 200),
({"source": "jhu", "country_code": "US"}, 404),
],
)
@@ -162,10 +165,12 @@ async def test_locations_status_code(async_api_client, query_params, expected_st
[
{"source": "csbs"},
{"source": "jhu"},
+ {"source": "nyt"},
{"timelines": True},
{"timelines": "true"},
{"timelines": 1},
{"source": "jhu", "timelines": True},
+ {"source": "nyt", "timelines": True},
],
)
async def test_latest(async_api_client, query_params, mock_client_session):
From f5dc8a6ba977c01ff567ce91006cd223e0703715 Mon Sep 17 00:00:00 2001
From: "allcontributors[bot]"
<46447321+allcontributors[bot]@users.noreply.github.com>
Date: Sun, 12 Apr 2020 21:19:18 -0400
Subject: [PATCH 32/61] docs: add nischalshankar as a contributor (#278)
* docs: update README.md [skip ci]
* docs: update .all-contributorsrc [skip ci]
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
---
.all-contributorsrc | 10 ++++++++++
README.md | 1 +
2 files changed, 11 insertions(+)
diff --git a/.all-contributorsrc b/.all-contributorsrc
index e8633cc8..6c25072f 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -171,6 +171,16 @@
"contributions": [
"code"
]
+ },
+ {
+ "login": "nischalshankar",
+ "name": "Nischal Shankar",
+ "avatar_url": "https://avatars2.githubusercontent.com/u/33793411?v=4",
+ "profile": "https://github.com/nischalshankar",
+ "contributions": [
+ "code",
+ "doc"
+ ]
}
],
"contributorsPerLine": 7,
diff --git a/README.md b/README.md
index 6115bb5f..05cc43ca 100644
--- a/README.md
+++ b/README.md
@@ -511,6 +511,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
 Turreted 💻 |
 Ibtida Bhuiyan 💻 |
 James Gray 💻 |
+  Nischal Shankar 💻 📖 |
From 8aae06b7593adde8a74968f26b30c6db6a0fe32e Mon Sep 17 00:00:00 2001
From: "allcontributors[bot]"
<46447321+allcontributors[bot]@users.noreply.github.com>
Date: Sun, 12 Apr 2020 21:21:11 -0400
Subject: [PATCH 33/61] docs: add ibhuiyan17 as a contributor (#279)
* docs: update README.md [skip ci]
* docs: update .all-contributorsrc [skip ci]
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
---
.all-contributorsrc | 3 ++-
README.md | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/.all-contributorsrc b/.all-contributorsrc
index 6c25072f..59896722 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -160,7 +160,8 @@
"avatar_url": "https://avatars1.githubusercontent.com/u/33792969?v=4",
"profile": "http://ibtida.me",
"contributions": [
- "code"
+ "code",
+ "doc"
]
},
{
diff --git a/README.md b/README.md
index 05cc43ca..66132cc3 100644
--- a/README.md
+++ b/README.md
@@ -509,7 +509,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
 Turreted 💻 |
-  Ibtida Bhuiyan 💻 |
+  Ibtida Bhuiyan 💻 📖 |
 James Gray 💻 |
 Nischal Shankar 💻 📖 |
From a4aed2db321972e85d42d128a0a74ef9f5d8cbaa Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sun, 12 Apr 2020 21:30:34 -0400
Subject: [PATCH 34/61] update version
---
app/main.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/main.py b/app/main.py
index 0018f8bf..437b2395 100644
--- a/app/main.py
+++ b/app/main.py
@@ -26,7 +26,7 @@
"API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak."
" Project page: https://github.com/ExpDev07/coronavirus-tracker-api."
),
- version="2.0.1",
+ version="2.0.2",
docs_url="/",
redoc_url="/docs",
on_startup=[setup_client_session],
From 2255dc9b5b321e44fdd7dc06e3527c53dd2fe994 Mon Sep 17 00:00:00 2001
From: Ibtida Bhuiyan
Date: Mon, 13 Apr 2020 18:54:58 -0400
Subject: [PATCH 35/61] Update README to clarify NYT data (#281)
Previously stated NYT provides timeseries for US states and counties which could be misleading since this API currently supports county level.
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 66132cc3..ae306600 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@ Currently 3 different data-sources are available to retrieve the data:
* **csbs** - https://www.csbs.org/information-covid-19-coronavirus - U.S. County data that comes from the Conference of State Bank Supervisors.
-* **nyt** - https://github.com/nytimes/covid-19-data - The New York Times is releasing a series of data files with cumulative counts of coronavirus cases in the United States, at the state and county level, over time.
+* **nyt** - https://github.com/nytimes/covid-19-data - The New York Times is releasing a series of data files with cumulative counts of coronavirus cases in the United States. This API provides the timeseries at the US county level.
__jhu__ data-source will be used as a default source if you don't specify a *source parameter* in your request.
From 6eb92dfa4f00f56c8f81c24c31ffaee2bd71c700 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Wed, 15 Apr 2020 06:57:23 -0400
Subject: [PATCH 36/61] Uvicorn based Docker (#282)
* single uvicorn based api
* update readme
---
README.md | 5 +++++
uvicorn.Dockerfile | 14 ++++++++++++++
2 files changed, 19 insertions(+)
create mode 100644 uvicorn.Dockerfile
diff --git a/README.md b/README.md
index ae306600..7355d0af 100644
--- a/README.md
+++ b/README.md
@@ -472,6 +472,11 @@ invoke docker --build
Run with `docker run` or `docker-compose`
+#### Alternate Docker images
+
+If a full `gunicorn` deployment is unnecessary or [impractical on your hardware](https://fastapi.tiangolo.com/deployment/#raspberry-pi-and-other-architectures) consider using our single instance [`Uvicorn`](https://www.uvicorn.org/) based [Dockerfile](uvicorn.Dockerfile).
+
+
### Invoke
Additional developer commands can be run by calling them with the [python `invoke` task runner](http://www.pyinvoke.org/).
diff --git a/uvicorn.Dockerfile b/uvicorn.Dockerfile
new file mode 100644
index 00000000..9ed45c16
--- /dev/null
+++ b/uvicorn.Dockerfile
@@ -0,0 +1,14 @@
+FROM python:3.7
+
+# COPY DEPENDENCIES
+COPY requirements.txt ./
+
+# COPY PROJECT
+COPY ./app /app
+
+EXPOSE 80
+
+# INSTALL DEPENDENCIES
+RUN pip install --no-cache-dir -r requirements.txt
+
+CMD ["uvicorn", "app.main:APP", "--host", "0.0.0.0", "--port", "80"]
From d6a332d34ed4fa4cfe13ea094ead1d2b9e6b1125 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sat, 18 Apr 2020 09:03:07 -0400
Subject: [PATCH 37/61] Update issue templates (#288)
---
.github/ISSUE_TEMPLATE/bug_report.md | 61 ++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 00000000..4a80756e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,61 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: "[BUG]"
+labels: bug
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is. Please include timestamps and HTTP status codes.
+If possible include the [httpie](https://httpie.org/) or `curl` request and response.
+Please include the verbose flag. `-v`
+
+**To Reproduce**
+`httpie/curl` request to reproduce the behavior:
+1. Getting Italy data at `v2/locations/IT` gives a 422.
+2. Expected to same data as `/v2/locations?country_code=IT`
+2. See httpie request & response below
+```sh
+ http GET https://coronavirus-tracker-api.herokuapp.com/v2/locations/IT -v
+GET /v2/locations/IT HTTP/1.1
+Accept: */*
+Accept-Encoding: gzip, deflate
+Connection: keep-alive
+Host: coronavirus-tracker-api.herokuapp.com
+User-Agent: HTTPie/2.0.0
+
+
+
+HTTP/1.1 422 Unprocessable Entity
+Connection: keep-alive
+Content-Length: 99
+Content-Type: application/json
+Date: Sat, 18 Apr 2020 12:50:29 GMT
+Server: uvicorn
+Via: 1.1 vegur
+
+{
+ "detail": [
+ {
+ "loc": [
+ "path",
+ "id"
+ ],
+ "msg": "value is not a valid integer",
+ "type": "type_error.integer"
+ }
+ ]
+}
+```
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Additional context**
+Add any other context about the problem here.
+Does the other instance at https://covid-tracker-us.herokuapp.com/ produce the same result?
From 9c817214ba8618b1a80dc4e587eb0135d99d6e64 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sat, 18 Apr 2020 09:06:50 -0400
Subject: [PATCH 38/61] Update bug_report.md
---
.github/ISSUE_TEMPLATE/bug_report.md | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 4a80756e..afbb3e1d 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -17,6 +17,12 @@ Please include the verbose flag. `-v`
1. Getting Italy data at `v2/locations/IT` gives a 422.
2. Expected to same data as `/v2/locations?country_code=IT`
2. See httpie request & response below
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots or Requests**
+If applicable, add screenshots or `httpie/curl`requests to help explain your problem.
```sh
http GET https://coronavirus-tracker-api.herokuapp.com/v2/locations/IT -v
GET /v2/locations/IT HTTP/1.1
@@ -50,11 +56,6 @@ Via: 1.1 vegur
}
```
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**Screenshots**
-If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.
From 81abb260bd710cb5670b9ea664e9996ea79e53e7 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sat, 18 Apr 2020 09:07:17 -0400
Subject: [PATCH 39/61] Update bug_report.md
---
.github/ISSUE_TEMPLATE/bug_report.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index afbb3e1d..0625e1fb 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -24,7 +24,7 @@ A clear and concise description of what you expected to happen.
**Screenshots or Requests**
If applicable, add screenshots or `httpie/curl`requests to help explain your problem.
```sh
- http GET https://coronavirus-tracker-api.herokuapp.com/v2/locations/IT -v
+$ http GET https://coronavirus-tracker-api.herokuapp.com/v2/locations/IT -v
GET /v2/locations/IT HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
From a9f3b732c6770a7b14ed7c6bdcacc75c6d1d4927 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sat, 18 Apr 2020 14:10:46 -0400
Subject: [PATCH 40/61] add GZIP support for responses > 1000bytes (#294)
* add GZIP support for responses > 1000bytes
* increment version
---
app/__init__.py | 2 +-
app/main.py | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/__init__.py b/app/__init__.py
index c43ae7ac..57721529 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -4,4 +4,4 @@
API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak.
"""
# See PEP396.
-__version__ = "2.0.1"
+__version__ = "2.0.3"
diff --git a/app/main.py b/app/main.py
index 437b2395..1224c24e 100644
--- a/app/main.py
+++ b/app/main.py
@@ -8,6 +8,7 @@
import uvicorn
from fastapi import FastAPI, Request, Response
from fastapi.middleware.cors import CORSMiddleware
+from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import JSONResponse
from .data import data_source
@@ -26,7 +27,7 @@
"API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak."
" Project page: https://github.com/ExpDev07/coronavirus-tracker-api."
),
- version="2.0.2",
+ version="2.0.3",
docs_url="/",
redoc_url="/docs",
on_startup=[setup_client_session],
@@ -41,6 +42,7 @@
APP.add_middleware(
CORSMiddleware, allow_credentials=True, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"],
)
+APP.add_middleware(GZipMiddleware, minimum_size=1000)
@APP.middleware("http")
From 0d1ff7458e9b032f8aa22fca03f2e79a5e202538 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sat, 18 Apr 2020 16:42:33 -0400
Subject: [PATCH 41/61] add minimal logging for location services (#290)
---
app/services/location/csbs.py | 7 +++++++
app/services/location/jhu.py | 7 +++++++
app/services/location/nyt.py | 7 +++++++
3 files changed, 21 insertions(+)
diff --git a/app/services/location/csbs.py b/app/services/location/csbs.py
index dbd8d82d..d0de3837 100644
--- a/app/services/location/csbs.py
+++ b/app/services/location/csbs.py
@@ -1,5 +1,6 @@
"""app.services.location.csbs.py"""
import csv
+import logging
from datetime import datetime
from asyncache import cached
@@ -39,10 +40,15 @@ async def get_locations():
:returns: The locations.
:rtype: dict
"""
+ logger = logging.getLogger("services.location.csbs")
+ logger.info("Requesting data...")
async with httputils.CLIENT_SESSION.get(BASE_URL) as response:
text = await response.text()
+ logger.info("Data received")
+
data = list(csv.DictReader(text.splitlines()))
+ logger.info("CSV parsed")
locations = []
@@ -77,6 +83,7 @@ async def get_locations():
int(item["Death"] or 0),
)
)
+ logger.info("Data normalized")
# Return the locations.
return locations
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index 316de367..39e07ac2 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -1,5 +1,6 @@
"""app.services.location.jhu.py"""
import csv
+import logging
from datetime import datetime
from asyncache import cached
@@ -47,6 +48,7 @@ async def get_category(category):
:returns: The data for category.
:rtype: dict
"""
+ logger = logging.getLogger("services.location.jhu")
# Adhere to category naming standard.
category = category.lower()
@@ -55,11 +57,15 @@ async def get_category(category):
url = BASE_URL + "time_series_covid19_%s_global.csv" % category
# Request the data
+ logger.info("Requesting data...")
async with httputils.CLIENT_SESSION.get(url) as response:
text = await response.text()
+ logger.info("Data received")
+
# Parse the CSV.
data = list(csv.DictReader(text.splitlines()))
+ logger.info("CSV parsed")
# The normalized locations.
locations = []
@@ -92,6 +98,7 @@ async def get_category(category):
"latest": int(latest or 0),
}
)
+ logger.info("Data normalized")
# Latest total.
latest = sum(map(lambda location: location["latest"], locations))
diff --git a/app/services/location/nyt.py b/app/services/location/nyt.py
index 7f73c1de..7f12eb62 100644
--- a/app/services/location/nyt.py
+++ b/app/services/location/nyt.py
@@ -1,5 +1,6 @@
"""app.services.location.nyt.py"""
import csv
+import logging
from datetime import datetime
from asyncache import cached
@@ -71,13 +72,18 @@ async def get_locations():
:returns: The complete data for US Counties.
:rtype: dict
"""
+ logger = logging.getLogger("services.location.nyt")
# Request the data.
+ logger.info("Requesting data...")
async with httputils.CLIENT_SESSION.get(BASE_URL) as response:
text = await response.text()
+ logger.info("Data received")
+
# Parse the CSV.
data = list(csv.DictReader(text.splitlines()))
+ logger.info("CSV parsed")
# Group together locations (NYT data ordered by dates not location).
grouped_locations = get_grouped_locations_dict(data)
@@ -119,5 +125,6 @@ async def get_locations():
},
)
)
+ logger.info("Data normalized")
return locations
From 56f51c5880b541c469ebb0176ec826f0da900e1e Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sat, 18 Apr 2020 17:19:50 -0400
Subject: [PATCH 42/61] Population backup (#291)
* add io module
for writing to and reading from the file-system
* use io module to save and load population data backups
* add responses test dependency (update deps)
* test population fallback conditions
* don't write to file-system by default
* update population fallback data
---
Pipfile | 7 +-
Pipfile.lock | 241 ++++++++++----------
app/data/geonames_population_mappings.json | 252 +++++++++++++++++++++
app/io.py | 28 +++
app/utils/populations.py | 27 ++-
requirements-dev.txt | 23 +-
requirements.txt | 12 +-
tests/test_io.py | 39 ++++
tests/test_populations.py | 77 +++++++
9 files changed, 564 insertions(+), 142 deletions(-)
create mode 100644 app/data/geonames_population_mappings.json
create mode 100644 app/io.py
create mode 100644 tests/test_io.py
create mode 100644 tests/test_populations.py
diff --git a/Pipfile b/Pipfile
index b337c22a..9a0839af 100644
--- a/Pipfile
+++ b/Pipfile
@@ -10,22 +10,23 @@ asyncmock = "*"
bandit = "*"
black = "==19.10b0"
coveralls = "*"
-importlib-metadata = {version="*", markers="python_version<'3.8'"}
+importlib-metadata = {version = "*",markers = "python_version<'3.8'"}
invoke = "*"
isort = "*"
pylint = "*"
pytest = "*"
pytest-asyncio = "*"
pytest-cov = "*"
+responses = "*"
[packages]
aiohttp = "*"
asyncache = "*"
cachetools = "*"
-dataclasses = {version="*", markers="python_version<'3.7'"}
+dataclasses = {version = "*",markers = "python_version<'3.7'"}
fastapi = "*"
gunicorn = "*"
-idna_ssl = {version="*", markers="python_version<'3.7'"}
+idna_ssl = {version = "*",markers = "python_version<'3.7'"}
python-dateutil = "*"
python-dotenv = "*"
requests = "*"
diff --git a/Pipfile.lock b/Pipfile.lock
index a699f880..9ac79d0f 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "1911b081cecdda482b2a9c7c03ebba985c447846506b607df01563600c23126b"
+ "sha256": "9c469c96db1ae3a7e4c239d3a9c7028ecf49a0ab5e3ea50aed304ea2ab1a113e"
},
"pipfile-spec": 6,
"requires": {
@@ -57,18 +57,18 @@
},
"cachetools": {
"hashes": [
- "sha256:9a52dd97a85f257f4e4127f15818e71a0c7899f121b34591fcc1173ea79a0198",
- "sha256:b304586d357c43221856be51d73387f93e2a961598a9b6b6670664746f3b6c6c"
+ "sha256:1d057645db16ca7fe1f3bd953558897603d6f0b9c51ed9d11eb4d071ec4e2aab",
+ "sha256:de5d88f87781602201cde465d3afe837546663b168e8b39df67411b0bf10cefc"
],
"index": "pypi",
- "version": "==4.0.0"
+ "version": "==4.1.0"
},
"certifi": {
"hashes": [
- "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3",
- "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"
+ "sha256:1d987a998c75633c40847cc966fcf5904906c920a7f17ef374f5aa4282abd304",
+ "sha256:51fcb31174be6e6664c5f69e3e1691a2d72a1a12e90f872cbdb1567eb47b6519"
],
- "version": "==2019.11.28"
+ "version": "==2020.4.5.1"
},
"chardet": {
"hashes": [
@@ -95,11 +95,11 @@
},
"fastapi": {
"hashes": [
- "sha256:a5cb9100d5f2b5dd82addbc2cdf8009258bce45b03ba21d3f5eecc88c7b5a716",
- "sha256:cf26d47ede6bc6e179df951312f55fea7d4005dd53370245e216436ca4e22f22"
+ "sha256:1ee9a49f28d510b62b3b51a9452b274853bfc9c5d4b947ed054366e2d49f9efa",
+ "sha256:72f40f47e5235cb5cbbad1d4f97932ede6059290c07e12e9784028dcd1063d28"
],
"index": "pypi",
- "version": "==0.53.2"
+ "version": "==0.54.1"
},
"gunicorn": {
"hashes": [
@@ -173,22 +173,25 @@
},
"pydantic": {
"hashes": [
- "sha256:012c422859bac2e03ab3151ea6624fecf0e249486be7eb8c6ee69c91740c6752",
- "sha256:07911aab70f3bc52bb845ce1748569c5e70478ac977e106a150dd9d0465ebf04",
- "sha256:47b8db7024ba3d46c3d4768535e1cf87b6c8cf92ccd81e76f4e1cb8ee47688b3",
- "sha256:50e4e948892a6815649ad5a9a9379ad1e5f090f17842ac206535dfaed75c6f2f",
- "sha256:51f11c8bbf794a68086540da099aae4a9107447c7a9d63151edbb7d50110cf21",
- "sha256:6100d7862371115c40be55cc4b8d766a74b1d0dbaf99dbfe72bb4bac0faf89ed",
- "sha256:61d22d36808087d3184ed6ac0d91dd71c533b66addb02e4a9930e1e30833202f",
- "sha256:72184c1421103cca128300120f8f1185fb42a9ea73a1c9845b1c53db8c026a7d",
- "sha256:831a0265a9e3933b3d0f04d1a81bba543bafbe4119c183ff2771871db70524ab",
- "sha256:8848b4eb458469739126e4c1a202d723dd092e087f8dbe3104371335f87ba5df",
- "sha256:bbbed364376f4a0aebb9ea452ff7968b306499a9e74f4db69b28ff2cd4043a11",
- "sha256:e27559cedbd7f59d2375bfd6eea29a330ea1a5b0589c34d6b4e0d7bec6027bbf",
- "sha256:f17ec336e64d4583311249fb179528e9a2c27c8a2eaf590ec6ec2c6dece7cb3f",
- "sha256:f863456d3d4bf817f2e5248553dee3974c5dc796f48e6ddb599383570f4215ac"
- ],
- "version": "==1.4"
+ "sha256:0b7aadfa1de28057656064e04d9f018d1b186fe2a8e953a2fb41545873b7cf95",
+ "sha256:0f61e67291b99a927816558a218a4e794db72a33621c836e63d12613a2202cd4",
+ "sha256:20946280c750753b3e3177c748825ef189d7ab86c514f6a0b118621110d5f0d3",
+ "sha256:22139ee446992c222977ac0a9269c4da2e9ecc1834f84804ebde008a4649b929",
+ "sha256:3c0f39e884d7a3572d5cc8322b0fe9bf66114283e22e05a5c4b8961c19588945",
+ "sha256:446ce773a552a2cb90065d4aa645e16fa7494369b5f0d199e4d41a992a98204d",
+ "sha256:475e6606873e40717cc3b0eebc7d1101cbfc774e01dadeeea24c121eb5826b86",
+ "sha256:66124752662de0479a9d0c17bdebdc8a889bccad8846626fb66d8669e8eafb63",
+ "sha256:896637b7d8e4cdc0bcee1704fcadacdd167c35ac29f02a4395fce7a033925f26",
+ "sha256:9af44d06db33896a2176603c9cb876df3a60297a292a24d3018956a910cc1402",
+ "sha256:9e46fac8a4674db0777fd0133aa56817e1481beee50971bab39dded7639f9b2b",
+ "sha256:ae206e103e976c40ec294cd6c8fcbfbdaced3ab9b736bc53d03fa11b5aaa1628",
+ "sha256:b11d0bd7ecf41098894e8777ee623c29554dbaa37e862c51bcc5a2b950d1bf77",
+ "sha256:d73070028f7b046a5b2e611a9799c238d7bd245f8fe30f4ad7ff29ddb63aac40",
+ "sha256:ddedcdf9d5c24939578449a8e099ceeec3b3d76243fc143aff63ebf6d5aade10",
+ "sha256:e08e21f4d5395ac17cde19de26be63fb16fb870f0cfde1481ddc22d5e2353548",
+ "sha256:e6239199b363bc53262bcb57f1441206d4b2d46b392eccba2213d8358d6e284a"
+ ],
+ "version": "==1.5"
},
"python-dateutil": {
"hashes": [
@@ -200,11 +203,11 @@
},
"python-dotenv": {
"hashes": [
- "sha256:81822227f771e0cab235a2939f0f265954ac4763cafd806d845801c863bf372f",
- "sha256:92b3123fb2d58a284f76cc92bfe4ee6c502c32ded73e8b051c4f6afc8b6751ed"
+ "sha256:25c0ff1a3e12f4bde8d592cc254ab075cfe734fc5dd989036716fd17ee7e5ec7",
+ "sha256:3b9909bc96b0edc6b01586e1eed05e71174ef4e04c71da5786370cebea53ad74"
],
"index": "pypi",
- "version": "==0.12.0"
+ "version": "==0.13.0"
},
"requests": {
"hashes": [
@@ -230,10 +233,10 @@
},
"urllib3": {
"hashes": [
- "sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc",
- "sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc"
+ "sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527",
+ "sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
],
- "version": "==1.25.8"
+ "version": "==1.25.9"
},
"uvicorn": {
"hashes": [
@@ -371,10 +374,10 @@
},
"certifi": {
"hashes": [
- "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3",
- "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"
+ "sha256:1d987a998c75633c40847cc966fcf5904906c920a7f17ef374f5aa4282abd304",
+ "sha256:51fcb31174be6e6664c5f69e3e1691a2d72a1a12e90f872cbdb1567eb47b6519"
],
- "version": "==2019.11.28"
+ "version": "==2020.4.5.1"
},
"chardet": {
"hashes": [
@@ -392,47 +395,47 @@
},
"coverage": {
"hashes": [
- "sha256:03f630aba2b9b0d69871c2e8d23a69b7fe94a1e2f5f10df5049c0df99db639a0",
- "sha256:046a1a742e66d065d16fb564a26c2a15867f17695e7f3d358d7b1ad8a61bca30",
- "sha256:0a907199566269e1cfa304325cc3b45c72ae341fbb3253ddde19fa820ded7a8b",
- "sha256:165a48268bfb5a77e2d9dbb80de7ea917332a79c7adb747bd005b3a07ff8caf0",
- "sha256:1b60a95fc995649464e0cd48cecc8288bac5f4198f21d04b8229dc4097d76823",
- "sha256:1f66cf263ec77af5b8fe14ef14c5e46e2eb4a795ac495ad7c03adc72ae43fafe",
- "sha256:2e08c32cbede4a29e2a701822291ae2bc9b5220a971bba9d1e7615312efd3037",
- "sha256:3844c3dab800ca8536f75ae89f3cf566848a3eb2af4d9f7b1103b4f4f7a5dad6",
- "sha256:408ce64078398b2ee2ec08199ea3fcf382828d2f8a19c5a5ba2946fe5ddc6c31",
- "sha256:443be7602c790960b9514567917af538cac7807a7c0c0727c4d2bbd4014920fd",
- "sha256:4482f69e0701139d0f2c44f3c395d1d1d37abd81bfafbf9b6efbe2542679d892",
- "sha256:4a8a259bf990044351baf69d3b23e575699dd60b18460c71e81dc565f5819ac1",
- "sha256:513e6526e0082c59a984448f4104c9bf346c2da9961779ede1fc458e8e8a1f78",
- "sha256:5f587dfd83cb669933186661a351ad6fc7166273bc3e3a1531ec5c783d997aac",
- "sha256:62061e87071497951155cbccee487980524d7abea647a1b2a6eb6b9647df9006",
- "sha256:641e329e7f2c01531c45c687efcec8aeca2a78a4ff26d49184dce3d53fc35014",
- "sha256:65a7e00c00472cd0f59ae09d2fb8a8aaae7f4a0cf54b2b74f3138d9f9ceb9cb2",
- "sha256:6ad6ca45e9e92c05295f638e78cd42bfaaf8ee07878c9ed73e93190b26c125f7",
- "sha256:73aa6e86034dad9f00f4bbf5a666a889d17d79db73bc5af04abd6c20a014d9c8",
- "sha256:7c9762f80a25d8d0e4ab3cb1af5d9dffbddb3ee5d21c43e3474c84bf5ff941f7",
- "sha256:85596aa5d9aac1bf39fe39d9fa1051b0f00823982a1de5766e35d495b4a36ca9",
- "sha256:86a0ea78fd851b313b2e712266f663e13b6bc78c2fb260b079e8b67d970474b1",
- "sha256:8a620767b8209f3446197c0e29ba895d75a1e272a36af0786ec70fe7834e4307",
- "sha256:922fb9ef2c67c3ab20e22948dcfd783397e4c043a5c5fa5ff5e9df5529074b0a",
- "sha256:9fad78c13e71546a76c2f8789623eec8e499f8d2d799f4b4547162ce0a4df435",
- "sha256:a37c6233b28e5bc340054cf6170e7090a4e85069513320275a4dc929144dccf0",
- "sha256:c3fc325ce4cbf902d05a80daa47b645d07e796a80682c1c5800d6ac5045193e5",
- "sha256:cda33311cb9fb9323958a69499a667bd728a39a7aa4718d7622597a44c4f1441",
- "sha256:db1d4e38c9b15be1521722e946ee24f6db95b189d1447fa9ff18dd16ba89f732",
- "sha256:eda55e6e9ea258f5e4add23bcf33dc53b2c319e70806e180aecbff8d90ea24de",
- "sha256:f372cdbb240e09ee855735b9d85e7f50730dcfb6296b74b95a3e5dea0615c4c1"
- ],
- "version": "==5.0.4"
+ "sha256:00f1d23f4336efc3b311ed0d807feb45098fc86dee1ca13b3d6768cdab187c8a",
+ "sha256:01333e1bd22c59713ba8a79f088b3955946e293114479bbfc2e37d522be03355",
+ "sha256:0cb4be7e784dcdc050fc58ef05b71aa8e89b7e6636b99967fadbdba694cf2b65",
+ "sha256:0e61d9803d5851849c24f78227939c701ced6704f337cad0a91e0972c51c1ee7",
+ "sha256:1601e480b9b99697a570cea7ef749e88123c04b92d84cedaa01e117436b4a0a9",
+ "sha256:2742c7515b9eb368718cd091bad1a1b44135cc72468c731302b3d641895b83d1",
+ "sha256:2d27a3f742c98e5c6b461ee6ef7287400a1956c11421eb574d843d9ec1f772f0",
+ "sha256:402e1744733df483b93abbf209283898e9f0d67470707e3c7516d84f48524f55",
+ "sha256:5c542d1e62eece33c306d66fe0a5c4f7f7b3c08fecc46ead86d7916684b36d6c",
+ "sha256:5f2294dbf7875b991c381e3d5af2bcc3494d836affa52b809c91697449d0eda6",
+ "sha256:6402bd2fdedabbdb63a316308142597534ea8e1895f4e7d8bf7476c5e8751fef",
+ "sha256:66460ab1599d3cf894bb6baee8c684788819b71a5dc1e8fa2ecc152e5d752019",
+ "sha256:782caea581a6e9ff75eccda79287daefd1d2631cc09d642b6ee2d6da21fc0a4e",
+ "sha256:79a3cfd6346ce6c13145731d39db47b7a7b859c0272f02cdb89a3bdcbae233a0",
+ "sha256:7a5bdad4edec57b5fb8dae7d3ee58622d626fd3a0be0dfceda162a7035885ecf",
+ "sha256:8fa0cbc7ecad630e5b0f4f35b0f6ad419246b02bc750de7ac66db92667996d24",
+ "sha256:a027ef0492ede1e03a8054e3c37b8def89a1e3c471482e9f046906ba4f2aafd2",
+ "sha256:a3f3654d5734a3ece152636aad89f58afc9213c6520062db3978239db122f03c",
+ "sha256:a82b92b04a23d3c8a581fc049228bafde988abacba397d57ce95fe95e0338ab4",
+ "sha256:acf3763ed01af8410fc36afea23707d4ea58ba7e86a8ee915dfb9ceff9ef69d0",
+ "sha256:adeb4c5b608574a3d647011af36f7586811a2c1197c861aedb548dd2453b41cd",
+ "sha256:b83835506dfc185a319031cf853fa4bb1b3974b1f913f5bb1a0f3d98bdcded04",
+ "sha256:bb28a7245de68bf29f6fb199545d072d1036a1917dca17a1e75bbb919e14ee8e",
+ "sha256:bf9cb9a9fd8891e7efd2d44deb24b86d647394b9705b744ff6f8261e6f29a730",
+ "sha256:c317eaf5ff46a34305b202e73404f55f7389ef834b8dbf4da09b9b9b37f76dd2",
+ "sha256:dbe8c6ae7534b5b024296464f387d57c13caa942f6d8e6e0346f27e509f0f768",
+ "sha256:de807ae933cfb7f0c7d9d981a053772452217df2bf38e7e6267c9cbf9545a796",
+ "sha256:dead2ddede4c7ba6cb3a721870f5141c97dc7d85a079edb4bd8d88c3ad5b20c7",
+ "sha256:dec5202bfe6f672d4511086e125db035a52b00f1648d6407cc8e526912c0353a",
+ "sha256:e1ea316102ea1e1770724db01998d1603ed921c54a86a2efcb03428d5417e489",
+ "sha256:f90bfc4ad18450c80b024036eaf91e4a246ae287701aaa88eaebebf150868052"
+ ],
+ "version": "==5.1"
},
"coveralls": {
"hashes": [
- "sha256:4b6bfc2a2a77b890f556bc631e35ba1ac21193c356393b66c84465c06218e135",
- "sha256:67188c7ec630c5f708c31552f2bcdac4580e172219897c4136504f14b823132f"
+ "sha256:41bd57b60321dfd5b56e990ab3f7ed876090691c21a9e3b005e1f6e42e6ba4b9",
+ "sha256:d213f5edd49053d03f0db316ccabfe17725f2758147afc9a37eaca9d8e8602b5"
],
"index": "pypi",
- "version": "==1.11.1"
+ "version": "==2.0.0"
},
"docopt": {
"hashes": [
@@ -442,17 +445,17 @@
},
"gitdb": {
"hashes": [
- "sha256:284a6a4554f954d6e737cddcff946404393e030b76a282c6640df8efd6b3da5e",
- "sha256:598e0096bb3175a0aab3a0b5aedaa18a9a25c6707e0eca0695ba1a0baf1b2150"
+ "sha256:6f0ecd46f99bb4874e5678d628c3a198e2b4ef38daea2756a2bfd8df7dd5c1a5",
+ "sha256:ba1132c0912e8c917aa8aa990bee26315064c7b7f171ceaaac0afeb1dc656c6a"
],
- "version": "==4.0.2"
+ "version": "==4.0.4"
},
"gitpython": {
"hashes": [
- "sha256:43da89427bdf18bf07f1164c6d415750693b4d50e28fc9b68de706245147b9dd",
- "sha256:e426c3b587bd58c482f0b7fe6145ff4ac7ae6c82673fc656f489719abca6f4cb"
+ "sha256:6d4f10e2aaad1864bb0f17ec06a2c2831534140e5883c350d58b4e85189dab74",
+ "sha256:71b8dad7409efbdae4930f2b0b646aaeccce292484ffa0bc74f1195582578b3d"
],
- "version": "==3.1.0"
+ "version": "==3.1.1"
},
"idna": {
"hashes": [
@@ -565,17 +568,17 @@
},
"pathspec": {
"hashes": [
- "sha256:163b0632d4e31cef212976cf57b43d9fd6b0bac6e67c26015d611a647d5e7424",
- "sha256:562aa70af2e0d434367d9790ad37aed893de47f1693e4201fd1d3dca15d19b96"
+ "sha256:7d91249d21749788d07a2d0f94147accd8f845507400749ea19c1ec9054a12b0",
+ "sha256:da45173eb3a6f2a5a487efba21f050af2b41948be6ab52b6a1e3ff22bb8b7061"
],
- "version": "==0.7.0"
+ "version": "==0.8.0"
},
"pbr": {
"hashes": [
- "sha256:139d2625547dbfa5fb0b81daebb39601c478c21956dc57e2e07b74450a8c506b",
- "sha256:61aa52a0f18b71c5cc58232d2cf8f8d09cd67fcad60b742a60124cb8d6951488"
+ "sha256:07f558fece33b05caf857474a366dfcc00562bca13dd8b47b2b3e22d9f9bf55c",
+ "sha256:579170e23f8e0c2f24b0de612f71f648eccb79fb1322c814ae6b3c07b5ba23e8"
],
- "version": "==5.4.4"
+ "version": "==5.4.5"
},
"pluggy": {
"hashes": [
@@ -601,10 +604,10 @@
},
"pyparsing": {
"hashes": [
- "sha256:4c830582a84fb022400b85429791bc551f1f4871c33f23e44f353119e92f969f",
- "sha256:c342dccb5250c08d45fd6f8b4a559613ca603b57498511740e65cd11a2e7dcec"
+ "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1",
+ "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
],
- "version": "==2.4.6"
+ "version": "==2.4.7"
},
"pytest": {
"hashes": [
@@ -648,29 +651,29 @@
},
"regex": {
"hashes": [
- "sha256:01b2d70cbaed11f72e57c1cfbaca71b02e3b98f739ce33f5f26f71859ad90431",
- "sha256:046e83a8b160aff37e7034139a336b660b01dbfe58706f9d73f5cdc6b3460242",
- "sha256:113309e819634f499d0006f6200700c8209a2a8bf6bd1bdc863a4d9d6776a5d1",
- "sha256:200539b5124bc4721247a823a47d116a7a23e62cc6695744e3eb5454a8888e6d",
- "sha256:25f4ce26b68425b80a233ce7b6218743c71cf7297dbe02feab1d711a2bf90045",
- "sha256:269f0c5ff23639316b29f31df199f401e4cb87529eafff0c76828071635d417b",
- "sha256:5de40649d4f88a15c9489ed37f88f053c15400257eeb18425ac7ed0a4e119400",
- "sha256:7f78f963e62a61e294adb6ff5db901b629ef78cb2a1cfce3cf4eeba80c1c67aa",
- "sha256:82469a0c1330a4beb3d42568f82dffa32226ced006e0b063719468dcd40ffdf0",
- "sha256:8c2b7fa4d72781577ac45ab658da44c7518e6d96e2a50d04ecb0fd8f28b21d69",
- "sha256:974535648f31c2b712a6b2595969f8ab370834080e00ab24e5dbb9d19b8bfb74",
- "sha256:99272d6b6a68c7ae4391908fc15f6b8c9a6c345a46b632d7fdb7ef6c883a2bbb",
- "sha256:9b64a4cc825ec4df262050c17e18f60252cdd94742b4ba1286bcfe481f1c0f26",
- "sha256:9e9624440d754733eddbcd4614378c18713d2d9d0dc647cf9c72f64e39671be5",
- "sha256:9ff16d994309b26a1cdf666a6309c1ef51ad4f72f99d3392bcd7b7139577a1f2",
- "sha256:b33ebcd0222c1d77e61dbcd04a9fd139359bded86803063d3d2d197b796c63ce",
- "sha256:bba52d72e16a554d1894a0cc74041da50eea99a8483e591a9edf1025a66843ab",
- "sha256:bed7986547ce54d230fd8721aba6fd19459cdc6d315497b98686d0416efaff4e",
- "sha256:c7f58a0e0e13fb44623b65b01052dae8e820ed9b8b654bb6296bc9c41f571b70",
- "sha256:d58a4fa7910102500722defbde6e2816b0372a4fcc85c7e239323767c74f5cbc",
- "sha256:f1ac2dc65105a53c1c2d72b1d3e98c2464a133b4067a51a3d2477b28449709a0"
- ],
- "version": "==2020.2.20"
+ "sha256:08119f707f0ebf2da60d2f24c2f39ca616277bb67ef6c92b72cbf90cbe3a556b",
+ "sha256:0ce9537396d8f556bcfc317c65b6a0705320701e5ce511f05fc04421ba05b8a8",
+ "sha256:1cbe0fa0b7f673400eb29e9ef41d4f53638f65f9a2143854de6b1ce2899185c3",
+ "sha256:2294f8b70e058a2553cd009df003a20802ef75b3c629506be20687df0908177e",
+ "sha256:23069d9c07e115537f37270d1d5faea3e0bdded8279081c4d4d607a2ad393683",
+ "sha256:24f4f4062eb16c5bbfff6a22312e8eab92c2c99c51a02e39b4eae54ce8255cd1",
+ "sha256:295badf61a51add2d428a46b8580309c520d8b26e769868b922750cf3ce67142",
+ "sha256:2a3bf8b48f8e37c3a40bb3f854bf0121c194e69a650b209628d951190b862de3",
+ "sha256:4385f12aa289d79419fede43f979e372f527892ac44a541b5446617e4406c468",
+ "sha256:5635cd1ed0a12b4c42cce18a8d2fb53ff13ff537f09de5fd791e97de27b6400e",
+ "sha256:5bfed051dbff32fd8945eccca70f5e22b55e4148d2a8a45141a3b053d6455ae3",
+ "sha256:7e1037073b1b7053ee74c3c6c0ada80f3501ec29d5f46e42669378eae6d4405a",
+ "sha256:90742c6ff121a9c5b261b9b215cb476eea97df98ea82037ec8ac95d1be7a034f",
+ "sha256:a58dd45cb865be0ce1d5ecc4cfc85cd8c6867bea66733623e54bd95131f473b6",
+ "sha256:c087bff162158536387c53647411db09b6ee3f9603c334c90943e97b1052a156",
+ "sha256:c162a21e0da33eb3d31a3ac17a51db5e634fc347f650d271f0305d96601dc15b",
+ "sha256:c9423a150d3a4fc0f3f2aae897a59919acd293f4cb397429b120a5fcd96ea3db",
+ "sha256:ccccdd84912875e34c5ad2d06e1989d890d43af6c2242c6fcfa51556997af6cd",
+ "sha256:e91ba11da11cf770f389e47c3f5c30473e6d85e06d7fd9dcba0017d2867aab4a",
+ "sha256:ea4adf02d23b437684cd388d557bf76e3afa72f7fed5bbc013482cc00c816948",
+ "sha256:fb95debbd1a824b2c4376932f2216cc186912e389bdb0e27147778cf6acb3f89"
+ ],
+ "version": "==2020.4.4"
},
"requests": {
"hashes": [
@@ -680,6 +683,14 @@
"index": "pypi",
"version": "==2.23.0"
},
+ "responses": {
+ "hashes": [
+ "sha256:0474ce3c897fbcc1aef286117c93499882d5c440f06a805947e4b1cb5ab3d474",
+ "sha256:f83613479a021e233e82d52ffb3e2e0e2836d24b0cc88a0fa31978789f78d0e5"
+ ],
+ "index": "pypi",
+ "version": "==0.10.12"
+ },
"six": {
"hashes": [
"sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a",
@@ -689,10 +700,10 @@
},
"smmap": {
"hashes": [
- "sha256:171484fe62793e3626c8b05dd752eb2ca01854b0c55a1efc0dc4210fccb65446",
- "sha256:5fead614cf2de17ee0707a8c6a5f2aa5a2fc6c698c70993ba42f515485ffda78"
+ "sha256:52ea78b3e708d2c2b0cfe93b6fc3fbeec53db913345c26be6ed84c11ed8bebc1",
+ "sha256:b46d3fc69ba5f367df96d91f8271e8ad667a198d5a28e215a6c3d9acd133a911"
],
- "version": "==3.0.1"
+ "version": "==3.0.2"
},
"stevedore": {
"hashes": [
@@ -736,10 +747,10 @@
},
"urllib3": {
"hashes": [
- "sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc",
- "sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc"
+ "sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527",
+ "sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
],
- "version": "==1.25.8"
+ "version": "==1.25.9"
},
"wcwidth": {
"hashes": [
diff --git a/app/data/geonames_population_mappings.json b/app/data/geonames_population_mappings.json
new file mode 100644
index 00000000..7b293caa
--- /dev/null
+++ b/app/data/geonames_population_mappings.json
@@ -0,0 +1,252 @@
+{
+ "AD": 77006,
+ "AE": 9630959,
+ "AF": 37172386,
+ "AG": 96286,
+ "AI": 13254,
+ "AL": 2866376,
+ "AM": 2951776,
+ "AO": 30809762,
+ "AQ": null,
+ "AR": 44494502,
+ "AS": 55465,
+ "AT": 8847037,
+ "AU": 24992369,
+ "AW": 105845,
+ "AX": 26711,
+ "AZ": 9942334,
+ "BA": 3323929,
+ "BB": 286641,
+ "BD": 161356039,
+ "BE": 11422068,
+ "BF": 19751535,
+ "BG": 7000039,
+ "BH": 1569439,
+ "BI": 11175378,
+ "BJ": 11485048,
+ "BL": 8450,
+ "BM": 63968,
+ "BN": 428962,
+ "BO": 11353142,
+ "BQ": 18012,
+ "BR": 209469333,
+ "BS": 385640,
+ "BT": 754394,
+ "BV": null,
+ "BW": 2254126,
+ "BY": 9485386,
+ "BZ": 383071,
+ "CA": 37058856,
+ "CC": 628,
+ "CD": 84068091,
+ "CF": 4666377,
+ "CG": 5244363,
+ "CH": 8516543,
+ "CI": 25069229,
+ "CK": 21388,
+ "CL": 18729160,
+ "CM": 25216237,
+ "CN": 1392730000,
+ "CO": 49648685,
+ "CR": 4999441,
+ "CU": 11338138,
+ "CV": 543767,
+ "CW": 159849,
+ "CX": 1500,
+ "CY": 1189265,
+ "CZ": 10625695,
+ "DE": 82927922,
+ "DJ": 958920,
+ "DK": 5797446,
+ "DM": 71625,
+ "DO": 10627165,
+ "DZ": 42228429,
+ "EC": 17084357,
+ "EE": 1320884,
+ "EG": 98423595,
+ "EH": 273008,
+ "ER": null,
+ "ES": 46723749,
+ "ET": 109224559,
+ "FI": 5518050,
+ "FJ": 883483,
+ "FK": 2638,
+ "FM": 112640,
+ "FO": 48497,
+ "FR": 66987244,
+ "GA": 2119275,
+ "GB": 66488991,
+ "GD": 111454,
+ "GE": 3731000,
+ "GF": 195506,
+ "GG": 65228,
+ "GH": 29767108,
+ "GI": 33718,
+ "GL": 56025,
+ "GM": 2280102,
+ "GN": 12414318,
+ "GP": 443000,
+ "GQ": 1308974,
+ "GR": 10727668,
+ "GS": 30,
+ "GT": 17247807,
+ "GU": 165768,
+ "GW": 1874309,
+ "GY": 779004,
+ "HK": 7451000,
+ "HM": null,
+ "HN": 9587522,
+ "HR": 4089400,
+ "HT": 11123176,
+ "HU": 9768785,
+ "ID": 267663435,
+ "IE": 4853506,
+ "IL": 8883800,
+ "IM": 84077,
+ "IN": 1352617328,
+ "IO": 4000,
+ "IQ": 38433600,
+ "IR": 81800269,
+ "IS": 353574,
+ "IT": 60431283,
+ "JE": 90812,
+ "JM": 2934855,
+ "JO": 9956011,
+ "JP": 126529100,
+ "KE": 51393010,
+ "KG": 6315800,
+ "KH": 16249798,
+ "KI": 115847,
+ "KM": 832322,
+ "KN": 52441,
+ "KP": 25549819,
+ "KR": 51635256,
+ "KW": 4137309,
+ "KY": 64174,
+ "KZ": 18276499,
+ "LA": 7061507,
+ "LB": 6848925,
+ "LC": 181889,
+ "LI": 37910,
+ "LK": 21670000,
+ "LR": 4818977,
+ "LS": 2108132,
+ "LT": 2789533,
+ "LU": 607728,
+ "LV": 1926542,
+ "LY": 6678567,
+ "MA": 36029138,
+ "MC": 38682,
+ "MD": 3545883,
+ "ME": 622345,
+ "MF": 37264,
+ "MG": 26262368,
+ "MH": 58413,
+ "MK": 2082958,
+ "ML": 19077690,
+ "MM": 53708395,
+ "MN": 3170208,
+ "MO": 631636,
+ "MP": 56882,
+ "MQ": 432900,
+ "MR": 4403319,
+ "MS": 9341,
+ "MT": 483530,
+ "MU": 1265303,
+ "MV": 515696,
+ "MW": 17563749,
+ "MX": 126190788,
+ "MY": 31528585,
+ "MZ": 29495962,
+ "NA": 2448255,
+ "NC": 284060,
+ "NE": 22442948,
+ "NF": 1828,
+ "NG": 195874740,
+ "NI": 6465513,
+ "NL": 17231017,
+ "NO": 5314336,
+ "NP": 28087871,
+ "NR": 12704,
+ "NU": 2166,
+ "NZ": 4885500,
+ "OM": 4829483,
+ "PA": 4176873,
+ "PE": 31989256,
+ "PF": 277679,
+ "PG": 8606316,
+ "PH": 106651922,
+ "PK": 212215030,
+ "PL": 37978548,
+ "PM": 7012,
+ "PN": 46,
+ "PR": 3195153,
+ "PS": 4569087,
+ "PT": 10281762,
+ "PW": 17907,
+ "PY": 6956071,
+ "QA": 2781677,
+ "RE": 776948,
+ "RO": 19473936,
+ "RS": 6982084,
+ "RU": 144478050,
+ "RW": 12301939,
+ "SA": 33699947,
+ "SB": 652858,
+ "SC": 96762,
+ "SD": 41801533,
+ "SE": 10183175,
+ "SG": 5638676,
+ "SH": 7460,
+ "SI": 2067372,
+ "SJ": 2550,
+ "SK": 5447011,
+ "SL": 7650154,
+ "SM": 33785,
+ "SN": 15854360,
+ "SO": 15008154,
+ "SR": 575991,
+ "SS": 8260490,
+ "ST": 197700,
+ "SV": 6420744,
+ "SX": 40654,
+ "SY": 16906283,
+ "SZ": 1136191,
+ "TC": 37665,
+ "TD": 15477751,
+ "TF": 140,
+ "TG": 7889094,
+ "TH": 69428524,
+ "TJ": 9100837,
+ "TK": 1466,
+ "TL": 1267972,
+ "TM": 5850908,
+ "TN": 11565204,
+ "TO": 103197,
+ "TR": 82319724,
+ "TT": 1389858,
+ "TV": 11508,
+ "TW": 22894384,
+ "TZ": 56318348,
+ "UA": 44622516,
+ "UG": 42723139,
+ "UM": null,
+ "US": 327167434,
+ "UY": 3449299,
+ "UZ": 32955400,
+ "VA": 921,
+ "VC": 110211,
+ "VE": 28870195,
+ "VG": 29802,
+ "VI": 106977,
+ "VN": 95540395,
+ "VU": 292680,
+ "WF": 16025,
+ "WS": 196130,
+ "XK": 1845300,
+ "YE": 28498687,
+ "YT": 159042,
+ "ZA": 57779622,
+ "ZM": 17351822,
+ "ZW": 14439018
+}
\ No newline at end of file
diff --git a/app/io.py b/app/io.py
new file mode 100644
index 00000000..8130c146
--- /dev/null
+++ b/app/io.py
@@ -0,0 +1,28 @@
+"""app.io.py"""
+import json
+import pathlib
+from typing import Dict, Union
+
+HERE = pathlib.Path(__file__)
+DATA = HERE.joinpath("..", "data").resolve()
+
+
+def save(
+ name: str, content: Union[str, Dict], write_mode: str = "w", indent: int = 2, **json_dumps_kwargs
+) -> pathlib.Path:
+ """Save content to a file. If content is a dictionary, use json.dumps()."""
+ path = DATA / name
+ if isinstance(content, dict):
+ content = json.dumps(content, indent=indent, **json_dumps_kwargs)
+ with open(DATA / name, mode=write_mode) as f_out:
+ f_out.write(content)
+ return path
+
+
+def load(name: str, **json_kwargs) -> Union[str, Dict]:
+ """Loads content from a file. If file ends with '.json', call json.load() and return a Dictionary."""
+ path = DATA / name
+ with open(path) as f_in:
+ if path.suffix == ".json":
+ return json.load(f_in, **json_kwargs)
+ return f_in.read()
diff --git a/app/utils/populations.py b/app/utils/populations.py
index 1d8bd843..f5235fd4 100644
--- a/app/utils/populations.py
+++ b/app/utils/populations.py
@@ -1,16 +1,23 @@
"""app.utils.populations.py"""
+import json
import logging
import requests
+import app.io
+
LOGGER = logging.getLogger(__name__)
+GEONAMES_URL = "http://api.geonames.org/countryInfoJSON"
+GEONAMES_BACKUP_PATH = "geonames_population_mappings.json"
# Fetching of the populations.
-def fetch_populations():
+def fetch_populations(save=False):
"""
Returns a dictionary containing the population of each country fetched from the GeoNames.
https://www.geonames.org/
+ TODO: only skip writing to the filesystem when deployed with gunicorn, or handle concurent access, or use DB.
+
:returns: The mapping of populations.
:rtype: dict
"""
@@ -20,12 +27,18 @@ def fetch_populations():
mappings = {}
# Fetch the countries.
- countries = requests.get("http://api.geonames.org/countryInfoJSON?username=dperic").json()["geonames"]
-
- # Go through all the countries and perform the mapping.
- for country in countries:
- mappings.update({country["countryCode"]: int(country["population"]) or None})
-
+ try:
+ countries = requests.get(GEONAMES_URL, params={"username": "dperic"}, timeout=1.5).json()["geonames"]
+ # Go through all the countries and perform the mapping.
+ for country in countries:
+ mappings.update({country["countryCode"]: int(country["population"]) or None})
+
+ if mappings and save:
+ LOGGER.info(f"Saving population data to {app.io.save(GEONAMES_BACKUP_PATH, mappings)}")
+ except (json.JSONDecodeError, KeyError, requests.exceptions.Timeout) as err:
+ LOGGER.warning(f"Error pulling population data. {err.__class__.__name__}: {err}")
+ mappings = app.io.load(GEONAMES_BACKUP_PATH)
+ LOGGER.info(f"Using backup data from {GEONAMES_BACKUP_PATH}")
# Finally, return the mappings.
return mappings
diff --git a/requirements-dev.txt b/requirements-dev.txt
index e85f4e9c..374fb37c 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -7,14 +7,14 @@ asyncmock==0.4.2
attrs==19.3.0
bandit==1.6.2
black==19.10b0
-certifi==2019.11.28
+certifi==2020.4.5.1
chardet==3.0.4
click==7.1.1
-coverage==5.0.4
-coveralls==1.11.1
+coverage==5.1
+coveralls==2.0.0
docopt==0.6.2
-gitdb==4.0.2
-gitpython==3.1.0
+gitdb==4.0.4
+gitpython==3.1.1
idna==2.9
importlib-metadata==1.6.0 ; python_version < '3.8'
invoke==1.4.1
@@ -25,24 +25,25 @@ mock==4.0.2
more-itertools==8.2.0
multidict==4.7.5
packaging==20.3
-pathspec==0.7.0
-pbr==5.4.4
+pathspec==0.8.0
+pbr==5.4.5
pluggy==0.13.1
py==1.8.1
pylint==2.4.4
-pyparsing==2.4.6
+pyparsing==2.4.7
pytest-asyncio==0.10.0
pytest-cov==2.8.1
pytest==5.4.1
pyyaml==5.3.1
-regex==2020.2.20
+regex==2020.4.4
requests==2.23.0
+responses==0.10.12
six==1.14.0
-smmap==3.0.1
+smmap==3.0.2
stevedore==1.32.0
toml==0.10.0
typed-ast==1.4.1
-urllib3==1.25.8
+urllib3==1.25.9
wcwidth==0.1.9
wrapt==1.11.2
zipp==3.1.0
diff --git a/requirements.txt b/requirements.txt
index 0d7a2c46..bb9302b1 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,25 +3,25 @@ aiohttp==3.6.2
async-timeout==3.0.1
asyncache==0.1.1
attrs==19.3.0
-cachetools==4.0.0
-certifi==2019.11.28
+cachetools==4.1.0
+certifi==2020.4.5.1
chardet==3.0.4
click==7.1.1
dataclasses==0.6 ; python_version < '3.7'
-fastapi==0.53.2
+fastapi==0.54.1
gunicorn==20.0.4
h11==0.9.0
httptools==0.1.1 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
idna-ssl==1.1.0 ; python_version < '3.7'
idna==2.9
multidict==4.7.5
-pydantic==1.4
+pydantic==1.5
python-dateutil==2.8.1
-python-dotenv==0.12.0
+python-dotenv==0.13.0
requests==2.23.0
six==1.14.0
starlette==0.13.2
-urllib3==1.25.8
+urllib3==1.25.9
uvicorn==0.11.3
uvloop==0.14.0 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
websockets==8.1
diff --git a/tests/test_io.py b/tests/test_io.py
new file mode 100644
index 00000000..83639cc9
--- /dev/null
+++ b/tests/test_io.py
@@ -0,0 +1,39 @@
+"""test.test_io.py"""
+import string
+
+import pytest
+
+import app.io
+
+
+@pytest.mark.parametrize(
+ "name, content, kwargs",
+ [
+ ("test_file.txt", string.ascii_lowercase, {}),
+ ("test_json_file.json", {"a": 0, "b": 1, "c": 2}, {}),
+ ("test_custom_json.json", {"z": -1, "b": 1, "y": -2, "a": 0}, {"indent": 4, "sort_keys": True}),
+ ],
+)
+def test_save(tmp_path, name, content, kwargs):
+ test_path = tmp_path / name
+ assert not test_path.exists()
+
+ result = app.io.save(test_path, content, **kwargs)
+ assert result == test_path
+ assert test_path.exists()
+
+
+@pytest.mark.parametrize(
+ "name, content, kwargs",
+ [
+ ("test_file.txt", string.ascii_lowercase, {}),
+ ("test_json_file.json", {"a": 0, "b": 1, "c": 2}, {}),
+ ("test_custom_json.json", {"z": -1, "b": 1, "y": -2, "a": 0}, {"indent": 4, "sort_keys": True}),
+ ],
+)
+def test_round_trip(tmp_path, name, content, kwargs):
+ test_path = tmp_path / name
+ assert not test_path.exists()
+
+ app.io.save(test_path, content, **kwargs)
+ assert app.io.load(test_path) == content
diff --git a/tests/test_populations.py b/tests/test_populations.py
new file mode 100644
index 00000000..97a33f66
--- /dev/null
+++ b/tests/test_populations.py
@@ -0,0 +1,77 @@
+"""tests.test_populations.py"""
+import pytest
+import requests.exceptions
+import responses
+
+import app.io
+import app.utils.populations
+
+NOT_FOUND_HTML = """
+
+
+
+Error
+
+
+Not Found
+
+"""
+
+SAMPLE_GEONAMES_JSON = {
+ "geonames": [
+ {
+ "continent": "EU",
+ "capital": "Andorra la Vella",
+ "languages": "ca",
+ "geonameId": 3041565,
+ "south": 42.42874300100004,
+ "isoAlpha3": "AND",
+ "north": 42.65576500000003,
+ "fipsCode": "AN",
+ "population": "77006",
+ "east": 1.786576000000025,
+ "isoNumeric": "020",
+ "areaInSqKm": "468.0",
+ "countryCode": "AD",
+ "west": 1.413760001000071,
+ "countryName": "Andorra",
+ "continentName": "Europe",
+ "currencyCode": "EUR",
+ },
+ {
+ "continent": "AS",
+ "capital": "Abu Dhabi",
+ "languages": "ar-AE,fa,en,hi,ur",
+ "geonameId": 290557,
+ "south": 22.6315119400001,
+ "isoAlpha3": "ARE",
+ "north": 26.0693916590001,
+ "fipsCode": "AE",
+ "population": "9630959",
+ "east": 56.381222289,
+ "isoNumeric": "784",
+ "areaInSqKm": "82880.0",
+ "countryCode": "AE",
+ "west": 51.5904085340001,
+ "countryName": "United Arab Emirates",
+ "continentName": "Asia",
+ "currencyCode": "AED",
+ },
+ ]
+}
+
+
+@responses.activate
+@pytest.mark.parametrize(
+ "body_arg, json_arg",
+ [
+ (None, SAMPLE_GEONAMES_JSON),
+ (NOT_FOUND_HTML, None),
+ (None, {"foo": "bar"}),
+ (requests.exceptions.Timeout("Forced Timeout"), None),
+ ],
+)
+def test_fetch_populations(body_arg, json_arg):
+ responses.add(responses.GET, app.utils.populations.GEONAMES_URL, body=body_arg, json=json_arg)
+
+ assert app.utils.populations.fetch_populations()
From 5a605ec9fc272e3f7b805529e75722e16ddf56b3 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sat, 18 Apr 2020 18:20:36 -0400
Subject: [PATCH 43/61] Refactor (#289)
* merge model modules
* Combine end router modules
move version 2 endpoint definitions to single module
move version 1 endpoint definitions to single module
* remove enum subpackage
* add back warning suppression
* fix module names
* add source info to log message
* tweak and fix logging to showup on Heroku
---
app/__init__.py | 4 ++
app/enums/sources.py | 11 ----
app/main.py | 5 +-
app/{models/location.py => models.py} | 39 +++++++++++++-
app/models/latest.py | 19 -------
app/models/timeline.py | 22 --------
app/router/__init__.py | 8 ---
app/router/v1/__init__.py | 4 --
app/router/v1/all.py | 20 --------
app/router/v1/confirmed.py | 11 ----
app/router/v1/deaths.py | 11 ----
app/router/v1/recovered.py | 11 ----
app/router/v2/__init__.py | 4 --
app/router/v2/latest.py | 21 --------
app/router/v2/sources.py | 11 ----
app/routers/__init__.py | 3 ++
app/routers/v1.py | 47 +++++++++++++++++
app/{router/v2/locations.py => routers/v2.py} | 51 ++++++++++++++++---
app/services/location/csbs.py | 11 ++--
app/services/location/jhu.py | 12 ++---
app/services/location/nyt.py | 12 ++---
app/utils/countries.py | 2 +-
app/utils/populations.py | 3 +-
23 files changed, 157 insertions(+), 185 deletions(-)
delete mode 100644 app/enums/sources.py
rename app/{models/location.py => models.py} (56%)
delete mode 100644 app/models/latest.py
delete mode 100644 app/models/timeline.py
delete mode 100644 app/router/__init__.py
delete mode 100644 app/router/v1/__init__.py
delete mode 100644 app/router/v1/all.py
delete mode 100644 app/router/v1/confirmed.py
delete mode 100644 app/router/v1/deaths.py
delete mode 100644 app/router/v1/recovered.py
delete mode 100644 app/router/v2/__init__.py
delete mode 100644 app/router/v2/latest.py
delete mode 100644 app/router/v2/sources.py
create mode 100644 app/routers/__init__.py
create mode 100644 app/routers/v1.py
rename app/{router/v2/locations.py => routers/v2.py} (59%)
diff --git a/app/__init__.py b/app/__init__.py
index 57721529..7a7badd2 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -3,5 +3,9 @@
~~~~~~~~~~~~~~~~~~~~~~~~
API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak.
"""
+import logging
+
# See PEP396.
__version__ = "2.0.3"
+
+logging.basicConfig(level=logging.INFO)
diff --git a/app/enums/sources.py b/app/enums/sources.py
deleted file mode 100644
index 9fc00744..00000000
--- a/app/enums/sources.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from enum import Enum
-
-
-class Sources(str, Enum):
- """
- A source available for retrieving data.
- """
-
- jhu = "jhu"
- csbs = "csbs"
- nyt = "nyt"
diff --git a/app/main.py b/app/main.py
index 1224c24e..0ab95fdb 100644
--- a/app/main.py
+++ b/app/main.py
@@ -12,8 +12,7 @@
from fastapi.responses import JSONResponse
from .data import data_source
-from .router.v1 import V1
-from .router.v2 import V2
+from .routers import V1, V2
from .utils.httputils import setup_client_session, teardown_client_session
# ############
@@ -61,7 +60,7 @@ async def add_datasource(request: Request, call_next):
request.state.source = source
# Move on...
- LOGGER.info(f"source provided: {source.__class__.__name__}")
+ LOGGER.debug(f"source provided: {source.__class__.__name__}")
response = await call_next(request)
return response
diff --git a/app/models/location.py b/app/models.py
similarity index 56%
rename from app/models/location.py
rename to app/models.py
index 48fa4d74..8875a92c 100644
--- a/app/models/location.py
+++ b/app/models.py
@@ -1,9 +1,44 @@
+"""app.models.py"""
from typing import Dict, List
from pydantic import BaseModel
-from .latest import Latest
-from .timeline import Timelines
+
+class Latest(BaseModel):
+ """
+ Latest model.
+ """
+
+ confirmed: int
+ deaths: int
+ recovered: int
+
+
+class LatestResponse(BaseModel):
+ """
+ Response for latest.
+ """
+
+ latest: Latest
+
+
+class Timeline(BaseModel):
+ """
+ Timeline model.
+ """
+
+ latest: int
+ timeline: Dict[str, int] = {}
+
+
+class Timelines(BaseModel):
+ """
+ Timelines model.
+ """
+
+ confirmed: Timeline
+ deaths: Timeline
+ recovered: Timeline
class Location(BaseModel):
diff --git a/app/models/latest.py b/app/models/latest.py
deleted file mode 100644
index 6dcfd517..00000000
--- a/app/models/latest.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from pydantic import BaseModel
-
-
-class Latest(BaseModel):
- """
- Latest model.
- """
-
- confirmed: int
- deaths: int
- recovered: int
-
-
-class LatestResponse(BaseModel):
- """
- Response for latest.
- """
-
- latest: Latest
diff --git a/app/models/timeline.py b/app/models/timeline.py
deleted file mode 100644
index 453dfb14..00000000
--- a/app/models/timeline.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from typing import Dict
-
-from pydantic import BaseModel
-
-
-class Timeline(BaseModel):
- """
- Timeline model.
- """
-
- latest: int
- timeline: Dict[str, int] = {}
-
-
-class Timelines(BaseModel):
- """
- Timelines model.
- """
-
- confirmed: Timeline
- deaths: Timeline
- recovered: Timeline
diff --git a/app/router/__init__.py b/app/router/__init__.py
deleted file mode 100644
index 4eda6c21..00000000
--- a/app/router/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-"""app.router"""
-from fastapi import APIRouter
-
-# pylint: disable=redefined-builtin
-from .v1 import all, confirmed, deaths, recovered
-
-# The routes.
-from .v2 import latest, sources, locations # isort:skip
diff --git a/app/router/v1/__init__.py b/app/router/v1/__init__.py
deleted file mode 100644
index 839bd212..00000000
--- a/app/router/v1/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-"""app.router.v1"""
-from fastapi import APIRouter
-
-V1 = APIRouter()
diff --git a/app/router/v1/all.py b/app/router/v1/all.py
deleted file mode 100644
index 91b9e826..00000000
--- a/app/router/v1/all.py
+++ /dev/null
@@ -1,20 +0,0 @@
-"""app.router.v1.all.py"""
-from ...services.location.jhu import get_category
-from . import V1
-
-
-@V1.get("/all")
-async def all(): # pylint: disable=redefined-builtin
- """Get all the categories."""
- confirmed = await get_category("confirmed")
- deaths = await get_category("deaths")
- recovered = await get_category("recovered")
-
- return {
- # Data.
- "confirmed": confirmed,
- "deaths": deaths,
- "recovered": recovered,
- # Latest.
- "latest": {"confirmed": confirmed["latest"], "deaths": deaths["latest"], "recovered": recovered["latest"],},
- }
diff --git a/app/router/v1/confirmed.py b/app/router/v1/confirmed.py
deleted file mode 100644
index 13365e32..00000000
--- a/app/router/v1/confirmed.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""app.router.v1.confirmed.py"""
-from ...services.location.jhu import get_category
-from . import V1
-
-
-@V1.get("/confirmed")
-async def confirmed():
- """Confirmed cases."""
- confirmed_data = await get_category("confirmed")
-
- return confirmed_data
diff --git a/app/router/v1/deaths.py b/app/router/v1/deaths.py
deleted file mode 100644
index fb45498c..00000000
--- a/app/router/v1/deaths.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""app.router.v1.deaths.py"""
-from ...services.location.jhu import get_category
-from . import V1
-
-
-@V1.get("/deaths")
-async def deaths():
- """Total deaths."""
- deaths_data = await get_category("deaths")
-
- return deaths_data
diff --git a/app/router/v1/recovered.py b/app/router/v1/recovered.py
deleted file mode 100644
index 3a3a85b7..00000000
--- a/app/router/v1/recovered.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""app.router.v1.recovered.py"""
-from ...services.location.jhu import get_category
-from . import V1
-
-
-@V1.get("/recovered")
-async def recovered():
- """Recovered cases."""
- recovered_data = await get_category("recovered")
-
- return recovered_data
diff --git a/app/router/v2/__init__.py b/app/router/v2/__init__.py
deleted file mode 100644
index 62c31905..00000000
--- a/app/router/v2/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-"""app.router.v2"""
-from fastapi import APIRouter
-
-V2 = APIRouter()
diff --git a/app/router/v2/latest.py b/app/router/v2/latest.py
deleted file mode 100644
index 105b16fe..00000000
--- a/app/router/v2/latest.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""app.router.v2.latest.py"""
-from fastapi import Request
-
-from ...enums.sources import Sources
-from ...models.latest import LatestResponse as Latest
-from . import V2
-
-
-@V2.get("/latest", response_model=Latest)
-async def get_latest(request: Request, source: Sources = "jhu"): # pylint: disable=unused-argument
- """
- Getting latest amount of total confirmed cases, deaths, and recoveries.
- """
- locations = await request.state.source.get_all()
- return {
- "latest": {
- "confirmed": sum(map(lambda location: location.confirmed, locations)),
- "deaths": sum(map(lambda location: location.deaths, locations)),
- "recovered": sum(map(lambda location: location.recovered, locations)),
- }
- }
diff --git a/app/router/v2/sources.py b/app/router/v2/sources.py
deleted file mode 100644
index ad906e51..00000000
--- a/app/router/v2/sources.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""app.router.v2.sources.py"""
-from ...data import DATA_SOURCES
-from . import V2
-
-
-@V2.get("/sources")
-async def sources():
- """
- Retrieves a list of data-sources that are availble to use.
- """
- return {"sources": list(DATA_SOURCES.keys())}
diff --git a/app/routers/__init__.py b/app/routers/__init__.py
new file mode 100644
index 00000000..2bdd5ee3
--- /dev/null
+++ b/app/routers/__init__.py
@@ -0,0 +1,3 @@
+"""app.routers"""
+from .v1 import V1
+from .v2 import V2
diff --git a/app/routers/v1.py b/app/routers/v1.py
new file mode 100644
index 00000000..662514a0
--- /dev/null
+++ b/app/routers/v1.py
@@ -0,0 +1,47 @@
+"""app.routers.v1.py"""
+from fastapi import APIRouter
+
+from ..services.location.jhu import get_category
+
+V1 = APIRouter()
+
+
+@V1.get("/all")
+async def all_categories():
+ """Get all the categories."""
+ confirmed = await get_category("confirmed")
+ deaths = await get_category("deaths")
+ recovered = await get_category("recovered")
+
+ return {
+ # Data.
+ "confirmed": confirmed,
+ "deaths": deaths,
+ "recovered": recovered,
+ # Latest.
+ "latest": {"confirmed": confirmed["latest"], "deaths": deaths["latest"], "recovered": recovered["latest"],},
+ }
+
+
+@V1.get("/confirmed")
+async def get_confirmed():
+ """Confirmed cases."""
+ confirmed_data = await get_category("confirmed")
+
+ return confirmed_data
+
+
+@V1.get("/deaths")
+async def get_deaths():
+ """Total deaths."""
+ deaths_data = await get_category("deaths")
+
+ return deaths_data
+
+
+@V1.get("/recovered")
+async def get_recovered():
+ """Recovered cases."""
+ recovered_data = await get_category("recovered")
+
+ return recovered_data
diff --git a/app/router/v2/locations.py b/app/routers/v2.py
similarity index 59%
rename from app/router/v2/locations.py
rename to app/routers/v2.py
index 649f9c9e..de5a5312 100644
--- a/app/router/v2/locations.py
+++ b/app/routers/v2.py
@@ -1,14 +1,41 @@
-"""app.router.v2.locations.py"""
-from fastapi import HTTPException, Request
+"""app.routers.v2"""
+import enum
-from ...enums.sources import Sources
-from ...models.location import LocationResponse as Location
-from ...models.location import LocationsResponse as Locations
-from . import V2
+from fastapi import APIRouter, HTTPException, Request
+
+from ..data import DATA_SOURCES
+from ..models import LatestResponse, LocationResponse, LocationsResponse
+
+V2 = APIRouter()
+
+
+class Sources(str, enum.Enum):
+ """
+ A source available for retrieving data.
+ """
+
+ jhu = "jhu"
+ csbs = "csbs"
+ nyt = "nyt"
+
+
+@V2.get("/latest", response_model=LatestResponse)
+async def get_latest(request: Request, source: Sources = "jhu"): # pylint: disable=unused-argument
+ """
+ Getting latest amount of total confirmed cases, deaths, and recoveries.
+ """
+ locations = await request.state.source.get_all()
+ return {
+ "latest": {
+ "confirmed": sum(map(lambda location: location.confirmed, locations)),
+ "deaths": sum(map(lambda location: location.deaths, locations)),
+ "recovered": sum(map(lambda location: location.recovered, locations)),
+ }
+ }
# pylint: disable=unused-argument,too-many-arguments,redefined-builtin
-@V2.get("/locations", response_model=Locations, response_model_exclude_unset=True)
+@V2.get("/locations", response_model=LocationsResponse, response_model_exclude_unset=True)
async def get_locations(
request: Request,
source: Sources = "jhu",
@@ -56,10 +83,18 @@ async def get_locations(
# pylint: disable=invalid-name
-@V2.get("/locations/{id}", response_model=Location)
+@V2.get("/locations/{id}", response_model=LocationResponse)
async def get_location_by_id(request: Request, id: int, source: Sources = "jhu", timelines: bool = True):
"""
Getting specific location by id.
"""
location = await request.state.source.get(id)
return {"location": location.serialize(timelines)}
+
+
+@V2.get("/sources")
+async def sources():
+ """
+ Retrieves a list of data-sources that are availble to use.
+ """
+ return {"sources": list(DATA_SOURCES.keys())}
diff --git a/app/services/location/csbs.py b/app/services/location/csbs.py
index d0de3837..d660269c 100644
--- a/app/services/location/csbs.py
+++ b/app/services/location/csbs.py
@@ -11,6 +11,8 @@
from ...utils import httputils
from . import LocationService
+LOGGER = logging.getLogger("services.location.csbs")
+
class CSBSLocationService(LocationService):
"""
@@ -40,15 +42,14 @@ async def get_locations():
:returns: The locations.
:rtype: dict
"""
- logger = logging.getLogger("services.location.csbs")
- logger.info("Requesting data...")
+ LOGGER.info("csbs Requesting data...")
async with httputils.CLIENT_SESSION.get(BASE_URL) as response:
text = await response.text()
- logger.info("Data received")
+ LOGGER.info("csbs Data received")
data = list(csv.DictReader(text.splitlines()))
- logger.info("CSV parsed")
+ LOGGER.info("csbs CSV parsed")
locations = []
@@ -83,7 +84,7 @@ async def get_locations():
int(item["Death"] or 0),
)
)
- logger.info("Data normalized")
+ LOGGER.info("csbs Data normalized")
# Return the locations.
return locations
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index 39e07ac2..21990c8c 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -14,6 +14,8 @@
from ...utils import httputils
from . import LocationService
+LOGGER = logging.getLogger("services.location.jhu")
+
class JhuLocationService(LocationService):
"""
@@ -48,8 +50,6 @@ async def get_category(category):
:returns: The data for category.
:rtype: dict
"""
- logger = logging.getLogger("services.location.jhu")
-
# Adhere to category naming standard.
category = category.lower()
@@ -57,15 +57,15 @@ async def get_category(category):
url = BASE_URL + "time_series_covid19_%s_global.csv" % category
# Request the data
- logger.info("Requesting data...")
+ LOGGER.info("jhu Requesting data...")
async with httputils.CLIENT_SESSION.get(url) as response:
text = await response.text()
- logger.info("Data received")
+ LOGGER.info("jhu Data received")
# Parse the CSV.
data = list(csv.DictReader(text.splitlines()))
- logger.info("CSV parsed")
+ LOGGER.info("jhu CSV parsed")
# The normalized locations.
locations = []
@@ -98,7 +98,7 @@ async def get_category(category):
"latest": int(latest or 0),
}
)
- logger.info("Data normalized")
+ LOGGER.info("jhu Data normalized")
# Latest total.
latest = sum(map(lambda location: location["latest"], locations))
diff --git a/app/services/location/nyt.py b/app/services/location/nyt.py
index 7f12eb62..a6435166 100644
--- a/app/services/location/nyt.py
+++ b/app/services/location/nyt.py
@@ -12,6 +12,8 @@
from ...utils import httputils
from . import LocationService
+LOGGER = logging.getLogger("services.location.nyt")
+
class NYTLocationService(LocationService):
"""
@@ -72,18 +74,16 @@ async def get_locations():
:returns: The complete data for US Counties.
:rtype: dict
"""
- logger = logging.getLogger("services.location.nyt")
-
# Request the data.
- logger.info("Requesting data...")
+ LOGGER.info("nyt Requesting data...")
async with httputils.CLIENT_SESSION.get(BASE_URL) as response:
text = await response.text()
- logger.info("Data received")
+ LOGGER.info("Data received")
# Parse the CSV.
data = list(csv.DictReader(text.splitlines()))
- logger.info("CSV parsed")
+ LOGGER.info("nyt CSV parsed")
# Group together locations (NYT data ordered by dates not location).
grouped_locations = get_grouped_locations_dict(data)
@@ -125,6 +125,6 @@ async def get_locations():
},
)
)
- logger.info("Data normalized")
+ LOGGER.info("nyt Data normalized")
return locations
diff --git a/app/utils/countries.py b/app/utils/countries.py
index 5f926f37..ebb09bb3 100644
--- a/app/utils/countries.py
+++ b/app/utils/countries.py
@@ -374,6 +374,6 @@ def country_code(value):
"""
code = COUNTRY_NAME__COUNTRY_CODE.get(value, DEFAULT_COUNTRY_CODE)
if code == DEFAULT_COUNTRY_CODE:
- LOGGER.warning(f"No country code found for '{value}'. Using '{code}'!")
+ LOGGER.info(f"No country code found for '{value}'. Using '{code}'!")
return code
diff --git a/app/utils/populations.py b/app/utils/populations.py
index f5235fd4..24f0fa4e 100644
--- a/app/utils/populations.py
+++ b/app/utils/populations.py
@@ -28,7 +28,7 @@ def fetch_populations(save=False):
# Fetch the countries.
try:
- countries = requests.get(GEONAMES_URL, params={"username": "dperic"}, timeout=1.5).json()["geonames"]
+ countries = requests.get(GEONAMES_URL, params={"username": "dperic"}, timeout=1.25).json()["geonames"]
# Go through all the countries and perform the mapping.
for country in countries:
mappings.update({country["countryCode"]: int(country["population"]) or None})
@@ -40,6 +40,7 @@ def fetch_populations(save=False):
mappings = app.io.load(GEONAMES_BACKUP_PATH)
LOGGER.info(f"Using backup data from {GEONAMES_BACKUP_PATH}")
# Finally, return the mappings.
+ LOGGER.info("Fetched populations")
return mappings
From 05e67bdfdf35305afb11487359e8e65bde3ef714 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sat, 18 Apr 2020 20:42:54 -0400
Subject: [PATCH 44/61] Gunicorn with 4 workers (#295)
* change missing country code to debug level
* set gunicorn config to 4 workers
* log worker id
---
Procfile | 2 +-
app/services/location/jhu.py | 3 ++-
app/utils/countries.py | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Procfile b/Procfile
index dd838293..094ebc0a 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-web: gunicorn app.main:APP -k uvicorn.workers.UvicornWorker
\ No newline at end of file
+web: gunicorn app.main:APP -w 4 -k uvicorn.workers.UvicornWorker
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index 21990c8c..53aa6ff9 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -1,6 +1,7 @@
"""app.services.location.jhu.py"""
import csv
import logging
+import os
from datetime import datetime
from asyncache import cached
@@ -57,7 +58,7 @@ async def get_category(category):
url = BASE_URL + "time_series_covid19_%s_global.csv" % category
# Request the data
- LOGGER.info("jhu Requesting data...")
+ LOGGER.info(f"pid:{os.getpid()}: jhu Requesting data...")
async with httputils.CLIENT_SESSION.get(url) as response:
text = await response.text()
diff --git a/app/utils/countries.py b/app/utils/countries.py
index ebb09bb3..d239b5ee 100644
--- a/app/utils/countries.py
+++ b/app/utils/countries.py
@@ -374,6 +374,6 @@ def country_code(value):
"""
code = COUNTRY_NAME__COUNTRY_CODE.get(value, DEFAULT_COUNTRY_CODE)
if code == DEFAULT_COUNTRY_CODE:
- LOGGER.info(f"No country code found for '{value}'. Using '{code}'!")
+ LOGGER.debug(f"No country code found for '{value}'. Using '{code}'!")
return code
From 9e8d12b509823c1446ad1105a986413b34d47b98 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sun, 26 Apr 2020 13:10:49 -0400
Subject: [PATCH 45/61] Improve logging details (#305)
* add & log a data_id string for each cache
move some messages to debug level
log process id for location get not category get
* dev mode should run with debug log level
* log missing country code at sub debug level
debug is `10`
---
Pipfile | 2 +-
app/services/location/csbs.py | 9 +++++----
app/services/location/jhu.py | 19 +++++++++++++------
app/services/location/nyt.py | 9 +++++----
app/utils/countries.py | 3 ++-
5 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/Pipfile b/Pipfile
index 9a0839af..c28a067c 100644
--- a/Pipfile
+++ b/Pipfile
@@ -36,7 +36,7 @@ uvicorn = "*"
python_version = "3.8"
[scripts]
-dev = "uvicorn app.main:APP --reload"
+dev = "uvicorn app.main:APP --reload --log-level=debug"
start = "uvicorn app.main:APP"
fmt = "invoke fmt"
sort = "invoke sort"
diff --git a/app/services/location/csbs.py b/app/services/location/csbs.py
index d660269c..68bdb01c 100644
--- a/app/services/location/csbs.py
+++ b/app/services/location/csbs.py
@@ -42,14 +42,15 @@ async def get_locations():
:returns: The locations.
:rtype: dict
"""
- LOGGER.info("csbs Requesting data...")
+ data_id = "csbs.locations"
+ LOGGER.info(f"{data_id} Requesting data...")
async with httputils.CLIENT_SESSION.get(BASE_URL) as response:
text = await response.text()
- LOGGER.info("csbs Data received")
+ LOGGER.debug(f"{data_id} Data received")
data = list(csv.DictReader(text.splitlines()))
- LOGGER.info("csbs CSV parsed")
+ LOGGER.debug(f"{data_id} CSV parsed")
locations = []
@@ -84,7 +85,7 @@ async def get_locations():
int(item["Death"] or 0),
)
)
- LOGGER.info("csbs Data normalized")
+ LOGGER.info(f"{data_id} Data normalized")
# Return the locations.
return locations
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index 53aa6ff9..bd247113 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -3,6 +3,7 @@
import logging
import os
from datetime import datetime
+from pprint import pformat as pf
from asyncache import cached
from cachetools import TTLCache
@@ -16,7 +17,7 @@
from . import LocationService
LOGGER = logging.getLogger("services.location.jhu")
-
+PID = os.getpid()
class JhuLocationService(LocationService):
"""
@@ -53,20 +54,21 @@ async def get_category(category):
"""
# Adhere to category naming standard.
category = category.lower()
+ data_id = f"jhu.{category}"
# URL to request data from.
url = BASE_URL + "time_series_covid19_%s_global.csv" % category
# Request the data
- LOGGER.info(f"pid:{os.getpid()}: jhu Requesting data...")
+ LOGGER.info(f"{data_id} Requesting data...")
async with httputils.CLIENT_SESSION.get(url) as response:
text = await response.text()
- LOGGER.info("jhu Data received")
+ LOGGER.debug(f"{data_id} Data received")
# Parse the CSV.
data = list(csv.DictReader(text.splitlines()))
- LOGGER.info("jhu CSV parsed")
+ LOGGER.debug(f"{data_id} CSV parsed")
# The normalized locations.
locations = []
@@ -99,18 +101,20 @@ async def get_category(category):
"latest": int(latest or 0),
}
)
- LOGGER.info("jhu Data normalized")
+ LOGGER.debug(f"{data_id} Data normalized")
# Latest total.
latest = sum(map(lambda location: location["latest"], locations))
# Return the final data.
- return {
+ results = {
"locations": locations,
"latest": latest,
"last_updated": datetime.utcnow().isoformat() + "Z",
"source": "https://github.com/ExpDev07/coronavirus-tracker-api",
}
+ LOGGER.info(f"{data_id} results:\n{pf(results, depth=1)}")
+ return results
@cached(cache=TTLCache(maxsize=1024, ttl=3600))
@@ -121,6 +125,8 @@ async def get_locations():
:returns: The locations.
:rtype: List[Location]
"""
+ data_id = "jhu.locations"
+ LOGGER.info(f"pid:{PID}: {data_id} Requesting data...")
# Get all of the data categories locations.
confirmed = await get_category("confirmed")
deaths = await get_category("deaths")
@@ -174,6 +180,7 @@ async def get_locations():
},
)
)
+ LOGGER.info(f"{data_id} Data normalized")
# Finally, return the locations.
return locations
diff --git a/app/services/location/nyt.py b/app/services/location/nyt.py
index a6435166..b33f5d3c 100644
--- a/app/services/location/nyt.py
+++ b/app/services/location/nyt.py
@@ -74,16 +74,17 @@ async def get_locations():
:returns: The complete data for US Counties.
:rtype: dict
"""
+ data_id = "nyt.locations"
# Request the data.
- LOGGER.info("nyt Requesting data...")
+ LOGGER.info(f"{data_id} Requesting data...")
async with httputils.CLIENT_SESSION.get(BASE_URL) as response:
text = await response.text()
- LOGGER.info("Data received")
+ LOGGER.debug(f"{data_id} Data received")
# Parse the CSV.
data = list(csv.DictReader(text.splitlines()))
- LOGGER.info("nyt CSV parsed")
+ LOGGER.debug(f"{data_id} CSV parsed")
# Group together locations (NYT data ordered by dates not location).
grouped_locations = get_grouped_locations_dict(data)
@@ -125,6 +126,6 @@ async def get_locations():
},
)
)
- LOGGER.info("nyt Data normalized")
+ LOGGER.info(f"{data_id} Data normalized")
return locations
diff --git a/app/utils/countries.py b/app/utils/countries.py
index d239b5ee..9fb4f98a 100644
--- a/app/utils/countries.py
+++ b/app/utils/countries.py
@@ -374,6 +374,7 @@ def country_code(value):
"""
code = COUNTRY_NAME__COUNTRY_CODE.get(value, DEFAULT_COUNTRY_CODE)
if code == DEFAULT_COUNTRY_CODE:
- LOGGER.debug(f"No country code found for '{value}'. Using '{code}'!")
+ # log at sub DEBUG level
+ LOGGER.log(5, f"No country code found for '{value}'. Using '{code}'!")
return code
From 983fa5c22b40e8607c18158e2b61fabca4be76d1 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Wed, 29 Apr 2020 22:18:49 -0400
Subject: [PATCH 46/61] Use shared Redis cache for jhu data (#306)
* add & log a data_id string for each cache
* dev mode should run with debug log level
* log missing country code at sub debug level
* use pydantic for config managment
* add redis config settings
* add aiocache with redis support
* use memory cache
* use shared cache for jhu data
* cleanup
* fix url type
* add aiofiles
* add async save/read
* update tests
* update dependencies
* change pylint config to pyproject.toml
* cache jhu data (locally) for 30 minutes
---
.env.example | 3 +-
Pipfile | 4 +-
Pipfile.lock | 164 +++++++---
app/caches.py | 52 ++++
app/config.py | 29 ++
app/config/__init__.py | 0
app/config/settings.py | 10 -
app/io.py | 36 ++-
app/main.py | 6 +-
app/services/location/jhu.py | 112 ++++---
pylintrc | 582 -----------------------------------
pyproject.toml | 36 +++
requirements-dev.txt | 12 +-
requirements.txt | 10 +-
tasks.py | 1 +
tests/test_io.py | 37 ++-
16 files changed, 380 insertions(+), 714 deletions(-)
create mode 100644 app/caches.py
create mode 100644 app/config.py
delete mode 100644 app/config/__init__.py
delete mode 100644 app/config/settings.py
delete mode 100644 pylintrc
diff --git a/.env.example b/.env.example
index cb380afb..e35ce549 100644
--- a/.env.example
+++ b/.env.example
@@ -1,2 +1,3 @@
# Port to serve app on.
-PORT = 5000
\ No newline at end of file
+PORT = 5000
+LOCAL_REDIS_URL = redis://localhost:6379
diff --git a/Pipfile b/Pipfile
index c28a067c..50d0a8a2 100644
--- a/Pipfile
+++ b/Pipfile
@@ -20,6 +20,8 @@ pytest-cov = "*"
responses = "*"
[packages]
+aiocache = {extras = ["redis"],version = "*"}
+aiofiles = "*"
aiohttp = "*"
asyncache = "*"
cachetools = "*"
@@ -27,8 +29,8 @@ dataclasses = {version = "*",markers = "python_version<'3.7'"}
fastapi = "*"
gunicorn = "*"
idna_ssl = {version = "*",markers = "python_version<'3.7'"}
+pydantic = {extras = ["dotenv"],version = "*"}
python-dateutil = "*"
-python-dotenv = "*"
requests = "*"
uvicorn = "*"
diff --git a/Pipfile.lock b/Pipfile.lock
index 9ac79d0f..43e27b0e 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "9c469c96db1ae3a7e4c239d3a9c7028ecf49a0ab5e3ea50aed304ea2ab1a113e"
+ "sha256": "596c0a497d4f2cfa9e3a3e8b38b2cf018ab3b6d9a26f04a949ced6b025e05f62"
},
"pipfile-spec": 6,
"requires": {
@@ -16,6 +16,25 @@
]
},
"default": {
+ "aiocache": {
+ "extras": [
+ "redis"
+ ],
+ "hashes": [
+ "sha256:e55c7caaa5753794fd301c3a2e592737fa1d036db9f8d04ae154facdfb48a157",
+ "sha256:f2ebe0b05cec45782e7b5ea0bb74640f157dd4bb1028b4565364dda9fe33be7f"
+ ],
+ "index": "pypi",
+ "version": "==0.11.1"
+ },
+ "aiofiles": {
+ "hashes": [
+ "sha256:377fdf7815cc611870c59cbd07b68b180841d2a2b79812d8c218be02448c2acb",
+ "sha256:98e6bcfd1b50f97db4980e182ddd509b7cc35909e903a8fe50d8849e02d815af"
+ ],
+ "index": "pypi",
+ "version": "==0.5.0"
+ },
"aiohttp": {
"hashes": [
"sha256:1e984191d1ec186881ffaed4581092ba04f7c61582a177b187d3a2f07ed9719e",
@@ -34,6 +53,13 @@
"index": "pypi",
"version": "==3.6.2"
},
+ "aioredis": {
+ "hashes": [
+ "sha256:15f8af30b044c771aee6787e5ec24694c048184c7b9e54c3b60c750a4b93273a",
+ "sha256:b61808d7e97b7cd5a92ed574937a079c9387fdadd22bfbfa7ad2fd319ecc26e3"
+ ],
+ "version": "==1.3.1"
+ },
"async-timeout": {
"hashes": [
"sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f",
@@ -79,10 +105,10 @@
},
"click": {
"hashes": [
- "sha256:8a18b4ea89d8820c5d0c7da8a64b2c324b4dabb695804dbfea19b9be9d88c0cc",
- "sha256:e345d143d80bf5ee7534056164e5e112ea5e22716bbb1ce727941f4c8b471b9a"
+ "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a",
+ "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"
],
- "version": "==7.1.1"
+ "version": "==7.1.2"
},
"dataclasses": {
"hashes": [
@@ -116,6 +142,51 @@
],
"version": "==0.9.0"
},
+ "hiredis": {
+ "hashes": [
+ "sha256:01b577f84c20ecc9c07fc4c184231b08e3c3942de096fa99978e053de231c423",
+ "sha256:01ff0900134166961c9e339df77c33b72f7edc5cb41739f0babcd9faa345926e",
+ "sha256:03ed34a13316d0c34213c4fd46e0fa3a5299073f4d4f08e93fed8c2108b399b3",
+ "sha256:040436e91df5143aff9e0debb49530d0b17a6bd52200ce568621c31ef581b10d",
+ "sha256:091eb38fbf968d1c5b703e412bbbd25f43a7967d8400842cee33a5a07b33c27b",
+ "sha256:102f9b9dc6ed57feb3a7c9bdf7e71cb7c278fe8df1edfcfe896bc3e0c2be9447",
+ "sha256:2b4b392c7e3082860c8371fab3ae762139090f9115819e12d9f56060f9ede05d",
+ "sha256:2c9cc0b986397b833073f466e6b9e9c70d1d4dc2c2c1b3e9cae3a23102ff296c",
+ "sha256:2fa65a9df683bca72073cd77709ddeb289ea2b114d3775d225fbbcc5faf808c5",
+ "sha256:38437a681f17c975fd22349e72c29bc643f8e7eb2d6dc5df419eac59afa4d7ce",
+ "sha256:3b3428fa3cf1ee178807b52c9bee8950ab94cd4eaa9bfae8c1bbae3c49501d34",
+ "sha256:3dd8c2fae7f5494978facb0e93297dd627b1a3f536f3b070cf0a7d9157a07dcb",
+ "sha256:4414a96c212e732723b5c3d7c04d386ebbb2ec359e1de646322cbc3f875cbd0d",
+ "sha256:48c627581ad4ef60adbac980981407939acf13a0e18f093502c7b542223c4f19",
+ "sha256:4a60e71625a2d78d8ab84dfb2fa2cfd9458c964b6e6c04fea76d9ade153fb371",
+ "sha256:585ace09f434e43d8a8dbeb366865b1a044d7c06319b3c7372a0a00e63b860f4",
+ "sha256:74b364b3f06c9cf0a53f7df611045bc9437ed972a283fa1f0b12537236d23ddc",
+ "sha256:75c65c3850e89e9daa68d1b9bedd5806f177d60aa5a7b0953b4829481cfc1f72",
+ "sha256:7f052de8bf744730a9120dbdc67bfeb7605a01f69fb8e7ba5c475af33c24e145",
+ "sha256:8113a7d5e87ecf57cd4ae263cc9e429adb9a3e59f5a7768da5d3312a8d0a051a",
+ "sha256:84857ce239eb8ed191ac78e77ff65d52902f00f30f4ee83bf80eb71da73b70e6",
+ "sha256:8644a48ddc4a40b3e3a6b9443f396c2ee353afb2d45656c4fc68d04a82e8e3f7",
+ "sha256:936aa565e673536e8a211e43ec43197406f24cd1f290138bd143765079c8ba00",
+ "sha256:9afeb88c67bbc663b9f27385c496da056d06ad87f55df6e393e1516cfecb0461",
+ "sha256:9d62cc7880110e4f83b0a51d218f465d3095e2751fbddd34e553dbd106a929ff",
+ "sha256:a1fadd062fc8d647ff39220c57ea2b48c99bb73f18223828ec97f88fc27e7898",
+ "sha256:a7754a783b1e5d6f627c19d099b178059c62f782ab62b4d8ba165b9fbc2ee34c",
+ "sha256:aa59dd63bb3f736de4fc2d080114429d5d369dfb3265f771778e8349d67a97a4",
+ "sha256:ae2ee0992f8de249715435942137843a93db204dd7db1e7cc9bdc5a8436443e8",
+ "sha256:b36842d7cf32929d568f37ec5b3173b72b2ec6572dec4d6be6ce774762215aee",
+ "sha256:bcbf9379c553b5facc6c04c1e5569b44b38ff16bcbf354676287698d61ee0c92",
+ "sha256:cbccbda6f1c62ab460449d9c85fdf24d0d32a6bf45176581151e53cc26a5d910",
+ "sha256:d0caf98dfb8af395d6732bd16561c0a2458851bea522e39f12f04802dbf6f502",
+ "sha256:d6456afeddba036def1a36d8a2758eca53202308d83db20ab5d0b66590919627",
+ "sha256:dbaef9a21a4f10bc281684ee4124f169e62bb533c2a92b55f8c06f64f9af7b8f",
+ "sha256:dce84916c09aaece006272b37234ae84a8ed13abb3a4d341a23933b8701abfb5",
+ "sha256:eb8c9c8b9869539d58d60ff4a28373a22514d40495911451343971cb4835b7a9",
+ "sha256:efc98b14ee3a8595e40b1425e8d42f5fd26f11a7b215a81ef9259068931754f4",
+ "sha256:fa2dc05b87d97acc1c6ae63f3e0f39eae5246565232484b08db6bf2dc1580678",
+ "sha256:fe7d6ce9f6a5fbe24f09d95ea93e9c7271abc4e1565da511e1449b107b4d7848"
+ ],
+ "version": "==1.0.1"
+ },
"httptools": {
"hashes": [
"sha256:0a4b1b2012b28e68306575ad14ad5e9120b34fccd02a81eb08838d7e3bbb48be",
@@ -172,26 +243,30 @@
"version": "==4.7.5"
},
"pydantic": {
- "hashes": [
- "sha256:0b7aadfa1de28057656064e04d9f018d1b186fe2a8e953a2fb41545873b7cf95",
- "sha256:0f61e67291b99a927816558a218a4e794db72a33621c836e63d12613a2202cd4",
- "sha256:20946280c750753b3e3177c748825ef189d7ab86c514f6a0b118621110d5f0d3",
- "sha256:22139ee446992c222977ac0a9269c4da2e9ecc1834f84804ebde008a4649b929",
- "sha256:3c0f39e884d7a3572d5cc8322b0fe9bf66114283e22e05a5c4b8961c19588945",
- "sha256:446ce773a552a2cb90065d4aa645e16fa7494369b5f0d199e4d41a992a98204d",
- "sha256:475e6606873e40717cc3b0eebc7d1101cbfc774e01dadeeea24c121eb5826b86",
- "sha256:66124752662de0479a9d0c17bdebdc8a889bccad8846626fb66d8669e8eafb63",
- "sha256:896637b7d8e4cdc0bcee1704fcadacdd167c35ac29f02a4395fce7a033925f26",
- "sha256:9af44d06db33896a2176603c9cb876df3a60297a292a24d3018956a910cc1402",
- "sha256:9e46fac8a4674db0777fd0133aa56817e1481beee50971bab39dded7639f9b2b",
- "sha256:ae206e103e976c40ec294cd6c8fcbfbdaced3ab9b736bc53d03fa11b5aaa1628",
- "sha256:b11d0bd7ecf41098894e8777ee623c29554dbaa37e862c51bcc5a2b950d1bf77",
- "sha256:d73070028f7b046a5b2e611a9799c238d7bd245f8fe30f4ad7ff29ddb63aac40",
- "sha256:ddedcdf9d5c24939578449a8e099ceeec3b3d76243fc143aff63ebf6d5aade10",
- "sha256:e08e21f4d5395ac17cde19de26be63fb16fb870f0cfde1481ddc22d5e2353548",
- "sha256:e6239199b363bc53262bcb57f1441206d4b2d46b392eccba2213d8358d6e284a"
- ],
- "version": "==1.5"
+ "extras": [
+ "dotenv"
+ ],
+ "hashes": [
+ "sha256:0a1cdf24e567d42dc762d3fed399bd211a13db2e8462af9dfa93b34c41648efb",
+ "sha256:2007eb062ed0e57875ce8ead12760a6e44bf5836e6a1a7ea81d71eeecf3ede0f",
+ "sha256:20a15a303ce1e4d831b4e79c17a4a29cb6740b12524f5bba3ea363bff65732bc",
+ "sha256:2a6904e9f18dea58f76f16b95cba6a2f20b72d787abd84ecd67ebc526e61dce6",
+ "sha256:3714a4056f5bdbecf3a41e0706ec9b228c9513eee2ad884dc2c568c4dfa540e9",
+ "sha256:473101121b1bd454c8effc9fe66d54812fdc128184d9015c5aaa0d4e58a6d338",
+ "sha256:68dece67bff2b3a5cc188258e46b49f676a722304f1c6148ae08e9291e284d98",
+ "sha256:70f27d2f0268f490fe3de0a9b6fca7b7492b8fd6623f9fecd25b221ebee385e3",
+ "sha256:8433dbb87246c0f562af75d00fa80155b74e4f6924b0db6a2078a3cd2f11c6c4",
+ "sha256:8be325fc9da897029ee48d1b5e40df817d97fe969f3ac3fd2434ba7e198c55d5",
+ "sha256:93b9f265329d9827f39f0fca68f5d72cc8321881cdc519a1304fa73b9f8a75bd",
+ "sha256:9be755919258d5d168aeffbe913ed6e8bd562e018df7724b68cabdee3371e331",
+ "sha256:ab863853cb502480b118187d670f753be65ec144e1654924bec33d63bc8b3ce2",
+ "sha256:b96ce81c4b5ca62ab81181212edfd057beaa41411cd9700fbcb48a6ba6564b4e",
+ "sha256:da8099fca5ee339d5572cfa8af12cf0856ae993406f0b1eb9bb38c8a660e7416",
+ "sha256:e2c753d355126ddd1eefeb167fa61c7037ecd30b98e7ebecdc0d1da463b4ea09",
+ "sha256:f0018613c7a0d19df3240c2a913849786f21b6539b9f23d85ce4067489dfacfa"
+ ],
+ "index": "pypi",
+ "version": "==1.5.1"
},
"python-dateutil": {
"hashes": [
@@ -206,7 +281,6 @@
"sha256:25c0ff1a3e12f4bde8d592cc254ab075cfe734fc5dd989036716fd17ee7e5ec7",
"sha256:3b9909bc96b0edc6b01586e1eed05e71174ef4e04c71da5786370cebea53ad74"
],
- "index": "pypi",
"version": "==0.13.0"
},
"requests": {
@@ -240,11 +314,11 @@
},
"uvicorn": {
"hashes": [
- "sha256:0f58170165c4495f563d8224b2f415a0829af0412baa034d6f777904613087fd",
- "sha256:6fdaf8e53bf1b2ddf0fe9ed06079b5348d7d1d87b3365fe2549e6de0d49e631c"
+ "sha256:50577d599775dac2301bac8bd5b540d19a9560144143c5bdab13cba92783b6e7",
+ "sha256:596eaa8645b6dbc24d6610e335f8ddf5f925b4c4b86fdc7146abb0bf0da65d17"
],
"index": "pypi",
- "version": "==0.11.3"
+ "version": "==0.11.5"
},
"uvloop": {
"hashes": [
@@ -321,10 +395,10 @@
},
"astroid": {
"hashes": [
- "sha256:71ea07f44df9568a75d0f354c49143a4575d90645e9fead6dfb52c26a85ed13a",
- "sha256:840947ebfa8b58f318d42301cf8c0a20fd794a33b61cc4638e28e9e61ba32f42"
+ "sha256:29fa5d46a2404d01c834fcb802a3943685f1fc538eb2a02a161349f5505ac196",
+ "sha256:2fecea42b20abb1922ed65c7b5be27edfba97211b04b2b6abc6a43549a024ea6"
],
- "version": "==2.3.3"
+ "version": "==2.4.0"
},
"async-asgi-testclient": {
"hashes": [
@@ -388,10 +462,10 @@
},
"click": {
"hashes": [
- "sha256:8a18b4ea89d8820c5d0c7da8a64b2c324b4dabb695804dbfea19b9be9d88c0cc",
- "sha256:e345d143d80bf5ee7534056164e5e112ea5e22716bbb1ce727941f4c8b471b9a"
+ "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a",
+ "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc"
],
- "version": "==7.1.1"
+ "version": "==7.1.2"
},
"coverage": {
"hashes": [
@@ -596,11 +670,11 @@
},
"pylint": {
"hashes": [
- "sha256:3db5468ad013380e987410a8d6956226963aed94ecb5f9d3a28acca6d9ac36cd",
- "sha256:886e6afc935ea2590b462664b161ca9a5e40168ea99e5300935f6591ad467df4"
+ "sha256:588e114e3f9a1630428c35b7dd1c82c1c93e1b0e78ee312ae4724c5e1a1e0245",
+ "sha256:bd556ba95a4cf55a1fc0004c00cf4560b1e70598a54a74c6904d933c8f3bd5a8"
],
"index": "pypi",
- "version": "==2.4.4"
+ "version": "==2.5.0"
},
"pyparsing": {
"hashes": [
@@ -619,11 +693,11 @@
},
"pytest-asyncio": {
"hashes": [
- "sha256:9fac5100fd716cbecf6ef89233e8590a4ad61d729d1732e0a96b84182df1daaf",
- "sha256:d734718e25cfc32d2bf78d346e99d33724deeba774cc4afdf491530c6184b63b"
+ "sha256:6096d101a1ae350d971df05e25f4a8b4d3cd13ffb1b32e42d902ac49670d2bfa",
+ "sha256:c54866f3cf5dd2063992ba2c34784edae11d3ed19e006d220a3cf0bfc4191fcb"
],
"index": "pypi",
- "version": "==0.10.0"
+ "version": "==0.11.0"
},
"pytest-cov": {
"hashes": [
@@ -685,11 +759,11 @@
},
"responses": {
"hashes": [
- "sha256:0474ce3c897fbcc1aef286117c93499882d5c440f06a805947e4b1cb5ab3d474",
- "sha256:f83613479a021e233e82d52ffb3e2e0e2836d24b0cc88a0fa31978789f78d0e5"
+ "sha256:1a78bc010b20a5022a2c0cb76b8ee6dc1e34d887972615ebd725ab9a166a4960",
+ "sha256:3d596d0be06151330cb230a2d630717ab20f7a81f205019481e206eb5db79915"
],
"index": "pypi",
- "version": "==0.10.12"
+ "version": "==0.10.14"
},
"six": {
"hashes": [
@@ -761,9 +835,9 @@
},
"wrapt": {
"hashes": [
- "sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1"
+ "sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"
],
- "version": "==1.11.2"
+ "version": "==1.12.1"
},
"zipp": {
"hashes": [
diff --git a/app/caches.py b/app/caches.py
new file mode 100644
index 00000000..df95f508
--- /dev/null
+++ b/app/caches.py
@@ -0,0 +1,52 @@
+"""app.caches.py"""
+import functools
+import logging
+from typing import Union
+
+import aiocache
+
+from .config import get_settings
+
+LOGGER = logging.getLogger(name="app.caches")
+
+SETTINGS = get_settings()
+
+if SETTINGS.rediscloud_url:
+ REDIS_URL = SETTINGS.rediscloud_url
+ LOGGER.info("Using Rediscloud")
+else:
+ REDIS_URL = SETTINGS.local_redis_url
+ LOGGER.info("Using Local Redis")
+
+
+@functools.lru_cache()
+def get_cache(namespace) -> Union[aiocache.RedisCache, aiocache.SimpleMemoryCache]:
+ """Retunr """
+ if REDIS_URL:
+ LOGGER.info("using RedisCache")
+ return aiocache.RedisCache(
+ endpoint=REDIS_URL.host,
+ port=REDIS_URL.port,
+ password=REDIS_URL.password,
+ namespace=namespace,
+ create_connection_timeout=5,
+ )
+ LOGGER.info("using SimpleMemoryCache")
+ return aiocache.SimpleMemoryCache(namespace=namespace)
+
+
+async def check_cache(data_id: str, namespace: str = None):
+ """Check the data of a cache given an id."""
+ cache = get_cache(namespace)
+ result = await cache.get(data_id, None)
+ LOGGER.info(f"{data_id} cache pulled")
+ await cache.close()
+ return result
+
+
+async def load_cache(data_id: str, data, namespace: str = None, cache_life: int = 3600):
+ """Load data into the cache."""
+ cache = get_cache(namespace)
+ await cache.set(data_id, data, ttl=cache_life)
+ LOGGER.info(f"{data_id} cache loaded")
+ await cache.close()
diff --git a/app/config.py b/app/config.py
new file mode 100644
index 00000000..7d911e4d
--- /dev/null
+++ b/app/config.py
@@ -0,0 +1,29 @@
+"""app.config.py"""
+import functools
+import logging
+
+from pydantic import AnyUrl, BaseSettings
+
+CFG_LOGGER = logging.getLogger("app.config")
+
+
+class _Settings(BaseSettings):
+ port: int = 5000
+ rediscloud_url: AnyUrl = None
+ local_redis_url: AnyUrl = None
+
+
+@functools.lru_cache()
+def get_settings(**kwargs) -> BaseSettings:
+ """
+ Read settings from the environment or `.env` file.
+ https://pydantic-docs.helpmanual.io/usage/settings/#dotenv-env-support
+
+ Usage:
+ import app.config
+
+ settings = app.config.get_settings(_env_file="")
+ port_number = settings.port
+ """
+ CFG_LOGGER.info("Loading Config settings from Environment ...")
+ return _Settings(**kwargs)
diff --git a/app/config/__init__.py b/app/config/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/config/settings.py b/app/config/settings.py
deleted file mode 100644
index 4a02a734..00000000
--- a/app/config/settings.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""app.config.settings.py"""
-import os
-
-# Load enviroment variables from .env file.
-from dotenv import load_dotenv
-
-load_dotenv()
-
-# The port to serve the app application on.
-PORT = int(os.getenv("PORT", "5000"))
diff --git a/app/io.py b/app/io.py
index 8130c146..3bd443b6 100644
--- a/app/io.py
+++ b/app/io.py
@@ -1,28 +1,56 @@
"""app.io.py"""
import json
import pathlib
-from typing import Dict, Union
+from typing import Dict, List, Union
+
+import aiofiles
HERE = pathlib.Path(__file__)
DATA = HERE.joinpath("..", "data").resolve()
def save(
- name: str, content: Union[str, Dict], write_mode: str = "w", indent: int = 2, **json_dumps_kwargs
+ name: str, content: Union[str, Dict, List], write_mode: str = "w", indent: int = 2, **json_dumps_kwargs
) -> pathlib.Path:
"""Save content to a file. If content is a dictionary, use json.dumps()."""
path = DATA / name
- if isinstance(content, dict):
+ if isinstance(content, (dict, list)):
content = json.dumps(content, indent=indent, **json_dumps_kwargs)
with open(DATA / name, mode=write_mode) as f_out:
f_out.write(content)
return path
-def load(name: str, **json_kwargs) -> Union[str, Dict]:
+def load(name: str, **json_kwargs) -> Union[str, Dict, List]:
"""Loads content from a file. If file ends with '.json', call json.load() and return a Dictionary."""
path = DATA / name
with open(path) as f_in:
if path.suffix == ".json":
return json.load(f_in, **json_kwargs)
return f_in.read()
+
+
+class AIO:
+ """Asynsc compatible file io operations."""
+
+ @classmethod
+ async def save(
+ cls, name: str, content: Union[str, Dict, List], write_mode: str = "w", indent: int = 2, **json_dumps_kwargs
+ ):
+ """Save content to a file. If content is a dictionary, use json.dumps()."""
+ path = DATA / name
+ if isinstance(content, (dict, list)):
+ content = json.dumps(content, indent=indent, **json_dumps_kwargs)
+ async with aiofiles.open(DATA / name, mode=write_mode) as f_out:
+ await f_out.write(content)
+ return path
+
+ @classmethod
+ async def load(cls, name: str, **json_kwargs) -> Union[str, Dict, List]:
+ """Loads content from a file. If file ends with '.json', call json.load() and return a Dictionary."""
+ path = DATA / name
+ async with aiofiles.open(path) as f_in:
+ content = await f_in.read()
+ if path.suffix == ".json":
+ content = json.loads(content, **json_kwargs)
+ return content
diff --git a/app/main.py b/app/main.py
index 0ab95fdb..3e5ee010 100644
--- a/app/main.py
+++ b/app/main.py
@@ -2,7 +2,6 @@
app.main.py
"""
import logging
-import os
import pydantic
import uvicorn
@@ -11,6 +10,7 @@
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import JSONResponse
+from .config import get_settings
from .data import data_source
from .routers import V1, V2
from .utils.httputils import setup_client_session, teardown_client_session
@@ -20,6 +20,8 @@
# ############
LOGGER = logging.getLogger("api")
+SETTINGS = get_settings()
+
APP = FastAPI(
title="Coronavirus Tracker",
description=(
@@ -93,5 +95,5 @@ async def handle_validation_error(
# Running of app.
if __name__ == "__main__":
uvicorn.run(
- "app.main:APP", host="127.0.0.1", port=int(os.getenv("PORT", "5000")), log_level="info",
+ "app.main:APP", host="127.0.0.1", port=SETTINGS.port, log_level="info",
)
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index bd247113..11f6d120 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -8,6 +8,7 @@
from asyncache import cached
from cachetools import TTLCache
+from ...caches import check_cache, load_cache
from ...coordinates import Coordinates
from ...location import TimelinedLocation
from ...timeline import Timeline
@@ -19,6 +20,7 @@
LOGGER = logging.getLogger("services.location.jhu")
PID = os.getpid()
+
class JhuLocationService(LocationService):
"""
Service for retrieving locations from Johns Hopkins CSSE (https://github.com/CSSEGISandData/COVID-19).
@@ -44,7 +46,7 @@ async def get(self, loc_id): # pylint: disable=arguments-differ
)
-@cached(cache=TTLCache(maxsize=1024, ttl=3600))
+@cached(cache=TTLCache(maxsize=1024, ttl=1800))
async def get_category(category):
"""
Retrieves the data for the provided category. The data is cached for 1 hour.
@@ -56,68 +58,78 @@ async def get_category(category):
category = category.lower()
data_id = f"jhu.{category}"
- # URL to request data from.
- url = BASE_URL + "time_series_covid19_%s_global.csv" % category
+ # check shared cache
+ cache_results = await check_cache(data_id)
+ if cache_results:
+ LOGGER.info(f"{data_id} using shared cache results")
+ results = cache_results
+ else:
+ LOGGER.info(f"{data_id} shared cache empty")
+ # URL to request data from.
+ url = BASE_URL + "time_series_covid19_%s_global.csv" % category
- # Request the data
- LOGGER.info(f"{data_id} Requesting data...")
- async with httputils.CLIENT_SESSION.get(url) as response:
- text = await response.text()
+ # Request the data
+ LOGGER.info(f"{data_id} Requesting data...")
+ async with httputils.CLIENT_SESSION.get(url) as response:
+ text = await response.text()
- LOGGER.debug(f"{data_id} Data received")
+ LOGGER.debug(f"{data_id} Data received")
- # Parse the CSV.
- data = list(csv.DictReader(text.splitlines()))
- LOGGER.debug(f"{data_id} CSV parsed")
+ # Parse the CSV.
+ data = list(csv.DictReader(text.splitlines()))
+ LOGGER.debug(f"{data_id} CSV parsed")
- # The normalized locations.
- locations = []
+ # The normalized locations.
+ locations = []
- for item in data:
- # Filter out all the dates.
- dates = dict(filter(lambda element: date_util.is_date(element[0]), item.items()))
+ for item in data:
+ # Filter out all the dates.
+ dates = dict(filter(lambda element: date_util.is_date(element[0]), item.items()))
- # Make location history from dates.
- history = {date: int(amount or 0) for date, amount in dates.items()}
+ # Make location history from dates.
+ history = {date: int(amount or 0) for date, amount in dates.items()}
- # Country for this location.
- country = item["Country/Region"]
+ # Country for this location.
+ country = item["Country/Region"]
- # Latest data insert value.
- latest = list(history.values())[-1]
+ # Latest data insert value.
+ latest = list(history.values())[-1]
+
+ # Normalize the item and append to locations.
+ locations.append(
+ {
+ # General info.
+ "country": country,
+ "country_code": countries.country_code(country),
+ "province": item["Province/State"],
+ # Coordinates.
+ "coordinates": {"lat": item["Lat"], "long": item["Long"],},
+ # History.
+ "history": history,
+ # Latest statistic.
+ "latest": int(latest or 0),
+ }
+ )
+ LOGGER.debug(f"{data_id} Data normalized")
+
+ # Latest total.
+ latest = sum(map(lambda location: location["latest"], locations))
+
+ # Return the final data.
+ results = {
+ "locations": locations,
+ "latest": latest,
+ "last_updated": datetime.utcnow().isoformat() + "Z",
+ "source": "https://github.com/ExpDev07/coronavirus-tracker-api",
+ }
+ # save the results to distributed cache
+ await load_cache(data_id, results)
- # Normalize the item and append to locations.
- locations.append(
- {
- # General info.
- "country": country,
- "country_code": countries.country_code(country),
- "province": item["Province/State"],
- # Coordinates.
- "coordinates": {"lat": item["Lat"], "long": item["Long"],},
- # History.
- "history": history,
- # Latest statistic.
- "latest": int(latest or 0),
- }
- )
- LOGGER.debug(f"{data_id} Data normalized")
-
- # Latest total.
- latest = sum(map(lambda location: location["latest"], locations))
-
- # Return the final data.
- results = {
- "locations": locations,
- "latest": latest,
- "last_updated": datetime.utcnow().isoformat() + "Z",
- "source": "https://github.com/ExpDev07/coronavirus-tracker-api",
- }
LOGGER.info(f"{data_id} results:\n{pf(results, depth=1)}")
return results
-@cached(cache=TTLCache(maxsize=1024, ttl=3600))
+@cached(cache=TTLCache(maxsize=1024, ttl=1800))
async def get_locations():
"""
Retrieves the locations from the categories. The locations are cached for 1 hour.
diff --git a/pylintrc b/pylintrc
deleted file mode 100644
index af114a33..00000000
--- a/pylintrc
+++ /dev/null
@@ -1,582 +0,0 @@
-[MASTER]
-
-# A comma-separated list of package or module names from where C extensions may
-# be loaded. Extensions are loading into the active Python interpreter and may
-# run arbitrary code.
-extension-pkg-whitelist=pydantic
-
-# Add files or directories to the blacklist. They should be base names, not
-# paths.
-ignore=CVS
-
-# Add files or directories matching the regex patterns to the blacklist. The
-# regex matches against base names, not paths.
-ignore-patterns=
-
-# Python code to execute, usually for sys.path manipulation such as
-# pygtk.require().
-#init-hook=
-
-# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
-# number of processors available to use.
-jobs=1
-
-# Control the amount of potential inferred values when inferring a single
-# object. This can help the performance when dealing with large functions or
-# complex, nested conditions.
-limit-inference-results=100
-
-# List of plugins (as comma separated values of python module names) to load,
-# usually to register additional checkers.
-load-plugins=
-
-# Pickle collected data for later comparisons.
-persistent=yes
-
-# Specify a configuration file.
-#rcfile=
-
-# When enabled, pylint would attempt to guess common misconfiguration and emit
-# user-friendly hints instead of false-positive error messages.
-suggestion-mode=yes
-
-# Allow loading of arbitrary C extensions. Extensions are imported into the
-# active Python interpreter and may run arbitrary code.
-unsafe-load-any-extension=no
-
-
-[MESSAGES CONTROL]
-
-# Only show warnings with the listed confidence levels. Leave empty to show
-# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
-confidence=
-
-# Disable the message, report, category or checker with the given id(s). You
-# can either give multiple identifiers separated by comma (,) or put this
-# option multiple times (only on the command line, not in the configuration
-# file where it should appear only once). You can also use "--disable=all" to
-# disable everything first and then reenable specific checks. For example, if
-# you want to run only the similarities checker, you can use "--disable=all
-# --enable=similarities". If you want to run only the classes checker, but have
-# no Warning level messages displayed, use "--disable=all --enable=classes
-# --disable=W".
-disable=print-statement,
- parameter-unpacking,
- unpacking-in-except,
- old-raise-syntax,
- backtick,
- long-suffix,
- old-ne-operator,
- old-octal-literal,
- import-star-module-level,
- non-ascii-bytes-literal,
- raw-checker-failed,
- bad-inline-option,
- locally-disabled,
- file-ignored,
- suppressed-message,
- useless-suppression,
- deprecated-pragma,
- use-symbolic-message-instead,
- apply-builtin,
- basestring-builtin,
- buffer-builtin,
- cmp-builtin,
- coerce-builtin,
- execfile-builtin,
- file-builtin,
- long-builtin,
- raw_input-builtin,
- reduce-builtin,
- standarderror-builtin,
- unicode-builtin,
- xrange-builtin,
- coerce-method,
- delslice-method,
- getslice-method,
- setslice-method,
- no-absolute-import,
- old-division,
- dict-iter-method,
- dict-view-method,
- next-method-called,
- metaclass-assignment,
- indexing-exception,
- raising-string,
- reload-builtin,
- oct-method,
- hex-method,
- nonzero-method,
- cmp-method,
- input-builtin,
- round-builtin,
- intern-builtin,
- unichr-builtin,
- map-builtin-not-iterating,
- zip-builtin-not-iterating,
- range-builtin-not-iterating,
- filter-builtin-not-iterating,
- using-cmp-argument,
- eq-without-hash,
- div-method,
- idiv-method,
- rdiv-method,
- exception-message-attribute,
- invalid-str-codec,
- sys-max-int,
- bad-python3-import,
- deprecated-string-function,
- deprecated-str-translate-call,
- deprecated-itertools-function,
- deprecated-types-field,
- next-method-defined,
- dict-items-not-iterating,
- dict-keys-not-iterating,
- dict-values-not-iterating,
- deprecated-operator-function,
- deprecated-urllib-function,
- xreadlines-attribute,
- deprecated-sys-function,
- exception-escape,
- comprehension-escape,
- bad-continuation, # conflicts with black
- duplicate-code # turn back on ASAP
-
-# Enable the message, report, category or checker with the given id(s). You can
-# either give multiple identifier separated by comma (,) or put this option
-# multiple time (only on the command line, not in the configuration file where
-# it should appear only once). See also the "--disable" option for examples.
-enable=c-extension-no-member
-
-
-[REPORTS]
-
-# Python expression which should return a score less than or equal to 10. You
-# have access to the variables 'error', 'warning', 'refactor', and 'convention'
-# which contain the number of messages in each category, as well as 'statement'
-# which is the total number of statements analyzed. This score is used by the
-# global evaluation report (RP0004).
-evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
-
-# Template used to display messages. This is a python new-style format string
-# used to format the message information. See doc for all details.
-#msg-template=
-
-# Set the output format. Available formats are text, parseable, colorized, json
-# and msvs (visual studio). You can also give a reporter class, e.g.
-# mypackage.mymodule.MyReporterClass.
-output-format=text
-
-# Tells whether to display a full report or only the messages.
-reports=no
-
-# Activate the evaluation score.
-score=yes
-
-
-[REFACTORING]
-
-# Maximum number of nested blocks for function / method body
-max-nested-blocks=5
-
-# Complete name of functions that never returns. When checking for
-# inconsistent-return-statements if a never returning function is called then
-# it will be considered as an explicit return statement and no message will be
-# printed.
-never-returning-functions=sys.exit
-
-
-[BASIC]
-
-# Naming style matching correct argument names.
-argument-naming-style=snake_case
-
-# Regular expression matching correct argument names. Overrides argument-
-# naming-style.
-#argument-rgx=
-
-# Naming style matching correct attribute names.
-attr-naming-style=snake_case
-
-# Regular expression matching correct attribute names. Overrides attr-naming-
-# style.
-#attr-rgx=
-
-# Bad variable names which should always be refused, separated by a comma.
-bad-names=foo,
- bar,
- baz,
- toto,
- tutu,
- tata
-
-# Naming style matching correct class attribute names.
-class-attribute-naming-style=any
-
-# Regular expression matching correct class attribute names. Overrides class-
-# attribute-naming-style.
-#class-attribute-rgx=
-
-# Naming style matching correct class names.
-class-naming-style=PascalCase
-
-# Regular expression matching correct class names. Overrides class-naming-
-# style.
-#class-rgx=
-
-# Naming style matching correct constant names.
-const-naming-style=UPPER_CASE
-
-# Regular expression matching correct constant names. Overrides const-naming-
-# style.
-#const-rgx=
-
-# Minimum line length for functions/classes that require docstrings, shorter
-# ones are exempt.
-docstring-min-length=-1
-
-# Naming style matching correct function names.
-function-naming-style=snake_case
-
-# Regular expression matching correct function names. Overrides function-
-# naming-style.
-#function-rgx=
-
-# Good variable names which should always be accepted, separated by a comma.
-good-names=i,
- j,
- k,
- ex,
- Run,
- _
-
-# Include a hint for the correct naming format with invalid-name.
-include-naming-hint=no
-
-# Naming style matching correct inline iteration names.
-inlinevar-naming-style=any
-
-# Regular expression matching correct inline iteration names. Overrides
-# inlinevar-naming-style.
-#inlinevar-rgx=
-
-# Naming style matching correct method names.
-method-naming-style=snake_case
-
-# Regular expression matching correct method names. Overrides method-naming-
-# style.
-#method-rgx=
-
-# Naming style matching correct module names.
-module-naming-style=snake_case
-
-# Regular expression matching correct module names. Overrides module-naming-
-# style.
-#module-rgx=
-
-# Colon-delimited sets of names that determine each other's naming style when
-# the name regexes allow several styles.
-name-group=
-
-# Regular expression which should only match function or class names that do
-# not require a docstring.
-no-docstring-rgx=^_
-
-# List of decorators that produce properties, such as abc.abstractproperty. Add
-# to this list to register other decorators that produce valid properties.
-# These decorators are taken in consideration only for invalid-name.
-property-classes=abc.abstractproperty
-
-# Naming style matching correct variable names.
-variable-naming-style=snake_case
-
-# Regular expression matching correct variable names. Overrides variable-
-# naming-style.
-#variable-rgx=
-
-
-[FORMAT]
-
-# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
-expected-line-ending-format=
-
-# Regexp for a line that is allowed to be longer than the limit.
-ignore-long-lines=^\s*(# )??$
-
-# Number of spaces of indent required inside a hanging or continued line.
-indent-after-paren=4
-
-# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
-# tab).
-indent-string=' '
-
-# Maximum number of characters on a single line.
-max-line-length=120 # matches black setting
-
-# Maximum number of lines in a module.
-max-module-lines=1000
-
-# List of optional constructs for which whitespace checking is disabled. `dict-
-# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
-# `trailing-comma` allows a space between comma and closing bracket: (a, ).
-# `empty-line` allows space-only lines.
-no-space-check=trailing-comma,
- dict-separator
-
-# Allow the body of a class to be on the same line as the declaration if body
-# contains single statement.
-single-line-class-stmt=no
-
-# Allow the body of an if to be on the same line as the test if there is no
-# else.
-single-line-if-stmt=no
-
-
-[LOGGING]
-
-# Format style used to check logging format string. `old` means using %
-# formatting, `new` is for `{}` formatting,and `fstr` is for f-strings.
-logging-format-style=fstr
-
-# Logging modules to check that the string format arguments are in logging
-# function parameter format.
-logging-modules=logging
-
-
-[MISCELLANEOUS]
-
-# List of note tags to take in consideration, separated by a comma.
-notes=FIXME,
- XXX
-
-
-[SIMILARITIES]
-
-# Ignore comments when computing similarities.
-ignore-comments=yes
-
-# Ignore docstrings when computing similarities.
-ignore-docstrings=yes
-
-# Ignore imports when computing similarities.
-ignore-imports=no
-
-# Minimum lines number of a similarity.
-min-similarity-lines=4
-
-
-[SPELLING]
-
-# Limits count of emitted suggestions for spelling mistakes.
-max-spelling-suggestions=4
-
-# Spelling dictionary name. Available dictionaries: none. To make it work,
-# install the python-enchant package.
-spelling-dict=
-
-# List of comma separated words that should not be checked.
-spelling-ignore-words=
-
-# A path to a file that contains the private dictionary; one word per line.
-spelling-private-dict-file=
-
-# Tells whether to store unknown words to the private dictionary (see the
-# --spelling-private-dict-file option) instead of raising a message.
-spelling-store-unknown-words=no
-
-
-[STRING]
-
-# This flag controls whether the implicit-str-concat-in-sequence should
-# generate a warning on implicit string concatenation in sequences defined over
-# several lines.
-check-str-concat-over-line-jumps=no
-
-
-[TYPECHECK]
-
-# List of decorators that produce context managers, such as
-# contextlib.contextmanager. Add to this list to register other decorators that
-# produce valid context managers.
-contextmanager-decorators=contextlib.contextmanager
-
-# List of members which are set dynamically and missed by pylint inference
-# system, and so shouldn't trigger E1101 when accessed. Python regular
-# expressions are accepted.
-generated-members=
-
-# Tells whether missing members accessed in mixin class should be ignored. A
-# mixin class is detected if its name ends with "mixin" (case insensitive).
-ignore-mixin-members=yes
-
-# Tells whether to warn about missing members when the owner of the attribute
-# is inferred to be None.
-ignore-none=yes
-
-# This flag controls whether pylint should warn about no-member and similar
-# checks whenever an opaque object is returned when inferring. The inference
-# can return multiple potential results while evaluating a Python object, but
-# some branches might not be evaluated, which results in partial inference. In
-# that case, it might be useful to still emit no-member and other checks for
-# the rest of the inferred objects.
-ignore-on-opaque-inference=yes
-
-# List of class names for which member attributes should not be checked (useful
-# for classes with dynamically set attributes). This supports the use of
-# qualified names.
-ignored-classes=optparse.Values,thread._local,_thread._local
-
-# List of module names for which member attributes should not be checked
-# (useful for modules/projects where namespaces are manipulated during runtime
-# and thus existing member attributes cannot be deduced by static analysis). It
-# supports qualified module names, as well as Unix pattern matching.
-ignored-modules=
-
-# Show a hint with possible names when a member name was not found. The aspect
-# of finding the hint is based on edit distance.
-missing-member-hint=yes
-
-# The minimum edit distance a name should have in order to be considered a
-# similar match for a missing member name.
-missing-member-hint-distance=1
-
-# The total number of similar names that should be taken in consideration when
-# showing a hint for a missing member.
-missing-member-max-choices=1
-
-# List of decorators that change the signature of a decorated function.
-signature-mutators=
-
-
-[VARIABLES]
-
-# List of additional names supposed to be defined in builtins. Remember that
-# you should avoid defining new builtins when possible.
-additional-builtins=
-
-# Tells whether unused global variables should be treated as a violation.
-allow-global-unused-variables=yes
-
-# List of strings which can identify a callback function by name. A callback
-# name must start or end with one of those strings.
-callbacks=cb_,
- _cb
-
-# A regular expression matching the name of dummy variables (i.e. expected to
-# not be used).
-dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
-
-# Argument names that match this expression will be ignored. Default to name
-# with leading underscore.
-ignored-argument-names=_.*|^ignored_|^unused_
-
-# Tells whether we should check for unused import in __init__ files.
-init-import=no
-
-# List of qualified module names which can have objects that can redefine
-# builtins.
-redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
-
-
-[CLASSES]
-
-# List of method names used to declare (i.e. assign) instance attributes.
-defining-attr-methods=__init__,
- __new__,
- setUp,
- __post_init__
-
-# List of member names, which should be excluded from the protected access
-# warning.
-exclude-protected=_asdict,
- _fields,
- _replace,
- _source,
- _make
-
-# List of valid names for the first argument in a class method.
-valid-classmethod-first-arg=cls
-
-# List of valid names for the first argument in a metaclass class method.
-valid-metaclass-classmethod-first-arg=cls
-
-
-[DESIGN]
-
-# Maximum number of arguments for function / method.
-max-args=5
-
-# Maximum number of attributes for a class (see R0902).
-max-attributes=7
-
-# Maximum number of boolean expressions in an if statement (see R0916).
-max-bool-expr=5
-
-# Maximum number of branch for function / method body.
-max-branches=12
-
-# Maximum number of locals for function / method body.
-max-locals=15
-
-# Maximum number of parents for a class (see R0901).
-max-parents=7
-
-# Maximum number of public methods for a class (see R0904).
-max-public-methods=20
-
-# Maximum number of return / yield for function / method body.
-max-returns=6
-
-# Maximum number of statements in function / method body.
-max-statements=50
-
-# Minimum number of public methods for a class (see R0903).
-min-public-methods=2
-
-
-[IMPORTS]
-
-# List of modules that can be imported at any level, not just the top level
-# one.
-allow-any-import-level=
-
-# Allow wildcard imports from modules that define __all__.
-allow-wildcard-with-all=no
-
-# Analyse import fallback blocks. This can be used to support both Python 2 and
-# 3 compatible code, which means that the block might have code that exists
-# only in one or another interpreter, leading to false positives when analysed.
-analyse-fallback-blocks=no
-
-# Deprecated modules which should not be used, separated by a comma.
-deprecated-modules=optparse,tkinter.tix
-
-# Create a graph of external dependencies in the given file (report RP0402 must
-# not be disabled).
-ext-import-graph=
-
-# Create a graph of every (i.e. internal and external) dependencies in the
-# given file (report RP0402 must not be disabled).
-import-graph=
-
-# Create a graph of internal dependencies in the given file (report RP0402 must
-# not be disabled).
-int-import-graph=
-
-# Force import order to recognize a module as part of the standard
-# compatibility libraries.
-known-standard-library=
-
-# Force import order to recognize a module as part of a third party library.
-known-third-party=enchant
-
-# Couples of modules and preferred modules, separated by a comma.
-preferred-modules=
-
-
-[EXCEPTIONS]
-
-# Exceptions that will emit a warning when being caught. Defaults to
-# "BaseException, Exception".
-overgeneral-exceptions=BaseException,
- Exception
diff --git a/pyproject.toml b/pyproject.toml
index f1226541..b6bc6af6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -24,3 +24,39 @@ include_trailing_comma = "True"
force_grid_wrap = 0
use_parentheses = "True"
line_length = 120
+
+[tool.pylint.master]
+extension-pkg-whitelist = "pydantic"
+ignore = "CVS"
+suggestion-mode = "yes"
+[tool.pylint.messages_control]
+disable = '''
+duplicate-code,
+line-too-long,
+logging-fstring-interpolation,
+bad-continuation,
+'''
+[tool.pylint.logging]
+logging-modules = "logging"
+[tool.pylint.imports]
+allow-wildcard-with-all = "no"
+[tool.pylint.format]
+indent-after-paren = "4"
+max-line-length = "120" # matches black setting
+max-module-lines = "800"
+no-space-check = '''
+trailing-comma,
+dict-separator
+'''
+single-line-class-stmt = "no"
+single-line-if-stmt = "no"
+[tool.pylint.miscellaneous]
+notes= '''
+FIXME,
+XXX
+'''
+[tool.pylint.similarities]
+ignore-comments = "yes"
+ignore-docstrings = "yes"
+ignore-imports = "no"
+min-similarity-lines = "4"
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 374fb37c..7809162c 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,6 +1,6 @@
-i https://pypi.org/simple
appdirs==1.4.3
-astroid==2.3.3
+astroid==2.4.0
async-asgi-testclient==1.4.4
async-generator==1.10
asyncmock==0.4.2
@@ -9,7 +9,7 @@ bandit==1.6.2
black==19.10b0
certifi==2020.4.5.1
chardet==3.0.4
-click==7.1.1
+click==7.1.2
coverage==5.1
coveralls==2.0.0
docopt==0.6.2
@@ -29,15 +29,15 @@ pathspec==0.8.0
pbr==5.4.5
pluggy==0.13.1
py==1.8.1
-pylint==2.4.4
+pylint==2.5.0
pyparsing==2.4.7
-pytest-asyncio==0.10.0
+pytest-asyncio==0.11.0
pytest-cov==2.8.1
pytest==5.4.1
pyyaml==5.3.1
regex==2020.4.4
requests==2.23.0
-responses==0.10.12
+responses==0.10.14
six==1.14.0
smmap==3.0.2
stevedore==1.32.0
@@ -45,5 +45,5 @@ toml==0.10.0
typed-ast==1.4.1
urllib3==1.25.9
wcwidth==0.1.9
-wrapt==1.11.2
+wrapt==1.12.1
zipp==3.1.0
diff --git a/requirements.txt b/requirements.txt
index bb9302b1..8e0f2ff3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,28 +1,32 @@
-i https://pypi.org/simple
+aiocache[redis]==0.11.1
+aiofiles==0.5.0
aiohttp==3.6.2
+aioredis==1.3.1
async-timeout==3.0.1
asyncache==0.1.1
attrs==19.3.0
cachetools==4.1.0
certifi==2020.4.5.1
chardet==3.0.4
-click==7.1.1
+click==7.1.2
dataclasses==0.6 ; python_version < '3.7'
fastapi==0.54.1
gunicorn==20.0.4
h11==0.9.0
+hiredis==1.0.1
httptools==0.1.1 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
idna-ssl==1.1.0 ; python_version < '3.7'
idna==2.9
multidict==4.7.5
-pydantic==1.5
+pydantic[dotenv]==1.5.1
python-dateutil==2.8.1
python-dotenv==0.13.0
requests==2.23.0
six==1.14.0
starlette==0.13.2
urllib3==1.25.9
-uvicorn==0.11.3
+uvicorn==0.11.5
uvloop==0.14.0 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
websockets==8.1
yarl==1.4.2
diff --git a/tasks.py b/tasks.py
index 06a52486..ae1f09cd 100644
--- a/tasks.py
+++ b/tasks.py
@@ -46,6 +46,7 @@ def check(ctx, fmt=False, sort=False, diff=False): # pylint: disable=redefined-
fmt_args.append("--diff")
sort_args.append("--diff")
+ # FIXME: run each command and check return code
cmd_args = []
if fmt:
cmd_args.extend(fmt_args)
diff --git a/tests/test_io.py b/tests/test_io.py
index 83639cc9..c5d16c3a 100644
--- a/tests/test_io.py
+++ b/tests/test_io.py
@@ -5,8 +5,7 @@
import app.io
-
-@pytest.mark.parametrize(
+IO_PARAMS = (
"name, content, kwargs",
[
("test_file.txt", string.ascii_lowercase, {}),
@@ -14,6 +13,9 @@
("test_custom_json.json", {"z": -1, "b": 1, "y": -2, "a": 0}, {"indent": 4, "sort_keys": True}),
],
)
+
+
+@pytest.mark.parametrize(*IO_PARAMS)
def test_save(tmp_path, name, content, kwargs):
test_path = tmp_path / name
assert not test_path.exists()
@@ -23,17 +25,32 @@ def test_save(tmp_path, name, content, kwargs):
assert test_path.exists()
-@pytest.mark.parametrize(
- "name, content, kwargs",
- [
- ("test_file.txt", string.ascii_lowercase, {}),
- ("test_json_file.json", {"a": 0, "b": 1, "c": 2}, {}),
- ("test_custom_json.json", {"z": -1, "b": 1, "y": -2, "a": 0}, {"indent": 4, "sort_keys": True}),
- ],
-)
+@pytest.mark.parametrize(*IO_PARAMS)
def test_round_trip(tmp_path, name, content, kwargs):
test_path = tmp_path / name
assert not test_path.exists()
app.io.save(test_path, content, **kwargs)
assert app.io.load(test_path) == content
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(*IO_PARAMS)
+async def test_async_save(tmp_path, name, content, kwargs):
+ test_path = tmp_path / name
+ assert not test_path.exists()
+
+ result = await app.io.AIO.save(test_path, content, **kwargs)
+ assert result == test_path
+ assert test_path.exists()
+
+
+@pytest.mark.asyncio
+@pytest.mark.parametrize(*IO_PARAMS)
+async def test_async_round_trip(tmp_path, name, content, kwargs):
+ test_path = tmp_path / name
+ assert not test_path.exists()
+
+ await app.io.AIO.save(test_path, content, **kwargs)
+ load_results = await app.io.AIO.load(test_path)
+ assert load_results == content
From 37a1ad08c34a24a49c0226250c61ec8d9687aeec Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sat, 2 May 2020 10:53:43 -0400
Subject: [PATCH 47/61] reduce cache maxsize (#20) (#308)
---
app/services/location/jhu.py | 4 ++--
app/services/location/nyt.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py
index 11f6d120..1a11e8ac 100644
--- a/app/services/location/jhu.py
+++ b/app/services/location/jhu.py
@@ -46,10 +46,10 @@ async def get(self, loc_id): # pylint: disable=arguments-differ
)
-@cached(cache=TTLCache(maxsize=1024, ttl=1800))
+@cached(cache=TTLCache(maxsize=128, ttl=1800))
async def get_category(category):
"""
- Retrieves the data for the provided category. The data is cached for 1 hour.
+ Retrieves the data for the provided category. The data is cached for 30 minutes locally, 1 hour via shared Redis.
:returns: The data for category.
:rtype: dict
diff --git a/app/services/location/nyt.py b/app/services/location/nyt.py
index b33f5d3c..8b70c5cc 100644
--- a/app/services/location/nyt.py
+++ b/app/services/location/nyt.py
@@ -66,7 +66,7 @@ def get_grouped_locations_dict(data):
return grouped_locations
-@cached(cache=TTLCache(maxsize=1024, ttl=3600))
+@cached(cache=TTLCache(maxsize=128, ttl=3600))
async def get_locations():
"""
Returns a list containing parsed NYT data by US county. The data is cached for 1 hour.
From 160c40ea8b9d60cc1f97d5b26286c080150222ac Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sun, 3 May 2020 14:40:13 -0400
Subject: [PATCH 48/61] Scout APM Monitoring (#309)
* add scout-apm package
* add scout-apm config
* add scout apm middleware
---
Pipfile | 1 +
Pipfile.lock | 136 ++++++++++++++++++++++++++++++++++++++++++-
app/config.py | 2 +
app/main.py | 8 +++
requirements-dev.txt | 2 +-
requirements.txt | 10 +++-
6 files changed, 156 insertions(+), 3 deletions(-)
diff --git a/Pipfile b/Pipfile
index 50d0a8a2..584e4e10 100644
--- a/Pipfile
+++ b/Pipfile
@@ -32,6 +32,7 @@ idna_ssl = {version = "*",markers = "python_version<'3.7'"}
pydantic = {extras = ["dotenv"],version = "*"}
python-dateutil = "*"
requests = "*"
+scout-apm = "*"
uvicorn = "*"
[requires]
diff --git a/Pipfile.lock b/Pipfile.lock
index 43e27b0e..b1551678 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "596c0a497d4f2cfa9e3a3e8b38b2cf018ab3b6d9a26f04a949ced6b025e05f62"
+ "sha256": "1a448c6a753787b0b71c702c6b3baa4063b468afef4847b413459801d6e56592"
},
"pipfile-spec": 6,
"requires": {
@@ -60,6 +60,14 @@
],
"version": "==1.3.1"
},
+ "asgiref": {
+ "hashes": [
+ "sha256:8036f90603c54e93521e5777b2b9a39ba1bad05773fcf2d208f0299d1df58ce5",
+ "sha256:9ca8b952a0a9afa61d30aa6d3d9b570bb3fd6bafcf7ec9e6bed43b936133db1c"
+ ],
+ "markers": "python_version >= '3.5'",
+ "version": "==3.2.7"
+ },
"async-timeout": {
"hashes": [
"sha256:0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f",
@@ -96,6 +104,39 @@
],
"version": "==2020.4.5.1"
},
+ "cffi": {
+ "hashes": [
+ "sha256:001bf3242a1bb04d985d63e138230802c6c8d4db3668fb545fb5005ddf5bb5ff",
+ "sha256:00789914be39dffba161cfc5be31b55775de5ba2235fe49aa28c148236c4e06b",
+ "sha256:028a579fc9aed3af38f4892bdcc7390508adabc30c6af4a6e4f611b0c680e6ac",
+ "sha256:14491a910663bf9f13ddf2bc8f60562d6bc5315c1f09c704937ef17293fb85b0",
+ "sha256:1cae98a7054b5c9391eb3249b86e0e99ab1e02bb0cc0575da191aedadbdf4384",
+ "sha256:2089ed025da3919d2e75a4d963d008330c96751127dd6f73c8dc0c65041b4c26",
+ "sha256:2d384f4a127a15ba701207f7639d94106693b6cd64173d6c8988e2c25f3ac2b6",
+ "sha256:337d448e5a725bba2d8293c48d9353fc68d0e9e4088d62a9571def317797522b",
+ "sha256:399aed636c7d3749bbed55bc907c3288cb43c65c4389964ad5ff849b6370603e",
+ "sha256:3b911c2dbd4f423b4c4fcca138cadde747abdb20d196c4a48708b8a2d32b16dd",
+ "sha256:3d311bcc4a41408cf5854f06ef2c5cab88f9fded37a3b95936c9879c1640d4c2",
+ "sha256:62ae9af2d069ea2698bf536dcfe1e4eed9090211dbaafeeedf5cb6c41b352f66",
+ "sha256:66e41db66b47d0d8672d8ed2708ba91b2f2524ece3dee48b5dfb36be8c2f21dc",
+ "sha256:675686925a9fb403edba0114db74e741d8181683dcf216be697d208857e04ca8",
+ "sha256:7e63cbcf2429a8dbfe48dcc2322d5f2220b77b2e17b7ba023d6166d84655da55",
+ "sha256:8a6c688fefb4e1cd56feb6c511984a6c4f7ec7d2a1ff31a10254f3c817054ae4",
+ "sha256:8c0ffc886aea5df6a1762d0019e9cb05f825d0eec1f520c51be9d198701daee5",
+ "sha256:95cd16d3dee553f882540c1ffe331d085c9e629499ceadfbda4d4fde635f4b7d",
+ "sha256:99f748a7e71ff382613b4e1acc0ac83bf7ad167fb3802e35e90d9763daba4d78",
+ "sha256:b8c78301cefcf5fd914aad35d3c04c2b21ce8629b5e4f4e45ae6812e461910fa",
+ "sha256:c420917b188a5582a56d8b93bdd8e0f6eca08c84ff623a4c16e809152cd35793",
+ "sha256:c43866529f2f06fe0edc6246eb4faa34f03fe88b64a0a9a942561c8e22f4b71f",
+ "sha256:cab50b8c2250b46fe738c77dbd25ce017d5e6fb35d3407606e7a4180656a5a6a",
+ "sha256:cef128cb4d5e0b3493f058f10ce32365972c554572ff821e175dbc6f8ff6924f",
+ "sha256:cf16e3cf6c0a5fdd9bc10c21687e19d29ad1fe863372b5543deaec1039581a30",
+ "sha256:e56c744aa6ff427a607763346e4170629caf7e48ead6921745986db3692f987f",
+ "sha256:e577934fc5f8779c554639376beeaa5657d54349096ef24abe8c74c5d9c117c3",
+ "sha256:f2b0fa0c01d8a0c7483afd9f31d7ecf2d71760ca24499c8697aeb5ca37dc090c"
+ ],
+ "version": "==1.14.0"
+ },
"chardet": {
"hashes": [
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
@@ -110,6 +151,30 @@
],
"version": "==7.1.2"
},
+ "cryptography": {
+ "hashes": [
+ "sha256:091d31c42f444c6f519485ed528d8b451d1a0c7bf30e8ca583a0cac44b8a0df6",
+ "sha256:18452582a3c85b96014b45686af264563e3e5d99d226589f057ace56196ec78b",
+ "sha256:1dfa985f62b137909496e7fc182dac687206d8d089dd03eaeb28ae16eec8e7d5",
+ "sha256:1e4014639d3d73fbc5ceff206049c5a9a849cefd106a49fa7aaaa25cc0ce35cf",
+ "sha256:22e91636a51170df0ae4dcbd250d318fd28c9f491c4e50b625a49964b24fe46e",
+ "sha256:3b3eba865ea2754738616f87292b7f29448aec342a7c720956f8083d252bf28b",
+ "sha256:651448cd2e3a6bc2bb76c3663785133c40d5e1a8c1a9c5429e4354201c6024ae",
+ "sha256:726086c17f94747cedbee6efa77e99ae170caebeb1116353c6cf0ab67ea6829b",
+ "sha256:844a76bc04472e5135b909da6aed84360f522ff5dfa47f93e3dd2a0b84a89fa0",
+ "sha256:88c881dd5a147e08d1bdcf2315c04972381d026cdb803325c03fe2b4a8ed858b",
+ "sha256:96c080ae7118c10fcbe6229ab43eb8b090fccd31a09ef55f83f690d1ef619a1d",
+ "sha256:a0c30272fb4ddda5f5ffc1089d7405b7a71b0b0f51993cb4e5dbb4590b2fc229",
+ "sha256:bb1f0281887d89617b4c68e8db9a2c42b9efebf2702a3c5bf70599421a8623e3",
+ "sha256:c447cf087cf2dbddc1add6987bbe2f767ed5317adb2d08af940db517dd704365",
+ "sha256:c4fd17d92e9d55b84707f4fd09992081ba872d1a0c610c109c18e062e06a2e55",
+ "sha256:d0d5aeaedd29be304848f1c5059074a740fa9f6f26b84c5b63e8b29e73dfc270",
+ "sha256:daf54a4b07d67ad437ff239c8a4080cfd1cc7213df57d33c97de7b4738048d5e",
+ "sha256:e993468c859d084d5579e2ebee101de8f5a27ce8e2159959b6673b418fd8c785",
+ "sha256:f118a95c7480f5be0df8afeb9a11bd199aa20afab7a96bcf20409b411a3a85f0"
+ ],
+ "version": "==2.9.2"
+ },
"dataclasses": {
"hashes": [
"sha256:454a69d788c7fda44efd71e259be79577822f5e3f53f029a22d08004e951dc9f",
@@ -242,6 +307,29 @@
],
"version": "==4.7.5"
},
+ "psutil": {
+ "hashes": [
+ "sha256:1413f4158eb50e110777c4f15d7c759521703bd6beb58926f1d562da40180058",
+ "sha256:298af2f14b635c3c7118fd9183843f4e73e681bb6f01e12284d4d70d48a60953",
+ "sha256:60b86f327c198561f101a92be1995f9ae0399736b6eced8f24af41ec64fb88d4",
+ "sha256:685ec16ca14d079455892f25bd124df26ff9137664af445563c1bd36629b5e0e",
+ "sha256:73f35ab66c6c7a9ce82ba44b1e9b1050be2a80cd4dcc3352cc108656b115c74f",
+ "sha256:75e22717d4dbc7ca529ec5063000b2b294fc9a367f9c9ede1f65846c7955fd38",
+ "sha256:a02f4ac50d4a23253b68233b07e7cdb567bd025b982d5cf0ee78296990c22d9e",
+ "sha256:d008ddc00c6906ec80040d26dc2d3e3962109e40ad07fd8a12d0284ce5e0e4f8",
+ "sha256:d84029b190c8a66a946e28b4d3934d2ca1528ec94764b180f7d6ea57b0e75e26",
+ "sha256:e2d0c5b07c6fe5a87fa27b7855017edb0d52ee73b71e6ee368fae268605cc3f5",
+ "sha256:f344ca230dd8e8d5eee16827596f1c22ec0876127c28e800d7ae20ed44c4b310"
+ ],
+ "version": "==5.7.0"
+ },
+ "pycparser": {
+ "hashes": [
+ "sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0",
+ "sha256:7582ad22678f0fcd81102833f60ef8d0e57288b6b5fb00323d101be910e35705"
+ ],
+ "version": "==2.20"
+ },
"pydantic": {
"extras": [
"dotenv"
@@ -268,6 +356,13 @@
"index": "pypi",
"version": "==1.5.1"
},
+ "pyopenssl": {
+ "hashes": [
+ "sha256:621880965a720b8ece2f1b2f54ea2071966ab00e2970ad2ce11d596102063504",
+ "sha256:9a24494b2602aaf402be5c9e30a0b82d4a5c67528fe8fb475e3f3bc00dd69507"
+ ],
+ "version": "==19.1.0"
+ },
"python-dateutil": {
"hashes": [
"sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c",
@@ -291,6 +386,31 @@
"index": "pypi",
"version": "==2.23.0"
},
+ "scout-apm": {
+ "hashes": [
+ "sha256:0c1610f4ab58fc79acfea6e63a5d6769779695f9075ce80c6c1da1042c3f2fae",
+ "sha256:1290caa22eb307e9061466305deaccd7c8b3b9054ee32c8e4338e395ab346ce9",
+ "sha256:17e3c5f28809ec460f8bba1c40413345a8604d772dad5839e8ada15da3db2e25",
+ "sha256:1b16d9f46f10b425cac742db26e8e2157c1bfc314c81f772e94c808b685a52da",
+ "sha256:28ff9a628368bc00f271c1c25f99c8b62b7b4c030f43a681a6a68612d6fd7434",
+ "sha256:554faa7c655d0c2c847a8601078b4e6787bb27addc6404bd0a83ef915580fbab",
+ "sha256:64f9f51c9f937030c84207e19485558c2df3ffbe9774ec06e14ae4e6ec18a2ea",
+ "sha256:6b02a3a0000ed2f584c69e26391372910b93a78b0b9b99beb74dc0e42e944b31",
+ "sha256:72addd7a1be4a5630eb703e68a85f6d11216dfb8da4642e68d05737dc8e53384",
+ "sha256:8d30961b1a317fd5a357046bc9e6fdb170cd052aea8fafaaf3180423ae2bc8fd",
+ "sha256:9e93deab879fdce257296fba427c36b4e2840c1fc529e640faa19d9fb8a26c30",
+ "sha256:ab7eb611fa833e82206cb8c23eaf46466b0f29982f708b0d23721e51b133b7d4",
+ "sha256:c27fab283f55a66f00aafb4d1974d77b4e5d0edbea5c7e70d51bd018aadae8da",
+ "sha256:cdea8a54a4a8000559fc8abc25c78bc3209eb5fec44eeef73652d22625117522",
+ "sha256:d28f9261852511b67235014631f99bef220eb94c72a4d5497bcc858b04e94728",
+ "sha256:dfa2c75f3ecaa512aa4dd56b8aa6c60a1ebd31f578fc825e7d4b5e4d182d0b40",
+ "sha256:e1daac680081af6653bbc6fdc16ad8fac0bbe8ead834c023df2e291887fbd307",
+ "sha256:ebd23100982c6c346d1213ffd45c190e99219a3fc5511d353631fa3d34bb121e",
+ "sha256:f9f7dee5dcd63b7e5e21b86b048ab10c95ce5c3512206d807b8ae47c59ca2d24"
+ ],
+ "index": "pypi",
+ "version": "==2.14.1"
+ },
"six": {
"hashes": [
"sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a",
@@ -306,10 +426,14 @@
"version": "==0.13.2"
},
"urllib3": {
+ "extras": [
+ "secure"
+ ],
"hashes": [
"sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527",
"sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
],
+ "markers": "python_version >= '3.5'",
"version": "==1.25.9"
},
"uvicorn": {
@@ -362,6 +486,12 @@
],
"version": "==8.1"
},
+ "wrapt": {
+ "hashes": [
+ "sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"
+ ],
+ "version": "==1.12.1"
+ },
"yarl": {
"hashes": [
"sha256:0c2ab325d33f1b824734b3ef51d4d54a54e0e7a23d13b86974507602334c2cce",
@@ -820,10 +950,14 @@
"version": "==1.4.1"
},
"urllib3": {
+ "extras": [
+ "secure"
+ ],
"hashes": [
"sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527",
"sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
],
+ "markers": "python_version >= '3.5'",
"version": "==1.25.9"
},
"wcwidth": {
diff --git a/app/config.py b/app/config.py
index 7d911e4d..ab60d42b 100644
--- a/app/config.py
+++ b/app/config.py
@@ -11,6 +11,8 @@ class _Settings(BaseSettings):
port: int = 5000
rediscloud_url: AnyUrl = None
local_redis_url: AnyUrl = None
+ # Scout APM
+ scout_name: str = None
@functools.lru_cache()
diff --git a/app/main.py b/app/main.py
index 3e5ee010..f8ed1b41 100644
--- a/app/main.py
+++ b/app/main.py
@@ -9,6 +9,7 @@
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import JSONResponse
+from scout_apm.async_.starlette import ScoutMiddleware
from .config import get_settings
from .data import data_source
@@ -39,6 +40,13 @@
# Middleware
#######################
+# Scout APM
+if SETTINGS.scout_name: # pragma: no cover
+ LOGGER.info(f"Adding Scout APM middleware for `{SETTINGS.scout_name}`")
+ APP.add_middleware(ScoutMiddleware)
+else:
+ LOGGER.debug("No SCOUT_NAME config")
+
# Enable CORS.
APP.add_middleware(
CORSMiddleware, allow_credentials=True, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"],
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 7809162c..1d919ece 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -43,7 +43,7 @@ smmap==3.0.2
stevedore==1.32.0
toml==0.10.0
typed-ast==1.4.1
-urllib3==1.25.9
+urllib3[secure]==1.25.9 ; python_version >= '3.5'
wcwidth==0.1.9
wrapt==1.12.1
zipp==3.1.0
diff --git a/requirements.txt b/requirements.txt
index 8e0f2ff3..dd2ece5a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,13 +3,16 @@ aiocache[redis]==0.11.1
aiofiles==0.5.0
aiohttp==3.6.2
aioredis==1.3.1
+asgiref==3.2.7 ; python_version >= '3.5'
async-timeout==3.0.1
asyncache==0.1.1
attrs==19.3.0
cachetools==4.1.0
certifi==2020.4.5.1
+cffi==1.14.0
chardet==3.0.4
click==7.1.2
+cryptography==2.9.2
dataclasses==0.6 ; python_version < '3.7'
fastapi==0.54.1
gunicorn==20.0.4
@@ -19,14 +22,19 @@ httptools==0.1.1 ; sys_platform != 'win32' and sys_platform != 'cygwin' and plat
idna-ssl==1.1.0 ; python_version < '3.7'
idna==2.9
multidict==4.7.5
+psutil==5.7.0
+pycparser==2.20
pydantic[dotenv]==1.5.1
+pyopenssl==19.1.0
python-dateutil==2.8.1
python-dotenv==0.13.0
requests==2.23.0
+scout-apm==2.14.1
six==1.14.0
starlette==0.13.2
-urllib3==1.25.9
+urllib3[secure]==1.25.9 ; python_version >= '3.5'
uvicorn==0.11.5
uvloop==0.14.0 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
websockets==8.1
+wrapt==1.12.1
yarl==1.4.2
From 1eee4598a567cdd9dfa2e7bffa82ffe21785999b Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Thu, 7 May 2020 22:35:02 -0400
Subject: [PATCH 49/61] 3 workers
---
Procfile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Procfile b/Procfile
index 094ebc0a..517e2a0c 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-web: gunicorn app.main:APP -w 4 -k uvicorn.workers.UvicornWorker
+web: gunicorn app.main:APP -w 3 -k uvicorn.workers.UvicornWorker
From 375794e1a17fb955282bc148cff62ee873e89ff4 Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Sat, 9 May 2020 16:17:58 -0400
Subject: [PATCH 50/61] Track Errors with Sentry (#311)
* add sentry-sdk
* add sentry middleware
---
Pipfile | 1 +
Pipfile.lock | 97 ++++++++++++++++++++++++--------------------
app/config.py | 2 +
app/main.py | 10 +++++
requirements-dev.txt | 16 ++++----
requirements.txt | 1 +
6 files changed, 74 insertions(+), 53 deletions(-)
diff --git a/Pipfile b/Pipfile
index 584e4e10..57ef4ae7 100644
--- a/Pipfile
+++ b/Pipfile
@@ -33,6 +33,7 @@ pydantic = {extras = ["dotenv"],version = "*"}
python-dateutil = "*"
requests = "*"
scout-apm = "*"
+sentry-sdk = "*"
uvicorn = "*"
[requires]
diff --git a/Pipfile.lock b/Pipfile.lock
index b1551678..7cdfd8a1 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "1a448c6a753787b0b71c702c6b3baa4063b468afef4847b413459801d6e56592"
+ "sha256": "dfa074e03982c046ee011817d151762138abfc1f13ae4e67700233599af18c3e"
},
"pipfile-spec": 6,
"requires": {
@@ -411,6 +411,14 @@
"index": "pypi",
"version": "==2.14.1"
},
+ "sentry-sdk": {
+ "hashes": [
+ "sha256:23808d571d2461a4ce3784ec12bbee5bdb8c026c143fe79d36cef8a6d653e71f",
+ "sha256:bb90a4e19c7233a580715fc986cc44be2c48fc10b31e71580a2037e1c94b6950"
+ ],
+ "index": "pypi",
+ "version": "==0.14.3"
+ },
"six": {
"hashes": [
"sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a",
@@ -525,10 +533,10 @@
},
"astroid": {
"hashes": [
- "sha256:29fa5d46a2404d01c834fcb802a3943685f1fc538eb2a02a161349f5505ac196",
- "sha256:2fecea42b20abb1922ed65c7b5be27edfba97211b04b2b6abc6a43549a024ea6"
+ "sha256:4c17cea3e592c21b6e222f673868961bad77e1f985cb1694ed077475a89229c1",
+ "sha256:d8506842a3faf734b81599c8b98dcc423de863adcc1999248480b18bd31a0f38"
],
- "version": "==2.4.0"
+ "version": "==2.4.1"
},
"async-asgi-testclient": {
"hashes": [
@@ -649,17 +657,17 @@
},
"gitdb": {
"hashes": [
- "sha256:6f0ecd46f99bb4874e5678d628c3a198e2b4ef38daea2756a2bfd8df7dd5c1a5",
- "sha256:ba1132c0912e8c917aa8aa990bee26315064c7b7f171ceaaac0afeb1dc656c6a"
+ "sha256:91f36bfb1ab7949b3b40e23736db18231bf7593edada2ba5c3a174a7b23657ac",
+ "sha256:c9e1f2d0db7ddb9a704c2a0217be31214e91a4fe1dea1efad19ae42ba0c285c9"
],
- "version": "==4.0.4"
+ "version": "==4.0.5"
},
"gitpython": {
"hashes": [
- "sha256:6d4f10e2aaad1864bb0f17ec06a2c2831534140e5883c350d58b4e85189dab74",
- "sha256:71b8dad7409efbdae4930f2b0b646aaeccce292484ffa0bc74f1195582578b3d"
+ "sha256:864a47472548f3ba716ca202e034c1900f197c0fb3a08f641c20c3cafd15ed94",
+ "sha256:da3b2cf819974789da34f95ac218ef99f515a928685db141327c09b73dd69c09"
],
- "version": "==3.1.1"
+ "version": "==3.1.2"
},
"idna": {
"hashes": [
@@ -800,11 +808,11 @@
},
"pylint": {
"hashes": [
- "sha256:588e114e3f9a1630428c35b7dd1c82c1c93e1b0e78ee312ae4724c5e1a1e0245",
- "sha256:bd556ba95a4cf55a1fc0004c00cf4560b1e70598a54a74c6904d933c8f3bd5a8"
+ "sha256:b95e31850f3af163c2283ed40432f053acbc8fc6eba6a069cb518d9dbf71848c",
+ "sha256:dd506acce0427e9e08fb87274bcaa953d38b50a58207170dbf5b36cf3e16957b"
],
"index": "pypi",
- "version": "==2.5.0"
+ "version": "==2.5.2"
},
"pyparsing": {
"hashes": [
@@ -815,19 +823,18 @@
},
"pytest": {
"hashes": [
- "sha256:0e5b30f5cb04e887b91b1ee519fa3d89049595f428c1db76e73bd7f17b09b172",
- "sha256:84dde37075b8805f3d1f392cc47e38a0e59518fb46a431cfdaf7cf1ce805f970"
+ "sha256:95c710d0a72d91c13fae35dce195633c929c3792f54125919847fdcdf7caa0d3",
+ "sha256:eb2b5e935f6a019317e455b6da83dd8650ac9ffd2ee73a7b657a30873d67a698"
],
"index": "pypi",
- "version": "==5.4.1"
+ "version": "==5.4.2"
},
"pytest-asyncio": {
"hashes": [
- "sha256:6096d101a1ae350d971df05e25f4a8b4d3cd13ffb1b32e42d902ac49670d2bfa",
- "sha256:c54866f3cf5dd2063992ba2c34784edae11d3ed19e006d220a3cf0bfc4191fcb"
+ "sha256:475bd2f3dc0bc11d2463656b3cbaafdbec5a47b47508ea0b329ee693040eebd2"
],
"index": "pypi",
- "version": "==0.11.0"
+ "version": "==0.12.0"
},
"pytest-cov": {
"hashes": [
@@ -855,29 +862,29 @@
},
"regex": {
"hashes": [
- "sha256:08119f707f0ebf2da60d2f24c2f39ca616277bb67ef6c92b72cbf90cbe3a556b",
- "sha256:0ce9537396d8f556bcfc317c65b6a0705320701e5ce511f05fc04421ba05b8a8",
- "sha256:1cbe0fa0b7f673400eb29e9ef41d4f53638f65f9a2143854de6b1ce2899185c3",
- "sha256:2294f8b70e058a2553cd009df003a20802ef75b3c629506be20687df0908177e",
- "sha256:23069d9c07e115537f37270d1d5faea3e0bdded8279081c4d4d607a2ad393683",
- "sha256:24f4f4062eb16c5bbfff6a22312e8eab92c2c99c51a02e39b4eae54ce8255cd1",
- "sha256:295badf61a51add2d428a46b8580309c520d8b26e769868b922750cf3ce67142",
- "sha256:2a3bf8b48f8e37c3a40bb3f854bf0121c194e69a650b209628d951190b862de3",
- "sha256:4385f12aa289d79419fede43f979e372f527892ac44a541b5446617e4406c468",
- "sha256:5635cd1ed0a12b4c42cce18a8d2fb53ff13ff537f09de5fd791e97de27b6400e",
- "sha256:5bfed051dbff32fd8945eccca70f5e22b55e4148d2a8a45141a3b053d6455ae3",
- "sha256:7e1037073b1b7053ee74c3c6c0ada80f3501ec29d5f46e42669378eae6d4405a",
- "sha256:90742c6ff121a9c5b261b9b215cb476eea97df98ea82037ec8ac95d1be7a034f",
- "sha256:a58dd45cb865be0ce1d5ecc4cfc85cd8c6867bea66733623e54bd95131f473b6",
- "sha256:c087bff162158536387c53647411db09b6ee3f9603c334c90943e97b1052a156",
- "sha256:c162a21e0da33eb3d31a3ac17a51db5e634fc347f650d271f0305d96601dc15b",
- "sha256:c9423a150d3a4fc0f3f2aae897a59919acd293f4cb397429b120a5fcd96ea3db",
- "sha256:ccccdd84912875e34c5ad2d06e1989d890d43af6c2242c6fcfa51556997af6cd",
- "sha256:e91ba11da11cf770f389e47c3f5c30473e6d85e06d7fd9dcba0017d2867aab4a",
- "sha256:ea4adf02d23b437684cd388d557bf76e3afa72f7fed5bbc013482cc00c816948",
- "sha256:fb95debbd1a824b2c4376932f2216cc186912e389bdb0e27147778cf6acb3f89"
- ],
- "version": "==2020.4.4"
+ "sha256:021a0ae4d2baeeb60a3014805a2096cb329bd6d9f30669b7ad0da51a9cb73349",
+ "sha256:04d6e948ef34d3eac133bedc0098364a9e635a7914f050edb61272d2ddae3608",
+ "sha256:099568b372bda492be09c4f291b398475587d49937c659824f891182df728cdf",
+ "sha256:0ff50843535593ee93acab662663cb2f52af8e31c3f525f630f1dc6156247938",
+ "sha256:1b17bf37c2aefc4cac8436971fe6ee52542ae4225cfc7762017f7e97a63ca998",
+ "sha256:1e2255ae938a36e9bd7db3b93618796d90c07e5f64dd6a6750c55f51f8b76918",
+ "sha256:2bc6a17a7fa8afd33c02d51b6f417fc271538990297167f68a98cae1c9e5c945",
+ "sha256:3ab5e41c4ed7cd4fa426c50add2892eb0f04ae4e73162155cd668257d02259dd",
+ "sha256:3b059e2476b327b9794c792c855aa05531a3f3044737e455d283c7539bd7534d",
+ "sha256:4df91094ced6f53e71f695c909d9bad1cca8761d96fd9f23db12245b5521136e",
+ "sha256:5493a02c1882d2acaaf17be81a3b65408ff541c922bfd002535c5f148aa29f74",
+ "sha256:5b741ecc3ad3e463d2ba32dce512b412c319993c1bb3d999be49e6092a769fb2",
+ "sha256:652ab4836cd5531d64a34403c00ada4077bb91112e8bcdae933e2eae232cf4a8",
+ "sha256:669a8d46764a09f198f2e91fc0d5acdac8e6b620376757a04682846ae28879c4",
+ "sha256:73a10404867b835f1b8a64253e4621908f0d71150eb4e97ab2e7e441b53e9451",
+ "sha256:7ce4a213a96d6c25eeae2f7d60d4dad89ac2b8134ec3e69db9bc522e2c0f9388",
+ "sha256:8127ca2bf9539d6a64d03686fd9e789e8c194fc19af49b69b081f8c7e6ecb1bc",
+ "sha256:b5b5b2e95f761a88d4c93691716ce01dc55f288a153face1654f868a8034f494",
+ "sha256:b7c9f65524ff06bf70c945cd8d8d1fd90853e27ccf86026af2afb4d9a63d06b1",
+ "sha256:f7f2f4226db6acd1da228adf433c5c3792858474e49d80668ea82ac87cf74a03",
+ "sha256:fa09da4af4e5b15c0e8b4986a083f3fd159302ea115a6cc0649cd163435538b8"
+ ],
+ "version": "==2020.5.7"
},
"requests": {
"hashes": [
@@ -904,10 +911,10 @@
},
"smmap": {
"hashes": [
- "sha256:52ea78b3e708d2c2b0cfe93b6fc3fbeec53db913345c26be6ed84c11ed8bebc1",
- "sha256:b46d3fc69ba5f367df96d91f8271e8ad667a198d5a28e215a6c3d9acd133a911"
+ "sha256:54c44c197c819d5ef1991799a7e30b662d1e520f2ac75c9efbeb54a742214cf4",
+ "sha256:9c98bbd1f9786d22f14b3d4126894d56befb835ec90cef151af566c7e19b5d24"
],
- "version": "==3.0.2"
+ "version": "==3.0.4"
},
"stevedore": {
"hashes": [
diff --git a/app/config.py b/app/config.py
index ab60d42b..377ebc13 100644
--- a/app/config.py
+++ b/app/config.py
@@ -13,6 +13,8 @@ class _Settings(BaseSettings):
local_redis_url: AnyUrl = None
# Scout APM
scout_name: str = None
+ # Sentry
+ sentry_dsn: str = None
@functools.lru_cache()
diff --git a/app/main.py b/app/main.py
index f8ed1b41..9b335df3 100644
--- a/app/main.py
+++ b/app/main.py
@@ -4,12 +4,14 @@
import logging
import pydantic
+import sentry_sdk
import uvicorn
from fastapi import FastAPI, Request, Response
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import JSONResponse
from scout_apm.async_.starlette import ScoutMiddleware
+from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
from .config import get_settings
from .data import data_source
@@ -23,6 +25,9 @@
SETTINGS = get_settings()
+if SETTINGS.sentry_dsn: # pragma: no cover
+ sentry_sdk.init(dsn=SETTINGS.sentry_dsn)
+
APP = FastAPI(
title="Coronavirus Tracker",
description=(
@@ -47,6 +52,11 @@
else:
LOGGER.debug("No SCOUT_NAME config")
+# Sentry Error Tracking
+if SETTINGS.sentry_dsn: # pragma: no cover
+ LOGGER.info("Adding Sentry middleware")
+ APP.add_middleware(SentryAsgiMiddleware)
+
# Enable CORS.
APP.add_middleware(
CORSMiddleware, allow_credentials=True, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"],
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 1d919ece..d95c199e 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,6 +1,6 @@
-i https://pypi.org/simple
appdirs==1.4.3
-astroid==2.4.0
+astroid==2.4.1
async-asgi-testclient==1.4.4
async-generator==1.10
asyncmock==0.4.2
@@ -13,8 +13,8 @@ click==7.1.2
coverage==5.1
coveralls==2.0.0
docopt==0.6.2
-gitdb==4.0.4
-gitpython==3.1.1
+gitdb==4.0.5
+gitpython==3.1.2
idna==2.9
importlib-metadata==1.6.0 ; python_version < '3.8'
invoke==1.4.1
@@ -29,17 +29,17 @@ pathspec==0.8.0
pbr==5.4.5
pluggy==0.13.1
py==1.8.1
-pylint==2.5.0
+pylint==2.5.2
pyparsing==2.4.7
-pytest-asyncio==0.11.0
+pytest-asyncio==0.12.0
pytest-cov==2.8.1
-pytest==5.4.1
+pytest==5.4.2
pyyaml==5.3.1
-regex==2020.4.4
+regex==2020.5.7
requests==2.23.0
responses==0.10.14
six==1.14.0
-smmap==3.0.2
+smmap==3.0.4
stevedore==1.32.0
toml==0.10.0
typed-ast==1.4.1
diff --git a/requirements.txt b/requirements.txt
index dd2ece5a..02ab222e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -30,6 +30,7 @@ python-dateutil==2.8.1
python-dotenv==0.13.0
requests==2.23.0
scout-apm==2.14.1
+sentry-sdk==0.14.3
six==1.14.0
starlette==0.13.2
urllib3[secure]==1.25.9 ; python_version >= '3.5'
From 7d329e016036a23cb116c372afeee6aead8bf29e Mon Sep 17 00:00:00 2001
From: Gabriel
Date: Tue, 28 Jul 2020 17:08:00 -0400
Subject: [PATCH 51/61] FastAPI update and serve static Swagger assets (#324)
* update FastAPI 0.54.1 -> 0.60.1
* static Swagger files
---
Pipfile.lock | 726 ++++++++++++++++++------------------
app/main.py | 32 +-
requirements-dev.txt | 48 +--
requirements.txt | 41 +-
static/redoc.standalone.js | 137 +++++++
static/swagger-ui-bundle.js | 92 +++++
static/swagger-ui.css | 4 +
7 files changed, 679 insertions(+), 401 deletions(-)
create mode 100644 static/redoc.standalone.js
create mode 100644 static/swagger-ui-bundle.js
create mode 100644 static/swagger-ui.css
diff --git a/Pipfile.lock b/Pipfile.lock
index 7cdfd8a1..c68ce3a1 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -62,11 +62,11 @@
},
"asgiref": {
"hashes": [
- "sha256:8036f90603c54e93521e5777b2b9a39ba1bad05773fcf2d208f0299d1df58ce5",
- "sha256:9ca8b952a0a9afa61d30aa6d3d9b570bb3fd6bafcf7ec9e6bed43b936133db1c"
+ "sha256:7e51911ee147dd685c3c8b805c0ad0cb58d360987b56953878f8c06d2d1c6f1a",
+ "sha256:9fc6fb5d39b8af147ba40765234fa822b39818b12cc80b35ad9b0cef3a476aed"
],
"markers": "python_version >= '3.5'",
- "version": "==3.2.7"
+ "version": "==3.2.10"
},
"async-timeout": {
"hashes": [
@@ -91,51 +91,51 @@
},
"cachetools": {
"hashes": [
- "sha256:1d057645db16ca7fe1f3bd953558897603d6f0b9c51ed9d11eb4d071ec4e2aab",
- "sha256:de5d88f87781602201cde465d3afe837546663b168e8b39df67411b0bf10cefc"
+ "sha256:513d4ff98dd27f85743a8dc0e92f55ddb1b49e060c2d5961512855cda2c01a98",
+ "sha256:bbaa39c3dede00175df2dc2b03d0cf18dd2d32a7de7beb68072d13043c9edb20"
],
"index": "pypi",
- "version": "==4.1.0"
+ "version": "==4.1.1"
},
"certifi": {
"hashes": [
- "sha256:1d987a998c75633c40847cc966fcf5904906c920a7f17ef374f5aa4282abd304",
- "sha256:51fcb31174be6e6664c5f69e3e1691a2d72a1a12e90f872cbdb1567eb47b6519"
+ "sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3",
+ "sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41"
],
- "version": "==2020.4.5.1"
+ "version": "==2020.6.20"
},
"cffi": {
"hashes": [
- "sha256:001bf3242a1bb04d985d63e138230802c6c8d4db3668fb545fb5005ddf5bb5ff",
- "sha256:00789914be39dffba161cfc5be31b55775de5ba2235fe49aa28c148236c4e06b",
- "sha256:028a579fc9aed3af38f4892bdcc7390508adabc30c6af4a6e4f611b0c680e6ac",
- "sha256:14491a910663bf9f13ddf2bc8f60562d6bc5315c1f09c704937ef17293fb85b0",
- "sha256:1cae98a7054b5c9391eb3249b86e0e99ab1e02bb0cc0575da191aedadbdf4384",
- "sha256:2089ed025da3919d2e75a4d963d008330c96751127dd6f73c8dc0c65041b4c26",
- "sha256:2d384f4a127a15ba701207f7639d94106693b6cd64173d6c8988e2c25f3ac2b6",
- "sha256:337d448e5a725bba2d8293c48d9353fc68d0e9e4088d62a9571def317797522b",
- "sha256:399aed636c7d3749bbed55bc907c3288cb43c65c4389964ad5ff849b6370603e",
- "sha256:3b911c2dbd4f423b4c4fcca138cadde747abdb20d196c4a48708b8a2d32b16dd",
- "sha256:3d311bcc4a41408cf5854f06ef2c5cab88f9fded37a3b95936c9879c1640d4c2",
- "sha256:62ae9af2d069ea2698bf536dcfe1e4eed9090211dbaafeeedf5cb6c41b352f66",
- "sha256:66e41db66b47d0d8672d8ed2708ba91b2f2524ece3dee48b5dfb36be8c2f21dc",
- "sha256:675686925a9fb403edba0114db74e741d8181683dcf216be697d208857e04ca8",
- "sha256:7e63cbcf2429a8dbfe48dcc2322d5f2220b77b2e17b7ba023d6166d84655da55",
- "sha256:8a6c688fefb4e1cd56feb6c511984a6c4f7ec7d2a1ff31a10254f3c817054ae4",
- "sha256:8c0ffc886aea5df6a1762d0019e9cb05f825d0eec1f520c51be9d198701daee5",
- "sha256:95cd16d3dee553f882540c1ffe331d085c9e629499ceadfbda4d4fde635f4b7d",
- "sha256:99f748a7e71ff382613b4e1acc0ac83bf7ad167fb3802e35e90d9763daba4d78",
- "sha256:b8c78301cefcf5fd914aad35d3c04c2b21ce8629b5e4f4e45ae6812e461910fa",
- "sha256:c420917b188a5582a56d8b93bdd8e0f6eca08c84ff623a4c16e809152cd35793",
- "sha256:c43866529f2f06fe0edc6246eb4faa34f03fe88b64a0a9a942561c8e22f4b71f",
- "sha256:cab50b8c2250b46fe738c77dbd25ce017d5e6fb35d3407606e7a4180656a5a6a",
- "sha256:cef128cb4d5e0b3493f058f10ce32365972c554572ff821e175dbc6f8ff6924f",
- "sha256:cf16e3cf6c0a5fdd9bc10c21687e19d29ad1fe863372b5543deaec1039581a30",
- "sha256:e56c744aa6ff427a607763346e4170629caf7e48ead6921745986db3692f987f",
- "sha256:e577934fc5f8779c554639376beeaa5657d54349096ef24abe8c74c5d9c117c3",
- "sha256:f2b0fa0c01d8a0c7483afd9f31d7ecf2d71760ca24499c8697aeb5ca37dc090c"
- ],
- "version": "==1.14.0"
+ "sha256:267adcf6e68d77ba154334a3e4fc921b8e63cbb38ca00d33d40655d4228502bc",
+ "sha256:26f33e8f6a70c255767e3c3f957ccafc7f1f706b966e110b855bfe944511f1f9",
+ "sha256:3cd2c044517f38d1b577f05927fb9729d3396f1d44d0c659a445599e79519792",
+ "sha256:4a03416915b82b81af5502459a8a9dd62a3c299b295dcdf470877cb948d655f2",
+ "sha256:4ce1e995aeecf7cc32380bc11598bfdfa017d592259d5da00fc7ded11e61d022",
+ "sha256:4f53e4128c81ca3212ff4cf097c797ab44646a40b42ec02a891155cd7a2ba4d8",
+ "sha256:4fa72a52a906425416f41738728268072d5acfd48cbe7796af07a923236bcf96",
+ "sha256:66dd45eb9530e3dde8f7c009f84568bc7cac489b93d04ac86e3111fb46e470c2",
+ "sha256:6923d077d9ae9e8bacbdb1c07ae78405a9306c8fd1af13bfa06ca891095eb995",
+ "sha256:833401b15de1bb92791d7b6fb353d4af60dc688eaa521bd97203dcd2d124a7c1",
+ "sha256:8416ed88ddc057bab0526d4e4e9f3660f614ac2394b5e019a628cdfff3733849",
+ "sha256:892daa86384994fdf4856cb43c93f40cbe80f7f95bb5da94971b39c7f54b3a9c",
+ "sha256:98be759efdb5e5fa161e46d404f4e0ce388e72fbf7d9baf010aff16689e22abe",
+ "sha256:a6d28e7f14ecf3b2ad67c4f106841218c8ab12a0683b1528534a6c87d2307af3",
+ "sha256:b1d6ebc891607e71fd9da71688fcf332a6630b7f5b7f5549e6e631821c0e5d90",
+ "sha256:b2a2b0d276a136146e012154baefaea2758ef1f56ae9f4e01c612b0831e0bd2f",
+ "sha256:b87dfa9f10a470eee7f24234a37d1d5f51e5f5fa9eeffda7c282e2b8f5162eb1",
+ "sha256:bac0d6f7728a9cc3c1e06d4fcbac12aaa70e9379b3025b27ec1226f0e2d404cf",
+ "sha256:c991112622baee0ae4d55c008380c32ecfd0ad417bcd0417ba432e6ba7328caa",
+ "sha256:cda422d54ee7905bfc53ee6915ab68fe7b230cacf581110df4272ee10462aadc",
+ "sha256:d3148b6ba3923c5850ea197a91a42683f946dba7e8eb82dfa211ab7e708de939",
+ "sha256:d6033b4ffa34ef70f0b8086fd4c3df4bf801fee485a8a7d4519399818351aa8e",
+ "sha256:ddff0b2bd7edcc8c82d1adde6dbbf5e60d57ce985402541cd2985c27f7bec2a0",
+ "sha256:e23cb7f1d8e0f93addf0cae3c5b6f00324cccb4a7949ee558d7b6ca973ab8ae9",
+ "sha256:effd2ba52cee4ceff1a77f20d2a9f9bf8d50353c854a282b8760ac15b9833168",
+ "sha256:f90c2267101010de42f7273c94a1f026e56cbc043f9330acd8a80e64300aba33",
+ "sha256:f960375e9823ae6a07072ff7f8a85954e5a6434f97869f50d0e41649a1c8144f",
+ "sha256:fcf32bf76dc25e30ed793145a57426064520890d7c02866eb93d3e4abe516948"
+ ],
+ "version": "==1.14.1"
},
"chardet": {
"hashes": [
@@ -153,27 +153,27 @@
},
"cryptography": {
"hashes": [
- "sha256:091d31c42f444c6f519485ed528d8b451d1a0c7bf30e8ca583a0cac44b8a0df6",
- "sha256:18452582a3c85b96014b45686af264563e3e5d99d226589f057ace56196ec78b",
- "sha256:1dfa985f62b137909496e7fc182dac687206d8d089dd03eaeb28ae16eec8e7d5",
- "sha256:1e4014639d3d73fbc5ceff206049c5a9a849cefd106a49fa7aaaa25cc0ce35cf",
- "sha256:22e91636a51170df0ae4dcbd250d318fd28c9f491c4e50b625a49964b24fe46e",
- "sha256:3b3eba865ea2754738616f87292b7f29448aec342a7c720956f8083d252bf28b",
- "sha256:651448cd2e3a6bc2bb76c3663785133c40d5e1a8c1a9c5429e4354201c6024ae",
- "sha256:726086c17f94747cedbee6efa77e99ae170caebeb1116353c6cf0ab67ea6829b",
- "sha256:844a76bc04472e5135b909da6aed84360f522ff5dfa47f93e3dd2a0b84a89fa0",
- "sha256:88c881dd5a147e08d1bdcf2315c04972381d026cdb803325c03fe2b4a8ed858b",
- "sha256:96c080ae7118c10fcbe6229ab43eb8b090fccd31a09ef55f83f690d1ef619a1d",
- "sha256:a0c30272fb4ddda5f5ffc1089d7405b7a71b0b0f51993cb4e5dbb4590b2fc229",
- "sha256:bb1f0281887d89617b4c68e8db9a2c42b9efebf2702a3c5bf70599421a8623e3",
- "sha256:c447cf087cf2dbddc1add6987bbe2f767ed5317adb2d08af940db517dd704365",
- "sha256:c4fd17d92e9d55b84707f4fd09992081ba872d1a0c610c109c18e062e06a2e55",
- "sha256:d0d5aeaedd29be304848f1c5059074a740fa9f6f26b84c5b63e8b29e73dfc270",
- "sha256:daf54a4b07d67ad437ff239c8a4080cfd1cc7213df57d33c97de7b4738048d5e",
- "sha256:e993468c859d084d5579e2ebee101de8f5a27ce8e2159959b6673b418fd8c785",
- "sha256:f118a95c7480f5be0df8afeb9a11bd199aa20afab7a96bcf20409b411a3a85f0"
- ],
- "version": "==2.9.2"
+ "sha256:0c608ff4d4adad9e39b5057de43657515c7da1ccb1807c3a27d4cf31fc923b4b",
+ "sha256:0cbfed8ea74631fe4de00630f4bb592dad564d57f73150d6f6796a24e76c76cd",
+ "sha256:124af7255ffc8e964d9ff26971b3a6153e1a8a220b9a685dc407976ecb27a06a",
+ "sha256:384d7c681b1ab904fff3400a6909261cae1d0939cc483a68bdedab282fb89a07",
+ "sha256:45741f5499150593178fc98d2c1a9c6722df88b99c821ad6ae298eff0ba1ae71",
+ "sha256:4b9303507254ccb1181d1803a2080a798910ba89b1a3c9f53639885c90f7a756",
+ "sha256:4d355f2aee4a29063c10164b032d9fa8a82e2c30768737a2fd56d256146ad559",
+ "sha256:51e40123083d2f946794f9fe4adeeee2922b581fa3602128ce85ff813d85b81f",
+ "sha256:8713ddb888119b0d2a1462357d5946b8911be01ddbf31451e1d07eaa5077a261",
+ "sha256:8e924dbc025206e97756e8903039662aa58aa9ba357d8e1d8fc29e3092322053",
+ "sha256:8ecef21ac982aa78309bb6f092d1677812927e8b5ef204a10c326fc29f1367e2",
+ "sha256:8ecf9400d0893836ff41b6f977a33972145a855b6efeb605b49ee273c5e6469f",
+ "sha256:9367d00e14dee8d02134c6c9524bb4bd39d4c162456343d07191e2a0b5ec8b3b",
+ "sha256:a09fd9c1cca9a46b6ad4bea0a1f86ab1de3c0c932364dbcf9a6c2a5eeb44fa77",
+ "sha256:ab49edd5bea8d8b39a44b3db618e4783ef84c19c8b47286bf05dfdb3efb01c83",
+ "sha256:bea0b0468f89cdea625bb3f692cd7a4222d80a6bdafd6fb923963f2b9da0e15f",
+ "sha256:bec7568c6970b865f2bcebbe84d547c52bb2abadf74cefce396ba07571109c67",
+ "sha256:ce82cc06588e5cbc2a7df3c8a9c778f2cb722f56835a23a68b5a7264726bb00c",
+ "sha256:dea0ba7fe6f9461d244679efa968d215ea1f989b9c1957d7f10c21e5c7c09ad6"
+ ],
+ "version": "==3.0"
},
"dataclasses": {
"hashes": [
@@ -186,11 +186,11 @@
},
"fastapi": {
"hashes": [
- "sha256:1ee9a49f28d510b62b3b51a9452b274853bfc9c5d4b947ed054366e2d49f9efa",
- "sha256:72f40f47e5235cb5cbbad1d4f97932ede6059290c07e12e9784028dcd1063d28"
+ "sha256:96f964c3d9da8183f824857ad67c16c00ff3297e7bbca6748f60bd8485ded38c",
+ "sha256:9a4faa0e2b9c88a3772f7ce15eb4005bbdd27d1230ab4a0cd3517316175014a6"
],
"index": "pypi",
- "version": "==0.54.1"
+ "version": "==0.60.1"
},
"gunicorn": {
"hashes": [
@@ -209,48 +209,54 @@
},
"hiredis": {
"hashes": [
- "sha256:01b577f84c20ecc9c07fc4c184231b08e3c3942de096fa99978e053de231c423",
- "sha256:01ff0900134166961c9e339df77c33b72f7edc5cb41739f0babcd9faa345926e",
- "sha256:03ed34a13316d0c34213c4fd46e0fa3a5299073f4d4f08e93fed8c2108b399b3",
- "sha256:040436e91df5143aff9e0debb49530d0b17a6bd52200ce568621c31ef581b10d",
- "sha256:091eb38fbf968d1c5b703e412bbbd25f43a7967d8400842cee33a5a07b33c27b",
- "sha256:102f9b9dc6ed57feb3a7c9bdf7e71cb7c278fe8df1edfcfe896bc3e0c2be9447",
- "sha256:2b4b392c7e3082860c8371fab3ae762139090f9115819e12d9f56060f9ede05d",
- "sha256:2c9cc0b986397b833073f466e6b9e9c70d1d4dc2c2c1b3e9cae3a23102ff296c",
- "sha256:2fa65a9df683bca72073cd77709ddeb289ea2b114d3775d225fbbcc5faf808c5",
- "sha256:38437a681f17c975fd22349e72c29bc643f8e7eb2d6dc5df419eac59afa4d7ce",
- "sha256:3b3428fa3cf1ee178807b52c9bee8950ab94cd4eaa9bfae8c1bbae3c49501d34",
- "sha256:3dd8c2fae7f5494978facb0e93297dd627b1a3f536f3b070cf0a7d9157a07dcb",
- "sha256:4414a96c212e732723b5c3d7c04d386ebbb2ec359e1de646322cbc3f875cbd0d",
- "sha256:48c627581ad4ef60adbac980981407939acf13a0e18f093502c7b542223c4f19",
- "sha256:4a60e71625a2d78d8ab84dfb2fa2cfd9458c964b6e6c04fea76d9ade153fb371",
- "sha256:585ace09f434e43d8a8dbeb366865b1a044d7c06319b3c7372a0a00e63b860f4",
- "sha256:74b364b3f06c9cf0a53f7df611045bc9437ed972a283fa1f0b12537236d23ddc",
- "sha256:75c65c3850e89e9daa68d1b9bedd5806f177d60aa5a7b0953b4829481cfc1f72",
- "sha256:7f052de8bf744730a9120dbdc67bfeb7605a01f69fb8e7ba5c475af33c24e145",
- "sha256:8113a7d5e87ecf57cd4ae263cc9e429adb9a3e59f5a7768da5d3312a8d0a051a",
- "sha256:84857ce239eb8ed191ac78e77ff65d52902f00f30f4ee83bf80eb71da73b70e6",
- "sha256:8644a48ddc4a40b3e3a6b9443f396c2ee353afb2d45656c4fc68d04a82e8e3f7",
- "sha256:936aa565e673536e8a211e43ec43197406f24cd1f290138bd143765079c8ba00",
- "sha256:9afeb88c67bbc663b9f27385c496da056d06ad87f55df6e393e1516cfecb0461",
- "sha256:9d62cc7880110e4f83b0a51d218f465d3095e2751fbddd34e553dbd106a929ff",
- "sha256:a1fadd062fc8d647ff39220c57ea2b48c99bb73f18223828ec97f88fc27e7898",
- "sha256:a7754a783b1e5d6f627c19d099b178059c62f782ab62b4d8ba165b9fbc2ee34c",
- "sha256:aa59dd63bb3f736de4fc2d080114429d5d369dfb3265f771778e8349d67a97a4",
- "sha256:ae2ee0992f8de249715435942137843a93db204dd7db1e7cc9bdc5a8436443e8",
- "sha256:b36842d7cf32929d568f37ec5b3173b72b2ec6572dec4d6be6ce774762215aee",
- "sha256:bcbf9379c553b5facc6c04c1e5569b44b38ff16bcbf354676287698d61ee0c92",
- "sha256:cbccbda6f1c62ab460449d9c85fdf24d0d32a6bf45176581151e53cc26a5d910",
- "sha256:d0caf98dfb8af395d6732bd16561c0a2458851bea522e39f12f04802dbf6f502",
- "sha256:d6456afeddba036def1a36d8a2758eca53202308d83db20ab5d0b66590919627",
- "sha256:dbaef9a21a4f10bc281684ee4124f169e62bb533c2a92b55f8c06f64f9af7b8f",
- "sha256:dce84916c09aaece006272b37234ae84a8ed13abb3a4d341a23933b8701abfb5",
- "sha256:eb8c9c8b9869539d58d60ff4a28373a22514d40495911451343971cb4835b7a9",
- "sha256:efc98b14ee3a8595e40b1425e8d42f5fd26f11a7b215a81ef9259068931754f4",
- "sha256:fa2dc05b87d97acc1c6ae63f3e0f39eae5246565232484b08db6bf2dc1580678",
- "sha256:fe7d6ce9f6a5fbe24f09d95ea93e9c7271abc4e1565da511e1449b107b4d7848"
- ],
- "version": "==1.0.1"
+ "sha256:06a039208f83744a702279b894c8cf24c14fd63c59cd917dcde168b79eef0680",
+ "sha256:0a909bf501459062aa1552be1461456518f367379fdc9fdb1f2ca5e4a1fdd7c0",
+ "sha256:18402d9e54fb278cb9a8c638df6f1550aca36a009d47ecf5aa263a38600f35b0",
+ "sha256:1e4cbbc3858ec7e680006e5ca590d89a5e083235988f26a004acf7244389ac01",
+ "sha256:23344e3c2177baf6975fbfa361ed92eb7d36d08f454636e5054b3faa7c2aff8a",
+ "sha256:289b31885b4996ce04cadfd5fc03d034dce8e2a8234479f7c9e23b9e245db06b",
+ "sha256:2c1c570ae7bf1bab304f29427e2475fe1856814312c4a1cf1cd0ee133f07a3c6",
+ "sha256:2c227c0ed371771ffda256034427320870e8ea2e4fd0c0a618c766e7c49aad73",
+ "sha256:3bb9b63d319402cead8bbd9dd55dca3b667d2997e9a0d8a1f9b6cc274db4baee",
+ "sha256:3ef2183de67b59930d2db8b8e8d4d58e00a50fcc5e92f4f678f6eed7a1c72d55",
+ "sha256:43b8ed3dbfd9171e44c554cb4acf4ee4505caa84c5e341858b50ea27dd2b6e12",
+ "sha256:47bcf3c5e6c1e87ceb86cdda2ee983fa0fe56a999e6185099b3c93a223f2fa9b",
+ "sha256:5263db1e2e1e8ae30500cdd75a979ff99dcc184201e6b4b820d0de74834d2323",
+ "sha256:5b1451727f02e7acbdf6aae4e06d75f66ee82966ff9114550381c3271a90f56c",
+ "sha256:6996883a8a6ff9117cbb3d6f5b0dcbbae6fb9e31e1a3e4e2f95e0214d9a1c655",
+ "sha256:6c96f64a54f030366657a54bb90b3093afc9c16c8e0dfa29fc0d6dbe169103a5",
+ "sha256:7332d5c3e35154cd234fd79573736ddcf7a0ade7a986db35b6196b9171493e75",
+ "sha256:7885b6f32c4a898e825bb7f56f36a02781ac4a951c63e4169f0afcf9c8c30dfb",
+ "sha256:7b0f63f10a166583ab744a58baad04e0f52cfea1ac27bfa1b0c21a48d1003c23",
+ "sha256:819f95d4eba3f9e484dd115ab7ab72845cf766b84286a00d4ecf76d33f1edca1",
+ "sha256:8968eeaa4d37a38f8ca1f9dbe53526b69628edc9c42229a5b2f56d98bb828c1f",
+ "sha256:89ebf69cb19a33d625db72d2ac589d26e936b8f7628531269accf4a3196e7872",
+ "sha256:8daecd778c1da45b8bd54fd41ffcd471a86beed3d8e57a43acf7a8d63bba4058",
+ "sha256:955ba8ea73cf3ed8bd2f963b4cb9f8f0dcb27becd2f4b3dd536fd24c45533454",
+ "sha256:964f18a59f5a64c0170f684c417f4fe3e695a536612e13074c4dd5d1c6d7c882",
+ "sha256:969843fbdfbf56cdb71da6f0bdf50f9985b8b8aeb630102945306cf10a9c6af2",
+ "sha256:996021ef33e0f50b97ff2d6b5f422a0fe5577de21a8873b58a779a5ddd1c3132",
+ "sha256:9e9c9078a7ce07e6fce366bd818be89365a35d2e4b163268f0ca9ba7e13bb2f6",
+ "sha256:a04901757cb0fb0f5602ac11dda48f5510f94372144d06c2563ba56c480b467c",
+ "sha256:a7bf1492429f18d205f3a818da3ff1f242f60aa59006e53dee00b4ef592a3363",
+ "sha256:aa0af2deb166a5e26e0d554b824605e660039b161e37ed4f01b8d04beec184f3",
+ "sha256:abfb15a6a7822f0fae681785cb38860e7a2cb1616a708d53df557b3d76c5bfd4",
+ "sha256:b253fe4df2afea4dfa6b1fa8c5fef212aff8bcaaeb4207e81eed05cb5e4a7919",
+ "sha256:b27f082f47d23cffc4cf1388b84fdc45c4ef6015f906cd7e0d988d9e35d36349",
+ "sha256:b33aea449e7f46738811fbc6f0b3177c6777a572207412bbbf6f525ffed001ae",
+ "sha256:b44f9421c4505c548435244d74037618f452844c5d3c67719d8a55e2613549da",
+ "sha256:bcc371151d1512201d0214c36c0c150b1dc64f19c2b1a8c9cb1d7c7c15ebd93f",
+ "sha256:c2851deeabd96d3f6283e9c6b26e0bfed4de2dc6fb15edf913e78b79fc5909ed",
+ "sha256:cdfd501c7ac5b198c15df800a3a34c38345f5182e5f80770caf362bccca65628",
+ "sha256:d2c0caffa47606d6d7c8af94ba42547bd2a441f06c74fd90a1ffe328524a6c64",
+ "sha256:dcb2db95e629962db5a355047fb8aefb012df6c8ae608930d391619dbd96fd86",
+ "sha256:e0eeb9c112fec2031927a1745788a181d0eecbacbed941fc5c4f7bc3f7b273bf",
+ "sha256:e154891263306200260d7f3051982774d7b9ef35af3509d5adbbe539afd2610c",
+ "sha256:e2e023a42dcbab8ed31f97c2bcdb980b7fbe0ada34037d87ba9d799664b58ded",
+ "sha256:e64be68255234bb489a574c4f2f8df7029c98c81ec4d160d6cd836e7f0679390",
+ "sha256:e82d6b930e02e80e5109b678c663a9ed210680ded81c1abaf54635d88d1da298"
+ ],
+ "version": "==1.1.0"
},
"httptools": {
"hashes": [
@@ -272,10 +278,10 @@
},
"idna": {
"hashes": [
- "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb",
- "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa"
+ "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6",
+ "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"
],
- "version": "==2.9"
+ "version": "==2.10"
},
"idna-ssl": {
"hashes": [
@@ -287,41 +293,41 @@
},
"multidict": {
"hashes": [
- "sha256:317f96bc0950d249e96d8d29ab556d01dd38888fbe68324f46fd834b430169f1",
- "sha256:42f56542166040b4474c0c608ed051732033cd821126493cf25b6c276df7dd35",
- "sha256:4b7df040fb5fe826d689204f9b544af469593fb3ff3a069a6ad3409f742f5928",
- "sha256:544fae9261232a97102e27a926019100a9db75bec7b37feedd74b3aa82f29969",
- "sha256:620b37c3fea181dab09267cd5a84b0f23fa043beb8bc50d8474dd9694de1fa6e",
- "sha256:6e6fef114741c4d7ca46da8449038ec8b1e880bbe68674c01ceeb1ac8a648e78",
- "sha256:7774e9f6c9af3f12f296131453f7b81dabb7ebdb948483362f5afcaac8a826f1",
- "sha256:85cb26c38c96f76b7ff38b86c9d560dea10cf3459bb5f4caf72fc1bb932c7136",
- "sha256:a326f4240123a2ac66bb163eeba99578e9d63a8654a59f4688a79198f9aa10f8",
- "sha256:ae402f43604e3b2bc41e8ea8b8526c7fa7139ed76b0d64fc48e28125925275b2",
- "sha256:aee283c49601fa4c13adc64c09c978838a7e812f85377ae130a24d7198c0331e",
- "sha256:b51249fdd2923739cd3efc95a3d6c363b67bbf779208e9f37fd5e68540d1a4d4",
- "sha256:bb519becc46275c594410c6c28a8a0adc66fe24fef154a9addea54c1adb006f5",
- "sha256:c2c37185fb0af79d5c117b8d2764f4321eeb12ba8c141a95d0aa8c2c1d0a11dd",
- "sha256:dc561313279f9d05a3d0ffa89cd15ae477528ea37aa9795c4654588a3287a9ab",
- "sha256:e439c9a10a95cb32abd708bb8be83b2134fa93790a4fb0535ca36db3dda94d20",
- "sha256:fc3b4adc2ee8474cb3cd2a155305d5f8eda0a9c91320f83e55748e1fcb68f8e3"
- ],
- "version": "==4.7.5"
+ "sha256:1ece5a3369835c20ed57adadc663400b5525904e53bae59ec854a5d36b39b21a",
+ "sha256:275ca32383bc5d1894b6975bb4ca6a7ff16ab76fa622967625baeebcf8079000",
+ "sha256:3750f2205b800aac4bb03b5ae48025a64e474d2c6cc79547988ba1d4122a09e2",
+ "sha256:4538273208e7294b2659b1602490f4ed3ab1c8cf9dbdd817e0e9db8e64be2507",
+ "sha256:5141c13374e6b25fe6bf092052ab55c0c03d21bd66c94a0e3ae371d3e4d865a5",
+ "sha256:51a4d210404ac61d32dada00a50ea7ba412e6ea945bbe992e4d7a595276d2ec7",
+ "sha256:5cf311a0f5ef80fe73e4f4c0f0998ec08f954a6ec72b746f3c179e37de1d210d",
+ "sha256:6513728873f4326999429a8b00fc7ceddb2509b01d5fd3f3be7881a257b8d463",
+ "sha256:7388d2ef3c55a8ba80da62ecfafa06a1c097c18032a501ffd4cabbc52d7f2b19",
+ "sha256:9456e90649005ad40558f4cf51dbb842e32807df75146c6d940b6f5abb4a78f3",
+ "sha256:c026fe9a05130e44157b98fea3ab12969e5b60691a276150db9eda71710cd10b",
+ "sha256:d14842362ed4cf63751648e7672f7174c9818459d169231d03c56e84daf90b7c",
+ "sha256:e0d072ae0f2a179c375f67e3da300b47e1a83293c554450b29c900e50afaae87",
+ "sha256:f07acae137b71af3bb548bd8da720956a3bc9f9a0b87733e0899226a2317aeb7",
+ "sha256:fbb77a75e529021e7c4a8d4e823d88ef4d23674a202be4f5addffc72cbb91430",
+ "sha256:fcfbb44c59af3f8ea984de67ec7c306f618a3ec771c2843804069917a8f2e255",
+ "sha256:feed85993dbdb1dbc29102f50bca65bdc68f2c0c8d352468c25b54874f23c39d"
+ ],
+ "version": "==4.7.6"
},
"psutil": {
"hashes": [
- "sha256:1413f4158eb50e110777c4f15d7c759521703bd6beb58926f1d562da40180058",
- "sha256:298af2f14b635c3c7118fd9183843f4e73e681bb6f01e12284d4d70d48a60953",
- "sha256:60b86f327c198561f101a92be1995f9ae0399736b6eced8f24af41ec64fb88d4",
- "sha256:685ec16ca14d079455892f25bd124df26ff9137664af445563c1bd36629b5e0e",
- "sha256:73f35ab66c6c7a9ce82ba44b1e9b1050be2a80cd4dcc3352cc108656b115c74f",
- "sha256:75e22717d4dbc7ca529ec5063000b2b294fc9a367f9c9ede1f65846c7955fd38",
- "sha256:a02f4ac50d4a23253b68233b07e7cdb567bd025b982d5cf0ee78296990c22d9e",
- "sha256:d008ddc00c6906ec80040d26dc2d3e3962109e40ad07fd8a12d0284ce5e0e4f8",
- "sha256:d84029b190c8a66a946e28b4d3934d2ca1528ec94764b180f7d6ea57b0e75e26",
- "sha256:e2d0c5b07c6fe5a87fa27b7855017edb0d52ee73b71e6ee368fae268605cc3f5",
- "sha256:f344ca230dd8e8d5eee16827596f1c22ec0876127c28e800d7ae20ed44c4b310"
+ "sha256:0ee3c36428f160d2d8fce3c583a0353e848abb7de9732c50cf3356dd49ad63f8",
+ "sha256:10512b46c95b02842c225f58fa00385c08fa00c68bac7da2d9a58ebe2c517498",
+ "sha256:4080869ed93cce662905b029a1770fe89c98787e543fa7347f075ade761b19d6",
+ "sha256:5e9d0f26d4194479a13d5f4b3798260c20cecf9ac9a461e718eb59ea520a360c",
+ "sha256:66c18ca7680a31bf16ee22b1d21b6397869dda8059dbdb57d9f27efa6615f195",
+ "sha256:68d36986ded5dac7c2dcd42f2682af1db80d4bce3faa126a6145c1637e1b559f",
+ "sha256:90990af1c3c67195c44c9a889184f84f5b2320dce3ee3acbd054e3ba0b4a7beb",
+ "sha256:a5b120bb3c0c71dfe27551f9da2f3209a8257a178ed6c628a819037a8df487f1",
+ "sha256:d8a82162f23c53b8525cf5f14a355f5d1eea86fa8edde27287dd3a98399e4fdf",
+ "sha256:f2018461733b23f308c298653c8903d32aaad7873d25e1d228765e91ae42c3f2",
+ "sha256:ff1977ba1a5f71f89166d5145c3da1cea89a0fdb044075a12c720ee9123ec818"
],
- "version": "==5.7.0"
+ "version": "==5.7.2"
},
"pycparser": {
"hashes": [
@@ -335,26 +341,26 @@
"dotenv"
],
"hashes": [
- "sha256:0a1cdf24e567d42dc762d3fed399bd211a13db2e8462af9dfa93b34c41648efb",
- "sha256:2007eb062ed0e57875ce8ead12760a6e44bf5836e6a1a7ea81d71eeecf3ede0f",
- "sha256:20a15a303ce1e4d831b4e79c17a4a29cb6740b12524f5bba3ea363bff65732bc",
- "sha256:2a6904e9f18dea58f76f16b95cba6a2f20b72d787abd84ecd67ebc526e61dce6",
- "sha256:3714a4056f5bdbecf3a41e0706ec9b228c9513eee2ad884dc2c568c4dfa540e9",
- "sha256:473101121b1bd454c8effc9fe66d54812fdc128184d9015c5aaa0d4e58a6d338",
- "sha256:68dece67bff2b3a5cc188258e46b49f676a722304f1c6148ae08e9291e284d98",
- "sha256:70f27d2f0268f490fe3de0a9b6fca7b7492b8fd6623f9fecd25b221ebee385e3",
- "sha256:8433dbb87246c0f562af75d00fa80155b74e4f6924b0db6a2078a3cd2f11c6c4",
- "sha256:8be325fc9da897029ee48d1b5e40df817d97fe969f3ac3fd2434ba7e198c55d5",
- "sha256:93b9f265329d9827f39f0fca68f5d72cc8321881cdc519a1304fa73b9f8a75bd",
- "sha256:9be755919258d5d168aeffbe913ed6e8bd562e018df7724b68cabdee3371e331",
- "sha256:ab863853cb502480b118187d670f753be65ec144e1654924bec33d63bc8b3ce2",
- "sha256:b96ce81c4b5ca62ab81181212edfd057beaa41411cd9700fbcb48a6ba6564b4e",
- "sha256:da8099fca5ee339d5572cfa8af12cf0856ae993406f0b1eb9bb38c8a660e7416",
- "sha256:e2c753d355126ddd1eefeb167fa61c7037ecd30b98e7ebecdc0d1da463b4ea09",
- "sha256:f0018613c7a0d19df3240c2a913849786f21b6539b9f23d85ce4067489dfacfa"
+ "sha256:1783c1d927f9e1366e0e0609ae324039b2479a1a282a98ed6a6836c9ed02002c",
+ "sha256:2dc946b07cf24bee4737ced0ae77e2ea6bc97489ba5a035b603bd1b40ad81f7e",
+ "sha256:2de562a456c4ecdc80cf1a8c3e70c666625f7d02d89a6174ecf63754c734592e",
+ "sha256:36dbf6f1be212ab37b5fda07667461a9219c956181aa5570a00edfb0acdfe4a1",
+ "sha256:3fa799f3cfff3e5f536cbd389368fc96a44bb30308f258c94ee76b73bd60531d",
+ "sha256:40d765fa2d31d5be8e29c1794657ad46f5ee583a565c83cea56630d3ae5878b9",
+ "sha256:418b84654b60e44c0cdd5384294b0e4bc1ebf42d6e873819424f3b78b8690614",
+ "sha256:4900b8820b687c9a3ed753684337979574df20e6ebe4227381d04b3c3c628f99",
+ "sha256:530d7222a2786a97bc59ee0e0ebbe23728f82974b1f1ad9a11cd966143410633",
+ "sha256:54122a8ed6b75fe1dd80797f8251ad2063ea348a03b77218d73ea9fe19bd4e73",
+ "sha256:6c3f162ba175678218629f446a947e3356415b6b09122dcb364e58c442c645a7",
+ "sha256:b49c86aecde15cde33835d5d6360e55f5e0067bb7143a8303bf03b872935c75b",
+ "sha256:b5b3489cb303d0f41ad4a7390cf606a5f2c7a94dcba20c051cd1c653694cb14d",
+ "sha256:cf3933c98cb5e808b62fae509f74f209730b180b1e3c3954ee3f7949e083a7df",
+ "sha256:eb75dc1809875d5738df14b6566ccf9fd9c0bcde4f36b72870f318f16b9f5c20",
+ "sha256:f769141ab0abfadf3305d4fcf36660e5cf568a666dd3efab7c3d4782f70946b1",
+ "sha256:f8af9b840a9074e08c0e6dc93101de84ba95df89b267bf7151d74c553d66833b"
],
"index": "pypi",
- "version": "==1.5.1"
+ "version": "==1.6.1"
},
"pyopenssl": {
"hashes": [
@@ -373,84 +379,92 @@
},
"python-dotenv": {
"hashes": [
- "sha256:25c0ff1a3e12f4bde8d592cc254ab075cfe734fc5dd989036716fd17ee7e5ec7",
- "sha256:3b9909bc96b0edc6b01586e1eed05e71174ef4e04c71da5786370cebea53ad74"
+ "sha256:8c10c99a1b25d9a68058a1ad6f90381a62ba68230ca93966882a4dbc3bc9c33d",
+ "sha256:c10863aee750ad720f4f43436565e4c1698798d763b63234fb5021b6c616e423"
],
- "version": "==0.13.0"
+ "version": "==0.14.0"
},
"requests": {
"hashes": [
- "sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee",
- "sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6"
+ "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b",
+ "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898"
],
"index": "pypi",
- "version": "==2.23.0"
+ "version": "==2.24.0"
},
"scout-apm": {
"hashes": [
- "sha256:0c1610f4ab58fc79acfea6e63a5d6769779695f9075ce80c6c1da1042c3f2fae",
- "sha256:1290caa22eb307e9061466305deaccd7c8b3b9054ee32c8e4338e395ab346ce9",
- "sha256:17e3c5f28809ec460f8bba1c40413345a8604d772dad5839e8ada15da3db2e25",
- "sha256:1b16d9f46f10b425cac742db26e8e2157c1bfc314c81f772e94c808b685a52da",
- "sha256:28ff9a628368bc00f271c1c25f99c8b62b7b4c030f43a681a6a68612d6fd7434",
- "sha256:554faa7c655d0c2c847a8601078b4e6787bb27addc6404bd0a83ef915580fbab",
- "sha256:64f9f51c9f937030c84207e19485558c2df3ffbe9774ec06e14ae4e6ec18a2ea",
- "sha256:6b02a3a0000ed2f584c69e26391372910b93a78b0b9b99beb74dc0e42e944b31",
- "sha256:72addd7a1be4a5630eb703e68a85f6d11216dfb8da4642e68d05737dc8e53384",
- "sha256:8d30961b1a317fd5a357046bc9e6fdb170cd052aea8fafaaf3180423ae2bc8fd",
- "sha256:9e93deab879fdce257296fba427c36b4e2840c1fc529e640faa19d9fb8a26c30",
- "sha256:ab7eb611fa833e82206cb8c23eaf46466b0f29982f708b0d23721e51b133b7d4",
- "sha256:c27fab283f55a66f00aafb4d1974d77b4e5d0edbea5c7e70d51bd018aadae8da",
- "sha256:cdea8a54a4a8000559fc8abc25c78bc3209eb5fec44eeef73652d22625117522",
- "sha256:d28f9261852511b67235014631f99bef220eb94c72a4d5497bcc858b04e94728",
- "sha256:dfa2c75f3ecaa512aa4dd56b8aa6c60a1ebd31f578fc825e7d4b5e4d182d0b40",
- "sha256:e1daac680081af6653bbc6fdc16ad8fac0bbe8ead834c023df2e291887fbd307",
- "sha256:ebd23100982c6c346d1213ffd45c190e99219a3fc5511d353631fa3d34bb121e",
- "sha256:f9f7dee5dcd63b7e5e21b86b048ab10c95ce5c3512206d807b8ae47c59ca2d24"
+ "sha256:1b8d01ec9ee0e80617698b7fccbfcc12f207ec1287a325e2bcf520a784e8b582",
+ "sha256:292b37c1c855bb78bcd4322320d704a1c4ec88dd1deb8089c59af3ddc638167b",
+ "sha256:3209b0362212693daa95abc03d92e5c2dd4eae90f2d20d17cfe56e8d9f997d50",
+ "sha256:34044653f7239f81f4a4282709d32630e82ba6e8cd0d343951a7a1f98f9cb53d",
+ "sha256:3cb11a32a3f395649af44c6e9d71c0f961652a8b291f8ae3b8bd701bfc6baaaa",
+ "sha256:54bb9fc339b39f3320521b7b8e988315b9252afd2252065de88a36802f21421c",
+ "sha256:5db32c5c61e9c916d5284157c3161c464358907ace50f2122af59bc3a02f79e9",
+ "sha256:6a5b9ea2fb1414cb69ee06d4ede9bcfe6e45bddbffc9a5b8ae50f74c3861ee09",
+ "sha256:79bb227f4c9268b3441d7f5a2a86d3378c3877df8dab9bb833711bd38a818151",
+ "sha256:7b9125ee5ed4be19b20d2669d27d80a4fe1a4c461e9b0873f3e04c96889853e8",
+ "sha256:afae9c349642b8f86eb28722a1fcc24ea0c5d8c980b9ca9f253cfcc8976025a4",
+ "sha256:bac108329a806a1de4786f7f2eb43ae5646d20813429b76db31a41ae92670c31",
+ "sha256:bc6ed26a855ada1a32c15aba98518400954f0ce0920a5017a76f2431de8d9093",
+ "sha256:d1d2e1b0e51f3a337c3c953c4e7fc1fc1ae9d391010bd90a2a8bedd5e58d63d9",
+ "sha256:d77f2aeb7ba04c5c3e1687c1b29b1a7e17471c817490074e0e9319e43f409664",
+ "sha256:ebdf82c1048c705cc79181c270e5816e4ddebcad512e312e2c86fdea803904ef",
+ "sha256:f09c4046a199002296d932a903a693c67f8f76e483b29ad584e2649eea474426",
+ "sha256:f8108ea738e69ee5ab2ee0b025fb601a7308b8c8e586b9e1bfb44491a018085f",
+ "sha256:ff6879c247ff073fd75d3f621509262440105bb786cddd0935987a42e78db8b0"
],
"index": "pypi",
- "version": "==2.14.1"
+ "version": "==2.15.2"
},
"sentry-sdk": {
"hashes": [
- "sha256:23808d571d2461a4ce3784ec12bbee5bdb8c026c143fe79d36cef8a6d653e71f",
- "sha256:bb90a4e19c7233a580715fc986cc44be2c48fc10b31e71580a2037e1c94b6950"
+ "sha256:2de15b13836fa3522815a933bd9c887c77f4868071043349f94f1b896c1bcfb8",
+ "sha256:38bb09d0277117f76507c8728d9a5156f09a47ac5175bb8072513859d19a593b"
],
"index": "pypi",
- "version": "==0.14.3"
+ "version": "==0.16.2"
},
"six": {
"hashes": [
- "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a",
- "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"
+ "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
+ "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
],
- "version": "==1.14.0"
+ "version": "==1.15.0"
},
"starlette": {
"hashes": [
- "sha256:6169ee78ded501095d1dda7b141a1dc9f9934d37ad23196e180150ace2c6449b",
- "sha256:a9bb130fa7aa736eda8a814b6ceb85ccf7a209ed53843d0d61e246b380afa10f"
+ "sha256:bd2ffe5e37fb75d014728511f8e68ebf2c80b0fa3d04ca1479f4dc752ae31ac9",
+ "sha256:ebe8ee08d9be96a3c9f31b2cb2a24dbdf845247b745664bd8a3f9bd0c977fdbc"
+ ],
+ "version": "==0.13.6"
+ },
+ "typing-extensions": {
+ "hashes": [
+ "sha256:6e95524d8a547a91e08f404ae485bbb71962de46967e1b71a0cb89af24e761c5",
+ "sha256:79ee589a3caca649a9bfd2a8de4709837400dfa00b6cc81962a1e6a1815969ae",
+ "sha256:f8d2bd89d25bc39dabe7d23df520442fa1d8969b82544370e03d88b5a591c392"
],
- "version": "==0.13.2"
+ "version": "==3.7.4.2"
},
"urllib3": {
"extras": [
"secure"
],
"hashes": [
- "sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527",
- "sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
+ "sha256:91056c15fa70756691db97756772bb1eb9678fa585d9184f24534b100dc60f4a",
+ "sha256:e7983572181f5e1522d9c98453462384ee92a0be7fac5f1413a1e35c56cc0461"
],
"markers": "python_version >= '3.5'",
- "version": "==1.25.9"
+ "version": "==1.25.10"
},
"uvicorn": {
"hashes": [
- "sha256:50577d599775dac2301bac8bd5b540d19a9560144143c5bdab13cba92783b6e7",
- "sha256:596eaa8645b6dbc24d6610e335f8ddf5f925b4c4b86fdc7146abb0bf0da65d17"
+ "sha256:1d46a22cc55a52f5567e0c66f000ae56f26263e44cef59b7c885bf10f487ce6e",
+ "sha256:b50f7f4c0c499c9b8d0280924cfbd24b90ba02456e3dc80934b9a786a291f09f"
],
"index": "pypi",
- "version": "==0.11.5"
+ "version": "==0.11.7"
},
"uvloop": {
"hashes": [
@@ -502,41 +516,41 @@
},
"yarl": {
"hashes": [
- "sha256:0c2ab325d33f1b824734b3ef51d4d54a54e0e7a23d13b86974507602334c2cce",
- "sha256:0ca2f395591bbd85ddd50a82eb1fde9c1066fafe888c5c7cc1d810cf03fd3cc6",
- "sha256:2098a4b4b9d75ee352807a95cdf5f10180db903bc5b7270715c6bbe2551f64ce",
- "sha256:25e66e5e2007c7a39541ca13b559cd8ebc2ad8fe00ea94a2aad28a9b1e44e5ae",
- "sha256:26d7c90cb04dee1665282a5d1a998defc1a9e012fdca0f33396f81508f49696d",
- "sha256:308b98b0c8cd1dfef1a0311dc5e38ae8f9b58349226aa0533f15a16717ad702f",
- "sha256:3ce3d4f7c6b69c4e4f0704b32eca8123b9c58ae91af740481aa57d7857b5e41b",
- "sha256:58cd9c469eced558cd81aa3f484b2924e8897049e06889e8ff2510435b7ef74b",
- "sha256:5b10eb0e7f044cf0b035112446b26a3a2946bca9d7d7edb5e54a2ad2f6652abb",
- "sha256:6faa19d3824c21bcbfdfce5171e193c8b4ddafdf0ac3f129ccf0cdfcb083e462",
- "sha256:944494be42fa630134bf907714d40207e646fd5a94423c90d5b514f7b0713fea",
- "sha256:a161de7e50224e8e3de6e184707476b5a989037dcb24292b391a3d66ff158e70",
- "sha256:a4844ebb2be14768f7994f2017f70aca39d658a96c786211be5ddbe1c68794c1",
- "sha256:c2b509ac3d4b988ae8769901c66345425e361d518aecbe4acbfc2567e416626a",
- "sha256:c9959d49a77b0e07559e579f38b2f3711c2b8716b8410b320bf9713013215a1b",
- "sha256:d8cdee92bc930d8b09d8bd2043cedd544d9c8bd7436a77678dd602467a993080",
- "sha256:e15199cdb423316e15f108f51249e44eb156ae5dba232cb73be555324a1d49c2"
- ],
- "version": "==1.4.2"
+ "sha256:1707230e1ea48ea06a3e20acb4ce05a38d2465bd9566c21f48f6212a88e47536",
+ "sha256:1f269e8e6676193a94635399a77c9059e1826fb6265c9204c9e5a8ccd36006e1",
+ "sha256:2657716c1fc998f5f2675c0ee6ce91282e0da0ea9e4a94b584bb1917e11c1559",
+ "sha256:431faa6858f0ea323714d8b7b4a7da1db2eeb9403607f0eaa3800ab2c5a4b627",
+ "sha256:5bbcb195da7de57f4508b7508c33f7593e9516e27732d08b9aad8586c7b8c384",
+ "sha256:5c82f5b1499342339f22c83b97dbe2b8a09e47163fab86cd934a8dd46620e0fb",
+ "sha256:5d410f69b4f92c5e1e2a8ffb73337cd8a274388c6975091735795588a538e605",
+ "sha256:66b4f345e9573e004b1af184bc00431145cf5e089a4dcc1351505c1f5750192c",
+ "sha256:875b2a741ce0208f3b818008a859ab5d0f461e98a32bbdc6af82231a9e761c55",
+ "sha256:9a3266b047d15e78bba38c8455bf68b391c040231ca5965ef867f7cbbc60bde5",
+ "sha256:9a592c4aa642249e9bdaf76897d90feeb08118626b363a6be8788a9b300274b5",
+ "sha256:a1772068401d425e803999dada29a6babf041786e08be5e79ef63c9ecc4c9575",
+ "sha256:b065a5c3e050395ae563019253cc6c769a50fd82d7fa92d07476273521d56b7c",
+ "sha256:b325fefd574ebef50e391a1072d1712a60348ca29c183e1d546c9d87fec2cd32",
+ "sha256:cf5eb664910d759bbae0b76d060d6e21f8af5098242d66c448bbebaf2a7bfa70",
+ "sha256:f058b6541477022c7b54db37229f87dacf3b565de4f901ff5a0a78556a174fea",
+ "sha256:f5cfed0766837303f688196aa7002730d62c5cc802d98c6395ea1feb87252727"
+ ],
+ "version": "==1.5.0"
}
},
"develop": {
"appdirs": {
"hashes": [
- "sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92",
- "sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e"
+ "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41",
+ "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"
],
- "version": "==1.4.3"
+ "version": "==1.4.4"
},
"astroid": {
"hashes": [
- "sha256:4c17cea3e592c21b6e222f673868961bad77e1f985cb1694ed077475a89229c1",
- "sha256:d8506842a3faf734b81599c8b98dcc423de863adcc1999248480b18bd31a0f38"
+ "sha256:2f4078c2a41bf377eea06d71c9d2ba4eb8f6b1af2135bec27bbbb7d8f12bb703",
+ "sha256:bc58d83eb610252fd8de6363e39d4f1d0619c894b0ed24603b881c02e64c7386"
],
- "version": "==2.4.1"
+ "version": "==2.4.2"
},
"async-asgi-testclient": {
"hashes": [
@@ -586,10 +600,10 @@
},
"certifi": {
"hashes": [
- "sha256:1d987a998c75633c40847cc966fcf5904906c920a7f17ef374f5aa4282abd304",
- "sha256:51fcb31174be6e6664c5f69e3e1691a2d72a1a12e90f872cbdb1567eb47b6519"
+ "sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3",
+ "sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41"
],
- "version": "==2020.4.5.1"
+ "version": "==2020.6.20"
},
"chardet": {
"hashes": [
@@ -607,47 +621,50 @@
},
"coverage": {
"hashes": [
- "sha256:00f1d23f4336efc3b311ed0d807feb45098fc86dee1ca13b3d6768cdab187c8a",
- "sha256:01333e1bd22c59713ba8a79f088b3955946e293114479bbfc2e37d522be03355",
- "sha256:0cb4be7e784dcdc050fc58ef05b71aa8e89b7e6636b99967fadbdba694cf2b65",
- "sha256:0e61d9803d5851849c24f78227939c701ced6704f337cad0a91e0972c51c1ee7",
- "sha256:1601e480b9b99697a570cea7ef749e88123c04b92d84cedaa01e117436b4a0a9",
- "sha256:2742c7515b9eb368718cd091bad1a1b44135cc72468c731302b3d641895b83d1",
- "sha256:2d27a3f742c98e5c6b461ee6ef7287400a1956c11421eb574d843d9ec1f772f0",
- "sha256:402e1744733df483b93abbf209283898e9f0d67470707e3c7516d84f48524f55",
- "sha256:5c542d1e62eece33c306d66fe0a5c4f7f7b3c08fecc46ead86d7916684b36d6c",
- "sha256:5f2294dbf7875b991c381e3d5af2bcc3494d836affa52b809c91697449d0eda6",
- "sha256:6402bd2fdedabbdb63a316308142597534ea8e1895f4e7d8bf7476c5e8751fef",
- "sha256:66460ab1599d3cf894bb6baee8c684788819b71a5dc1e8fa2ecc152e5d752019",
- "sha256:782caea581a6e9ff75eccda79287daefd1d2631cc09d642b6ee2d6da21fc0a4e",
- "sha256:79a3cfd6346ce6c13145731d39db47b7a7b859c0272f02cdb89a3bdcbae233a0",
- "sha256:7a5bdad4edec57b5fb8dae7d3ee58622d626fd3a0be0dfceda162a7035885ecf",
- "sha256:8fa0cbc7ecad630e5b0f4f35b0f6ad419246b02bc750de7ac66db92667996d24",
- "sha256:a027ef0492ede1e03a8054e3c37b8def89a1e3c471482e9f046906ba4f2aafd2",
- "sha256:a3f3654d5734a3ece152636aad89f58afc9213c6520062db3978239db122f03c",
- "sha256:a82b92b04a23d3c8a581fc049228bafde988abacba397d57ce95fe95e0338ab4",
- "sha256:acf3763ed01af8410fc36afea23707d4ea58ba7e86a8ee915dfb9ceff9ef69d0",
- "sha256:adeb4c5b608574a3d647011af36f7586811a2c1197c861aedb548dd2453b41cd",
- "sha256:b83835506dfc185a319031cf853fa4bb1b3974b1f913f5bb1a0f3d98bdcded04",
- "sha256:bb28a7245de68bf29f6fb199545d072d1036a1917dca17a1e75bbb919e14ee8e",
- "sha256:bf9cb9a9fd8891e7efd2d44deb24b86d647394b9705b744ff6f8261e6f29a730",
- "sha256:c317eaf5ff46a34305b202e73404f55f7389ef834b8dbf4da09b9b9b37f76dd2",
- "sha256:dbe8c6ae7534b5b024296464f387d57c13caa942f6d8e6e0346f27e509f0f768",
- "sha256:de807ae933cfb7f0c7d9d981a053772452217df2bf38e7e6267c9cbf9545a796",
- "sha256:dead2ddede4c7ba6cb3a721870f5141c97dc7d85a079edb4bd8d88c3ad5b20c7",
- "sha256:dec5202bfe6f672d4511086e125db035a52b00f1648d6407cc8e526912c0353a",
- "sha256:e1ea316102ea1e1770724db01998d1603ed921c54a86a2efcb03428d5417e489",
- "sha256:f90bfc4ad18450c80b024036eaf91e4a246ae287701aaa88eaebebf150868052"
- ],
- "version": "==5.1"
+ "sha256:098a703d913be6fbd146a8c50cc76513d726b022d170e5e98dc56d958fd592fb",
+ "sha256:16042dc7f8e632e0dcd5206a5095ebd18cb1d005f4c89694f7f8aafd96dd43a3",
+ "sha256:1adb6be0dcef0cf9434619d3b892772fdb48e793300f9d762e480e043bd8e716",
+ "sha256:27ca5a2bc04d68f0776f2cdcb8bbd508bbe430a7bf9c02315cd05fb1d86d0034",
+ "sha256:28f42dc5172ebdc32622a2c3f7ead1b836cdbf253569ae5673f499e35db0bac3",
+ "sha256:2fcc8b58953d74d199a1a4d633df8146f0ac36c4e720b4a1997e9b6327af43a8",
+ "sha256:304fbe451698373dc6653772c72c5d5e883a4aadaf20343592a7abb2e643dae0",
+ "sha256:30bc103587e0d3df9e52cd9da1dd915265a22fad0b72afe54daf840c984b564f",
+ "sha256:40f70f81be4d34f8d491e55936904db5c527b0711b2a46513641a5729783c2e4",
+ "sha256:4186fc95c9febeab5681bc3248553d5ec8c2999b8424d4fc3a39c9cba5796962",
+ "sha256:46794c815e56f1431c66d81943fa90721bb858375fb36e5903697d5eef88627d",
+ "sha256:4869ab1c1ed33953bb2433ce7b894a28d724b7aa76c19b11e2878034a4e4680b",
+ "sha256:4f6428b55d2916a69f8d6453e48a505c07b2245653b0aa9f0dee38785939f5e4",
+ "sha256:52f185ffd3291196dc1aae506b42e178a592b0b60a8610b108e6ad892cfc1bb3",
+ "sha256:538f2fd5eb64366f37c97fdb3077d665fa946d2b6d95447622292f38407f9258",
+ "sha256:64c4f340338c68c463f1b56e3f2f0423f7b17ba6c3febae80b81f0e093077f59",
+ "sha256:675192fca634f0df69af3493a48224f211f8db4e84452b08d5fcebb9167adb01",
+ "sha256:700997b77cfab016533b3e7dbc03b71d33ee4df1d79f2463a318ca0263fc29dd",
+ "sha256:8505e614c983834239f865da2dd336dcf9d72776b951d5dfa5ac36b987726e1b",
+ "sha256:962c44070c281d86398aeb8f64e1bf37816a4dfc6f4c0f114756b14fc575621d",
+ "sha256:9e536783a5acee79a9b308be97d3952b662748c4037b6a24cbb339dc7ed8eb89",
+ "sha256:9ea749fd447ce7fb1ac71f7616371f04054d969d412d37611716721931e36efd",
+ "sha256:a34cb28e0747ea15e82d13e14de606747e9e484fb28d63c999483f5d5188e89b",
+ "sha256:a3ee9c793ffefe2944d3a2bd928a0e436cd0ac2d9e3723152d6fd5398838ce7d",
+ "sha256:aab75d99f3f2874733946a7648ce87a50019eb90baef931698f96b76b6769a46",
+ "sha256:b1ed2bdb27b4c9fc87058a1cb751c4df8752002143ed393899edb82b131e0546",
+ "sha256:b360d8fd88d2bad01cb953d81fd2edd4be539df7bfec41e8753fe9f4456a5082",
+ "sha256:b8f58c7db64d8f27078cbf2a4391af6aa4e4767cc08b37555c4ae064b8558d9b",
+ "sha256:c1bbb628ed5192124889b51204de27c575b3ffc05a5a91307e7640eff1d48da4",
+ "sha256:c2ff24df02a125b7b346c4c9078c8936da06964cc2d276292c357d64378158f8",
+ "sha256:c890728a93fffd0407d7d37c1e6083ff3f9f211c83b4316fae3778417eab9811",
+ "sha256:c96472b8ca5dc135fb0aa62f79b033f02aa434fb03a8b190600a5ae4102df1fd",
+ "sha256:ce7866f29d3025b5b34c2e944e66ebef0d92e4a4f2463f7266daa03a1332a651",
+ "sha256:e26c993bd4b220429d4ec8c1468eca445a4064a61c74ca08da7429af9bc53bb0"
+ ],
+ "version": "==5.2.1"
},
"coveralls": {
"hashes": [
- "sha256:41bd57b60321dfd5b56e990ab3f7ed876090691c21a9e3b005e1f6e42e6ba4b9",
- "sha256:d213f5edd49053d03f0db316ccabfe17725f2758147afc9a37eaca9d8e8602b5"
+ "sha256:3726d35c0f93a28631a003880e2aa6cc93c401d62bc6919c5cb497217ba30c55",
+ "sha256:afe359cd5b350e1b3895372bda32af8f0260638c7c4a31a5c0f15aa6a96f40d9"
],
"index": "pypi",
- "version": "==2.0.0"
+ "version": "==2.1.1"
},
"docopt": {
"hashes": [
@@ -664,26 +681,26 @@
},
"gitpython": {
"hashes": [
- "sha256:864a47472548f3ba716ca202e034c1900f197c0fb3a08f641c20c3cafd15ed94",
- "sha256:da3b2cf819974789da34f95ac218ef99f515a928685db141327c09b73dd69c09"
+ "sha256:2db287d71a284e22e5c2846042d0602465c7434d910406990d5b74df4afb0858",
+ "sha256:fa3b92da728a457dd75d62bb5f3eb2816d99a7fe6c67398e260637a40e3fafb5"
],
- "version": "==3.1.2"
+ "version": "==3.1.7"
},
"idna": {
"hashes": [
- "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb",
- "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa"
+ "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6",
+ "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"
],
- "version": "==2.9"
+ "version": "==2.10"
},
"importlib-metadata": {
"hashes": [
- "sha256:2a688cbaa90e0cc587f1df48bdc97a6eadccdcd9c35fb3f976a09e3b5016d90f",
- "sha256:34513a8a0c4962bc66d35b359558fd8a5e10cd472d37aec5f66858addef32c1e"
+ "sha256:90bb658cdbbf6d1735b6341ce708fc7024a3e14e99ffdc5783edea9f9b077f83",
+ "sha256:dc15b2969b4ce36305c51eebe62d418ac7791e9a157911d58bfb1f9ccd8e2070"
],
"index": "pypi",
"markers": "python_version < '3.8'",
- "version": "==1.6.0"
+ "version": "==1.7.0"
},
"invoke": {
"hashes": [
@@ -744,39 +761,39 @@
},
"more-itertools": {
"hashes": [
- "sha256:5dd8bcf33e5f9513ffa06d5ad33d78f31e1931ac9a18f33d37e77a180d393a7c",
- "sha256:b1ddb932186d8a6ac451e1d95844b382f55e12686d51ca0c68b6f61f2ab7a507"
+ "sha256:68c70cc7167bdf5c7c9d8f6954a7837089c6a36bf565383919bb595efb8a17e5",
+ "sha256:b78134b2063dd214000685165d81c154522c3ee0a1c0d4d113c80361c234c5a2"
],
- "version": "==8.2.0"
+ "version": "==8.4.0"
},
"multidict": {
"hashes": [
- "sha256:317f96bc0950d249e96d8d29ab556d01dd38888fbe68324f46fd834b430169f1",
- "sha256:42f56542166040b4474c0c608ed051732033cd821126493cf25b6c276df7dd35",
- "sha256:4b7df040fb5fe826d689204f9b544af469593fb3ff3a069a6ad3409f742f5928",
- "sha256:544fae9261232a97102e27a926019100a9db75bec7b37feedd74b3aa82f29969",
- "sha256:620b37c3fea181dab09267cd5a84b0f23fa043beb8bc50d8474dd9694de1fa6e",
- "sha256:6e6fef114741c4d7ca46da8449038ec8b1e880bbe68674c01ceeb1ac8a648e78",
- "sha256:7774e9f6c9af3f12f296131453f7b81dabb7ebdb948483362f5afcaac8a826f1",
- "sha256:85cb26c38c96f76b7ff38b86c9d560dea10cf3459bb5f4caf72fc1bb932c7136",
- "sha256:a326f4240123a2ac66bb163eeba99578e9d63a8654a59f4688a79198f9aa10f8",
- "sha256:ae402f43604e3b2bc41e8ea8b8526c7fa7139ed76b0d64fc48e28125925275b2",
- "sha256:aee283c49601fa4c13adc64c09c978838a7e812f85377ae130a24d7198c0331e",
- "sha256:b51249fdd2923739cd3efc95a3d6c363b67bbf779208e9f37fd5e68540d1a4d4",
- "sha256:bb519becc46275c594410c6c28a8a0adc66fe24fef154a9addea54c1adb006f5",
- "sha256:c2c37185fb0af79d5c117b8d2764f4321eeb12ba8c141a95d0aa8c2c1d0a11dd",
- "sha256:dc561313279f9d05a3d0ffa89cd15ae477528ea37aa9795c4654588a3287a9ab",
- "sha256:e439c9a10a95cb32abd708bb8be83b2134fa93790a4fb0535ca36db3dda94d20",
- "sha256:fc3b4adc2ee8474cb3cd2a155305d5f8eda0a9c91320f83e55748e1fcb68f8e3"
- ],
- "version": "==4.7.5"
+ "sha256:1ece5a3369835c20ed57adadc663400b5525904e53bae59ec854a5d36b39b21a",
+ "sha256:275ca32383bc5d1894b6975bb4ca6a7ff16ab76fa622967625baeebcf8079000",
+ "sha256:3750f2205b800aac4bb03b5ae48025a64e474d2c6cc79547988ba1d4122a09e2",
+ "sha256:4538273208e7294b2659b1602490f4ed3ab1c8cf9dbdd817e0e9db8e64be2507",
+ "sha256:5141c13374e6b25fe6bf092052ab55c0c03d21bd66c94a0e3ae371d3e4d865a5",
+ "sha256:51a4d210404ac61d32dada00a50ea7ba412e6ea945bbe992e4d7a595276d2ec7",
+ "sha256:5cf311a0f5ef80fe73e4f4c0f0998ec08f954a6ec72b746f3c179e37de1d210d",
+ "sha256:6513728873f4326999429a8b00fc7ceddb2509b01d5fd3f3be7881a257b8d463",
+ "sha256:7388d2ef3c55a8ba80da62ecfafa06a1c097c18032a501ffd4cabbc52d7f2b19",
+ "sha256:9456e90649005ad40558f4cf51dbb842e32807df75146c6d940b6f5abb4a78f3",
+ "sha256:c026fe9a05130e44157b98fea3ab12969e5b60691a276150db9eda71710cd10b",
+ "sha256:d14842362ed4cf63751648e7672f7174c9818459d169231d03c56e84daf90b7c",
+ "sha256:e0d072ae0f2a179c375f67e3da300b47e1a83293c554450b29c900e50afaae87",
+ "sha256:f07acae137b71af3bb548bd8da720956a3bc9f9a0b87733e0899226a2317aeb7",
+ "sha256:fbb77a75e529021e7c4a8d4e823d88ef4d23674a202be4f5addffc72cbb91430",
+ "sha256:fcfbb44c59af3f8ea984de67ec7c306f618a3ec771c2843804069917a8f2e255",
+ "sha256:feed85993dbdb1dbc29102f50bca65bdc68f2c0c8d352468c25b54874f23c39d"
+ ],
+ "version": "==4.7.6"
},
"packaging": {
"hashes": [
- "sha256:3c292b474fda1671ec57d46d739d072bfd495a4f51ad01a055121d81e952b7a3",
- "sha256:82f77b9bee21c1bafbf35a84905d604d5d1223801d639cf3ed140bd651c08752"
+ "sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8",
+ "sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181"
],
- "version": "==20.3"
+ "version": "==20.4"
},
"pathspec": {
"hashes": [
@@ -801,18 +818,18 @@
},
"py": {
"hashes": [
- "sha256:5e27081401262157467ad6e7f851b7aa402c5852dbcb3dae06768434de5752aa",
- "sha256:c20fdd83a5dbc0af9efd622bee9a5564e278f6380fffcacc43ba6f43db2813b0"
+ "sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2",
+ "sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342"
],
- "version": "==1.8.1"
+ "version": "==1.9.0"
},
"pylint": {
"hashes": [
- "sha256:b95e31850f3af163c2283ed40432f053acbc8fc6eba6a069cb518d9dbf71848c",
- "sha256:dd506acce0427e9e08fb87274bcaa953d38b50a58207170dbf5b36cf3e16957b"
+ "sha256:7dd78437f2d8d019717dbf287772d0b2dbdfd13fc016aa7faa08d67bccc46adc",
+ "sha256:d0ece7d223fe422088b0e8f13fa0a1e8eb745ebffcb8ed53d3e95394b6101a1c"
],
"index": "pypi",
- "version": "==2.5.2"
+ "version": "==2.5.3"
},
"pyparsing": {
"hashes": [
@@ -823,26 +840,27 @@
},
"pytest": {
"hashes": [
- "sha256:95c710d0a72d91c13fae35dce195633c929c3792f54125919847fdcdf7caa0d3",
- "sha256:eb2b5e935f6a019317e455b6da83dd8650ac9ffd2ee73a7b657a30873d67a698"
+ "sha256:5c0db86b698e8f170ba4582a492248919255fcd4c79b1ee64ace34301fb589a1",
+ "sha256:7979331bfcba207414f5e1263b5a0f8f521d0f457318836a7355531ed1a4c7d8"
],
"index": "pypi",
- "version": "==5.4.2"
+ "version": "==5.4.3"
},
"pytest-asyncio": {
"hashes": [
- "sha256:475bd2f3dc0bc11d2463656b3cbaafdbec5a47b47508ea0b329ee693040eebd2"
+ "sha256:2eae1e34f6c68fc0a9dc12d4bea190483843ff4708d24277c41568d6b6044f1d",
+ "sha256:9882c0c6b24429449f5f969a5158b528f39bde47dc32e85b9f0403965017e700"
],
"index": "pypi",
- "version": "==0.12.0"
+ "version": "==0.14.0"
},
"pytest-cov": {
"hashes": [
- "sha256:cc6742d8bac45070217169f5f72ceee1e0e55b0221f54bcf24845972d3a47f2b",
- "sha256:cdbdef4f870408ebdbfeb44e63e07eb18bb4619fae852f6e760645fa36172626"
+ "sha256:1a629dc9f48e53512fcbfda6b07de490c374b0c83c55ff7a1720b3fccff0ac87",
+ "sha256:6e6d18092dce6fad667cd7020deed816f858ad3b49d5b5e2b1cc1c97a4dba65c"
],
"index": "pypi",
- "version": "==2.8.1"
+ "version": "==2.10.0"
},
"pyyaml": {
"hashes": [
@@ -862,52 +880,52 @@
},
"regex": {
"hashes": [
- "sha256:021a0ae4d2baeeb60a3014805a2096cb329bd6d9f30669b7ad0da51a9cb73349",
- "sha256:04d6e948ef34d3eac133bedc0098364a9e635a7914f050edb61272d2ddae3608",
- "sha256:099568b372bda492be09c4f291b398475587d49937c659824f891182df728cdf",
- "sha256:0ff50843535593ee93acab662663cb2f52af8e31c3f525f630f1dc6156247938",
- "sha256:1b17bf37c2aefc4cac8436971fe6ee52542ae4225cfc7762017f7e97a63ca998",
- "sha256:1e2255ae938a36e9bd7db3b93618796d90c07e5f64dd6a6750c55f51f8b76918",
- "sha256:2bc6a17a7fa8afd33c02d51b6f417fc271538990297167f68a98cae1c9e5c945",
- "sha256:3ab5e41c4ed7cd4fa426c50add2892eb0f04ae4e73162155cd668257d02259dd",
- "sha256:3b059e2476b327b9794c792c855aa05531a3f3044737e455d283c7539bd7534d",
- "sha256:4df91094ced6f53e71f695c909d9bad1cca8761d96fd9f23db12245b5521136e",
- "sha256:5493a02c1882d2acaaf17be81a3b65408ff541c922bfd002535c5f148aa29f74",
- "sha256:5b741ecc3ad3e463d2ba32dce512b412c319993c1bb3d999be49e6092a769fb2",
- "sha256:652ab4836cd5531d64a34403c00ada4077bb91112e8bcdae933e2eae232cf4a8",
- "sha256:669a8d46764a09f198f2e91fc0d5acdac8e6b620376757a04682846ae28879c4",
- "sha256:73a10404867b835f1b8a64253e4621908f0d71150eb4e97ab2e7e441b53e9451",
- "sha256:7ce4a213a96d6c25eeae2f7d60d4dad89ac2b8134ec3e69db9bc522e2c0f9388",
- "sha256:8127ca2bf9539d6a64d03686fd9e789e8c194fc19af49b69b081f8c7e6ecb1bc",
- "sha256:b5b5b2e95f761a88d4c93691716ce01dc55f288a153face1654f868a8034f494",
- "sha256:b7c9f65524ff06bf70c945cd8d8d1fd90853e27ccf86026af2afb4d9a63d06b1",
- "sha256:f7f2f4226db6acd1da228adf433c5c3792858474e49d80668ea82ac87cf74a03",
- "sha256:fa09da4af4e5b15c0e8b4986a083f3fd159302ea115a6cc0649cd163435538b8"
- ],
- "version": "==2020.5.7"
+ "sha256:0dc64ee3f33cd7899f79a8d788abfbec168410be356ed9bd30bbd3f0a23a7204",
+ "sha256:1269fef3167bb52631ad4fa7dd27bf635d5a0790b8e6222065d42e91bede4162",
+ "sha256:14a53646369157baa0499513f96091eb70382eb50b2c82393d17d7ec81b7b85f",
+ "sha256:3a3af27a8d23143c49a3420efe5b3f8cf1a48c6fc8bc6856b03f638abc1833bb",
+ "sha256:46bac5ca10fb748d6c55843a931855e2727a7a22584f302dd9bb1506e69f83f6",
+ "sha256:4c037fd14c5f4e308b8370b447b469ca10e69427966527edcab07f52d88388f7",
+ "sha256:51178c738d559a2d1071ce0b0f56e57eb315bcf8f7d4cf127674b533e3101f88",
+ "sha256:5ea81ea3dbd6767873c611687141ec7b06ed8bab43f68fad5b7be184a920dc99",
+ "sha256:6961548bba529cac7c07af2fd4d527c5b91bb8fe18995fed6044ac22b3d14644",
+ "sha256:75aaa27aa521a182824d89e5ab0a1d16ca207318a6b65042b046053cfc8ed07a",
+ "sha256:7a2dd66d2d4df34fa82c9dc85657c5e019b87932019947faece7983f2089a840",
+ "sha256:8a51f2c6d1f884e98846a0a9021ff6861bdb98457879f412fdc2b42d14494067",
+ "sha256:9c568495e35599625f7b999774e29e8d6b01a6fb684d77dee1f56d41b11b40cd",
+ "sha256:9eddaafb3c48e0900690c1727fba226c4804b8e6127ea409689c3bb492d06de4",
+ "sha256:bbb332d45b32df41200380fff14712cb6093b61bd142272a10b16778c418e98e",
+ "sha256:bc3d98f621898b4a9bc7fecc00513eec8f40b5b83913d74ccb445f037d58cd89",
+ "sha256:c11d6033115dc4887c456565303f540c44197f4fc1a2bfb192224a301534888e",
+ "sha256:c50a724d136ec10d920661f1442e4a8b010a4fe5aebd65e0c2241ea41dbe93dc",
+ "sha256:d0a5095d52b90ff38592bbdc2644f17c6d495762edf47d876049cfd2968fbccf",
+ "sha256:d6cff2276e502b86a25fd10c2a96973fdb45c7a977dca2138d661417f3728341",
+ "sha256:e46d13f38cfcbb79bfdb2964b0fe12561fe633caf964a77a5f8d4e45fe5d2ef7"
+ ],
+ "version": "==2020.7.14"
},
"requests": {
"hashes": [
- "sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee",
- "sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6"
+ "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b",
+ "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898"
],
"index": "pypi",
- "version": "==2.23.0"
+ "version": "==2.24.0"
},
"responses": {
"hashes": [
- "sha256:1a78bc010b20a5022a2c0cb76b8ee6dc1e34d887972615ebd725ab9a166a4960",
- "sha256:3d596d0be06151330cb230a2d630717ab20f7a81f205019481e206eb5db79915"
+ "sha256:7bb697a5fedeb41d81e8b87f152d453d5cab42dcd1691b6a7d6097e94d33f373",
+ "sha256:af94d28cdfb48ded0ad82a5216616631543650f440334a693479b8991a6594a2"
],
"index": "pypi",
- "version": "==0.10.14"
+ "version": "==0.10.15"
},
"six": {
"hashes": [
- "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a",
- "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"
+ "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
+ "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
],
- "version": "==1.14.0"
+ "version": "==1.15.0"
},
"smmap": {
"hashes": [
@@ -918,17 +936,17 @@
},
"stevedore": {
"hashes": [
- "sha256:18afaf1d623af5950cc0f7e75e70f917784c73b652a34a12d90b309451b5500b",
- "sha256:a4e7dc759fb0f2e3e2f7d8ffe2358c19d45b9b8297f393ef1256858d82f69c9b"
+ "sha256:38791aa5bed922b0a844513c5f9ed37774b68edc609e5ab8ab8d8fe0ce4315e5",
+ "sha256:c8f4f0ebbc394e52ddf49de8bcc3cf8ad2b4425ebac494106bbc5e3661ac7633"
],
- "version": "==1.32.0"
+ "version": "==3.2.0"
},
"toml": {
"hashes": [
- "sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c",
- "sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e"
+ "sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f",
+ "sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88"
],
- "version": "==0.10.0"
+ "version": "==0.10.1"
},
"typed-ast": {
"hashes": [
@@ -961,18 +979,18 @@
"secure"
],
"hashes": [
- "sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527",
- "sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
+ "sha256:91056c15fa70756691db97756772bb1eb9678fa585d9184f24534b100dc60f4a",
+ "sha256:e7983572181f5e1522d9c98453462384ee92a0be7fac5f1413a1e35c56cc0461"
],
"markers": "python_version >= '3.5'",
- "version": "==1.25.9"
+ "version": "==1.25.10"
},
"wcwidth": {
"hashes": [
- "sha256:cafe2186b3c009a04067022ce1dcd79cb38d8d65ee4f4791b8888d6599d1bbe1",
- "sha256:ee73862862a156bf77ff92b09034fc4825dd3af9cf81bc5b360668d425f3c5f1"
+ "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784",
+ "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"
],
- "version": "==0.1.9"
+ "version": "==0.2.5"
},
"wrapt": {
"hashes": [
diff --git a/app/main.py b/app/main.py
index 9b335df3..3033aaac 100644
--- a/app/main.py
+++ b/app/main.py
@@ -6,10 +6,11 @@
import pydantic
import sentry_sdk
import uvicorn
-from fastapi import FastAPI, Request, Response
+from fastapi import FastAPI, Request, Response, openapi
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import JSONResponse
+from fastapi.staticfiles import StaticFiles
from scout_apm.async_.starlette import ScoutMiddleware
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
@@ -35,8 +36,8 @@
" Project page: https://github.com/ExpDev07/coronavirus-tracker-api."
),
version="2.0.3",
- docs_url="/",
- redoc_url="/docs",
+ docs_url=None,
+ redoc_url=None,
on_startup=[setup_client_session],
on_shutdown=[teardown_client_session],
)
@@ -108,6 +109,31 @@ async def handle_validation_error(
# Include routers.
APP.include_router(V1, prefix="", tags=["v1"])
APP.include_router(V2, prefix="/v2", tags=["v2"])
+APP.mount("/static", StaticFiles(directory="static"), name="static")
+
+# ##############
+# Swagger/Redocs
+# ##############
+
+
+@APP.get("/", include_in_schema=False)
+async def custom_swagger_ui_html():
+ """Serve Swagger UI."""
+ return openapi.docs.get_swagger_ui_html(
+ openapi_url=APP.openapi_url,
+ title=f"{APP.title} - Swagger UI",
+ oauth2_redirect_url=APP.swagger_ui_oauth2_redirect_url,
+ swagger_js_url="/static/swagger-ui-bundle.js",
+ swagger_css_url="/static/swagger-ui.css",
+ )
+
+
+@APP.get("/docs", include_in_schema=False)
+async def redoc_html():
+ """Serve ReDoc UI."""
+ return openapi.docs.get_redoc_html(
+ openapi_url=APP.openapi_url, title=f"{APP.title} - ReDoc", redoc_js_url="/static/redoc.standalone.js",
+ )
# Running of app.
diff --git a/requirements-dev.txt b/requirements-dev.txt
index d95c199e..84619bec 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,49 +1,49 @@
-i https://pypi.org/simple
-appdirs==1.4.3
-astroid==2.4.1
+appdirs==1.4.4
+astroid==2.4.2
async-asgi-testclient==1.4.4
async-generator==1.10
asyncmock==0.4.2
attrs==19.3.0
bandit==1.6.2
black==19.10b0
-certifi==2020.4.5.1
+certifi==2020.6.20
chardet==3.0.4
click==7.1.2
-coverage==5.1
-coveralls==2.0.0
+coverage==5.2.1
+coveralls==2.1.1
docopt==0.6.2
gitdb==4.0.5
-gitpython==3.1.2
-idna==2.9
-importlib-metadata==1.6.0 ; python_version < '3.8'
+gitpython==3.1.7
+idna==2.10
+importlib-metadata==1.7.0 ; python_version < '3.8'
invoke==1.4.1
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
mock==4.0.2
-more-itertools==8.2.0
-multidict==4.7.5
-packaging==20.3
+more-itertools==8.4.0
+multidict==4.7.6
+packaging==20.4
pathspec==0.8.0
pbr==5.4.5
pluggy==0.13.1
-py==1.8.1
-pylint==2.5.2
+py==1.9.0
+pylint==2.5.3
pyparsing==2.4.7
-pytest-asyncio==0.12.0
-pytest-cov==2.8.1
-pytest==5.4.2
+pytest-asyncio==0.14.0
+pytest-cov==2.10.0
+pytest==5.4.3
pyyaml==5.3.1
-regex==2020.5.7
-requests==2.23.0
-responses==0.10.14
-six==1.14.0
+regex==2020.7.14
+requests==2.24.0
+responses==0.10.15
+six==1.15.0
smmap==3.0.4
-stevedore==1.32.0
-toml==0.10.0
+stevedore==3.2.0
+toml==0.10.1
typed-ast==1.4.1
-urllib3[secure]==1.25.9 ; python_version >= '3.5'
-wcwidth==0.1.9
+urllib3[secure]==1.25.10 ; python_version >= '3.5'
+wcwidth==0.2.5
wrapt==1.12.1
zipp==3.1.0
diff --git a/requirements.txt b/requirements.txt
index 02ab222e..415ef5d7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,39 +3,40 @@ aiocache[redis]==0.11.1
aiofiles==0.5.0
aiohttp==3.6.2
aioredis==1.3.1
-asgiref==3.2.7 ; python_version >= '3.5'
+asgiref==3.2.10 ; python_version >= '3.5'
async-timeout==3.0.1
asyncache==0.1.1
attrs==19.3.0
-cachetools==4.1.0
-certifi==2020.4.5.1
-cffi==1.14.0
+cachetools==4.1.1
+certifi==2020.6.20
+cffi==1.14.1
chardet==3.0.4
click==7.1.2
-cryptography==2.9.2
+cryptography==3.0
dataclasses==0.6 ; python_version < '3.7'
-fastapi==0.54.1
+fastapi==0.60.1
gunicorn==20.0.4
h11==0.9.0
-hiredis==1.0.1
+hiredis==1.1.0
httptools==0.1.1 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
idna-ssl==1.1.0 ; python_version < '3.7'
-idna==2.9
-multidict==4.7.5
-psutil==5.7.0
+idna==2.10
+multidict==4.7.6
+psutil==5.7.2
pycparser==2.20
-pydantic[dotenv]==1.5.1
+pydantic[dotenv]==1.6.1
pyopenssl==19.1.0
python-dateutil==2.8.1
-python-dotenv==0.13.0
-requests==2.23.0
-scout-apm==2.14.1
-sentry-sdk==0.14.3
-six==1.14.0
-starlette==0.13.2
-urllib3[secure]==1.25.9 ; python_version >= '3.5'
-uvicorn==0.11.5
+python-dotenv==0.14.0
+requests==2.24.0
+scout-apm==2.15.2
+sentry-sdk==0.16.2
+six==1.15.0
+starlette==0.13.6
+typing-extensions==3.7.4.2
+urllib3[secure]==1.25.10 ; python_version >= '3.5'
+uvicorn==0.11.7
uvloop==0.14.0 ; sys_platform != 'win32' and sys_platform != 'cygwin' and platform_python_implementation != 'PyPy'
websockets==8.1
wrapt==1.12.1
-yarl==1.4.2
+yarl==1.5.0
diff --git a/static/redoc.standalone.js b/static/redoc.standalone.js
new file mode 100644
index 00000000..55dbe5bb
--- /dev/null
+++ b/static/redoc.standalone.js
@@ -0,0 +1,137 @@
+/*!
+ * ReDoc - OpenAPI/Swagger-generated API Reference Documentation
+ * -------------------------------------------------------------
+ * Version: "2.0.0-rc.35"
+ * Repo: https://github.com/Redocly/redoc
+ */
+!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("null"),function(){try{return require("esprima")}catch(e){}}()):"function"==typeof define&&define.amd?define(["null","esprima"],t):"object"==typeof exports?exports.Redoc=t(require("null"),function(){try{return require("esprima")}catch(e){}}()):e.Redoc=t(e.null,e.esprima)}(this,(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=162)}([function(e,t,n){"use strict";e.exports=n(226)},function(e,t,n){"use strict";n.r(t),n.d(t,"__extends",(function(){return o})),n.d(t,"__assign",(function(){return i})),n.d(t,"__rest",(function(){return a})),n.d(t,"__decorate",(function(){return s})),n.d(t,"__param",(function(){return l})),n.d(t,"__metadata",(function(){return c})),n.d(t,"__awaiter",(function(){return u})),n.d(t,"__generator",(function(){return p})),n.d(t,"__exportStar",(function(){return f})),n.d(t,"__values",(function(){return d})),n.d(t,"__read",(function(){return h})),n.d(t,"__spread",(function(){return m})),n.d(t,"__spreadArrays",(function(){return g})),n.d(t,"__await",(function(){return y})),n.d(t,"__asyncGenerator",(function(){return v})),n.d(t,"__asyncDelegator",(function(){return b})),n.d(t,"__asyncValues",(function(){return x})),n.d(t,"__makeTemplateObject",(function(){return w})),n.d(t,"__importStar",(function(){return k})),n.d(t,"__importDefault",(function(){return O})),n.d(t,"__classPrivateFieldGet",(function(){return E})),n.d(t,"__classPrivateFieldSet",(function(){return _}));
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at http://www.apache.org/licenses/LICENSE-2.0
+
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+MERCHANTABLITY OR NON-INFRINGEMENT.
+
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */
+var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function o(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function l(e,t){return function(n,r){t(n,r,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))}function p(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function h(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function m(){for(var e=[],t=0;t1||s(e,t)}))})}function s(e,t){try{(n=o[e](t)).value instanceof y?Promise.resolve(n.value.v).then(l,c):u(i[0][2],n)}catch(e){u(i[0][3],e)}var n}function l(e){s("next",e)}function c(e){s("throw",e)}function u(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}}function b(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:y(e[r](t)),done:"return"===r}:o?o(t):t}:o}}function x(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=d(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}function w(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function k(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function O(e){return e&&e.__esModule?e:{default:e}}function E(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function _(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}},function(e,t,n){"use strict";(function(e,r){n.d(t,"a",(function(){return pn})),n.d(t,"b",(function(){return qe})),n.d(t,"c",(function(){return Se})),n.d(t,"d",(function(){return ot})),n.d(t,"e",(function(){return le})),n.d(t,"f",(function(){return ft})),n.d(t,"g",(function(){return L})),n.d(t,"h",(function(){return ht})),n.d(t,"i",(function(){return $t})),n.d(t,"j",(function(){return Vt})),n.d(t,"k",(function(){return rn})),n.d(t,"l",(function(){return ne})),n.d(t,"m",(function(){return bt})),n.d(t,"n",(function(){return it})),n.d(t,"o",(function(){return et})),n.d(t,"p",(function(){return wt})),n.d(t,"q",(function(){return me}));
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at http://www.apache.org/licenses/LICENSE-2.0
+
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+MERCHANTABLITY OR NON-INFRINGEMENT.
+
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */
+var o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function i(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var a=function(){return(a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function l(){for(var e=[],t=0;t2&&re("box");var n=Q(t);return new Ce(e,X(n),n.name,!0,n.equals)},shallowBox:function(e,t){return arguments.length>2&&re("shallowBox"),ne.box(e,{name:t,deep:!1})},array:function(e,t){arguments.length>2&&re("array");var n=Q(t);return new Mt(e,X(n),n.name)},shallowArray:function(e,t){return arguments.length>2&&re("shallowArray"),ne.array(e,{name:t,deep:!1})},map:function(e,t){arguments.length>2&&re("map");var n=Q(t);return new Wt(e,X(n),n.name)},shallowMap:function(e,t){return arguments.length>2&&re("shallowMap"),ne.map(e,{name:t,deep:!1})},set:function(e,t){arguments.length>2&&re("set");var n=Q(t);return new Gt(e,X(n),n.name)},object:function(e,t,n){"string"==typeof arguments[1]&&re("object");var r=Q(n);return dt({},e,t,r)},shallowObject:function(e,t){return"string"==typeof arguments[1]&&re("shallowObject"),ne.object(e,{},{name:t,deep:!1})},ref:J,shallow:Z,deep:K,struct:ee},ne=function(e,t,n){if("string"==typeof arguments[1])return K.apply(null,arguments);if(vt(e))return e;var r=b(e)?ne.object(e,t,n):Array.isArray(e)?ne.array(e,t):O(e)?ne.map(e,t):E(e)?ne.set(e,t):e;if(r!==e)return r;h(!1)};function re(e){h("Expected one or two arguments to observable."+e+". Did you accidentally try to use observable."+e+" as decorator?")}Object.keys(te).forEach((function(e){return ne[e]=te[e]}));var oe,ie,ae=$(!1,(function(e,t,n,r,o){var i=n.get,s=n.set,l=o[0]||{};!function(e,t,n){var r=Kt(e);n.name=r.name+"."+t,n.context=e,r.values[t]=new Ae(n),Object.defineProperty(e,t,function(e){return en[e]||(en[e]={configurable:Le.computedConfigurable,enumerable:!1,get:function(){return tn(this).read(this,e)},set:function(t){tn(this).write(this,e,t)}})}(t))}(e,t,a({get:i,set:s},l))})),se=ae({equals:D.structural}),le=function(e,t,n){if("string"==typeof t)return ae.apply(null,arguments);if(null!==e&&"object"==typeof e&&1===arguments.length)return ae.apply(null,arguments);var r="object"==typeof t?t:{};return r.get=e,r.set="function"==typeof t?t:r.set,r.name=r.name||e.name||"",new Ae(r)};le.struct=se,function(e){e[e.NOT_TRACKING=-1]="NOT_TRACKING",e[e.UP_TO_DATE=0]="UP_TO_DATE",e[e.POSSIBLY_STALE=1]="POSSIBLY_STALE",e[e.STALE=2]="STALE"}(oe||(oe={})),function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"}(ie||(ie={}));var ce=function(e){this.cause=e};function ue(e){return e instanceof ce}function pe(e){switch(e.dependenciesState){case oe.UP_TO_DATE:return!1;case oe.NOT_TRACKING:case oe.STALE:return!0;case oe.POSSIBLY_STALE:for(var t=ve(!0),n=ge(),r=e.observing,o=r.length,i=0;i0;Le.computationDepth>0&&t&&h(!1),Le.allowStateChanges||!t&&"strict"!==Le.enforceActions||h(!1)}function de(e,t,n){var r=ve(!0);xe(e),e.newObserving=new Array(e.observing.length+100),e.unboundDepsCount=0,e.runId=++Le.runId;var o,i=Le.trackingDerivation;if(Le.trackingDerivation=e,!0===Le.disableErrorBoundaries)o=t.call(n);else try{o=t.call(n)}catch(e){o=new ce(e)}return Le.trackingDerivation=i,function(e){for(var t=e.observing,n=e.observing=e.newObserving,r=oe.UP_TO_DATE,o=0,i=e.unboundDepsCount,a=0;ar&&(r=s.dependenciesState)}n.length=o,e.newObserving=null,i=t.length;for(;i--;){0===(s=t[i]).diffValue&&De(s,e),s.diffValue=0}for(;o--;){var s;1===(s=n[o]).diffValue&&(s.diffValue=0,Me(s,e))}r!==oe.UP_TO_DATE&&(e.dependenciesState=r,e.onBecomeStale())}(e),e.observing.length,be(r),o}function he(e){var t=e.observing;e.observing=[];for(var n=t.length;n--;)De(t[n],e);e.dependenciesState=oe.NOT_TRACKING}function me(e){var t=ge(),n=e();return ye(t),n}function ge(){var e=Le.trackingDerivation;return Le.trackingDerivation=null,e}function ye(e){Le.trackingDerivation=e}function ve(e){var t=Le.allowStateReads;return Le.allowStateReads=e,t}function be(e){Le.allowStateReads=e}function xe(e){if(e.dependenciesState!==oe.UP_TO_DATE){e.dependenciesState=oe.UP_TO_DATE;for(var t=e.observing,n=t.length;n--;)t[n].lowestObserverState=oe.UP_TO_DATE}}var we=0,ke=1,Oe=Object.getOwnPropertyDescriptor((function(){}),"name");Oe&&Oe.configurable;function Ee(e,t){var n=function(){return _e(e,t,this,arguments)};return n.isMobxAction=!0,n}function _e(e,t,n,r){var o=function(e,t,n){var r=Qe()&&!!e,o=0;if(r){o=Date.now();var i=n&&n.length||0,a=new Array(i);if(i>0)for(var s=0;s0&&!e.__mobxGlobals&&(Re=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==(new Pe).version&&(Re=!1),Re?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Pe):(setTimeout((function(){Ne||h("There are multiple, different versions of MobX active. Make sure MobX is loaded only once or use `configure({ isolateGlobalState: true })`")}),1),new Pe)}();function Me(e,t){var n=e.observers.length;n&&(e.observersIndexes[t.__mapid]=n),e.observers[n]=t,e.lowestObserverState>t.dependenciesState&&(e.lowestObserverState=t.dependenciesState)}function De(e,t){if(1===e.observers.length)e.observers.length=0,Fe(e);else{var n=e.observers,r=e.observersIndexes,o=n.pop();if(o!==t){var i=r[t.__mapid]||0;i?r[o.__mapid]=i:delete r[o.__mapid],n[i]=o}delete r[t.__mapid]}}function Fe(e){!1===e.isPendingUnobservation&&(e.isPendingUnobservation=!0,Le.pendingUnobservations.push(e))}function ze(){Le.inBatch++}function Ue(){if(0==--Le.inBatch){He();for(var e=Le.pendingUnobservations,t=0;t0&&Fe(e),!1)}function $e(e,t){if(console.log("[mobx.trace] '"+e.name+"' is invalidated due to a change in: '"+t.name+"'"),e.isTracing===ie.BREAK){var n=[];!function e(t,n,r){if(n.length>=1e3)return void n.push("(and many more)");n.push(""+new Array(r).join("\t")+t.name),t.dependencies&&t.dependencies.forEach((function(t){return e(t,n,r+1)}))}(ht(e),n,1),new Function("debugger;\n/*\nTracing '"+e.name+"'\n\nYou are entering this break point because derivation '"+e.name+"' is being traced and '"+t.name+"' is now forcing it to update.\nJust follow the stacktrace you should now see in the devtools to see precisely what piece of your code is causing this update\nThe stackframe you are looking for is at least ~6-8 stack-frames up.\n\n"+(e instanceof Ae?e.derivation.toString().replace(/[*]\//g,"/"):"")+"\n\nThe dependencies for this derivation are:\n\n"+n.join("\n")+"\n*/\n ")()}}var qe=function(){function e(e,t,n,r){void 0===e&&(e="Reaction@"+d()),void 0===r&&(r=!1),this.name=e,this.onInvalidate=t,this.errorHandler=n,this.requiresObservable=r,this.observing=[],this.newObserving=[],this.dependenciesState=oe.NOT_TRACKING,this.diffValue=0,this.runId=0,this.unboundDepsCount=0,this.__mapid="#"+d(),this.isDisposed=!1,this._isScheduled=!1,this._isTrackPending=!1,this._isRunning=!1,this.isTracing=ie.NONE}return e.prototype.onBecomeStale=function(){this.schedule()},e.prototype.schedule=function(){this._isScheduled||(this._isScheduled=!0,Le.pendingReactions.push(this),He())},e.prototype.isScheduled=function(){return this._isScheduled},e.prototype.runReaction=function(){if(!this.isDisposed){if(ze(),this._isScheduled=!1,pe(this)){this._isTrackPending=!0;try{this.onInvalidate(),this._isTrackPending&&Qe()&&Xe({name:this.name,type:"scheduled-reaction"})}catch(e){this.reportExceptionInDerivation(e)}}Ue()}},e.prototype.track=function(e){ze();var t,n=Qe();n&&(t=Date.now(),Ke({name:this.name,type:"reaction"})),this._isRunning=!0;var r=de(this,e,void 0);this._isRunning=!1,this._isTrackPending=!1,this.isDisposed&&he(this),ue(r)&&this.reportExceptionInDerivation(r.cause),n&&Je({time:Date.now()-t}),Ue()},e.prototype.reportExceptionInDerivation=function(e){var t=this;if(this.errorHandler)this.errorHandler(e,this);else{if(Le.disableErrorBoundaries)throw e;var n="[mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: '"+this+"'";Le.suppressReactionErrors?console.warn("[mobx] (error in reaction '"+this.name+"' suppressed, fix error of causing action below)"):console.error(n,e),Qe()&&Xe({type:"error",name:this.name,message:n,error:""+e}),Le.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},e.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,this._isRunning||(ze(),he(this),Ue()))},e.prototype.getDisposer=function(){var e=this.dispose.bind(this);return e.$mobx=this,e},e.prototype.toString=function(){return"Reaction["+this.name+"]"},e.prototype.trace=function(e){void 0===e&&(e=!1),function(){for(var e=[],t=0;t0||Le.isRunningReactions||We(Ve)}function Ve(){Le.isRunningReactions=!0;for(var e=Le.pendingReactions,t=0;e.length>0;){100==++t&&(console.error("Reaction doesn't converge to a stable state after 100 iterations. Probably there is a cycle in the reactive function: "+e[0]),e.splice(0));for(var n=e.splice(0),r=0,o=n.length;r",e):2===arguments.length&&"function"==typeof t?Ee(e,t):1===arguments.length&&"string"==typeof e?nt(e):!0!==r?nt(t).apply(null,arguments):void(e[t]=Ee(e.name||t,n.value))};function it(e,t){return _e("string"==typeof e?e:e.name||"","function"==typeof e?e:t,this,void 0)}function at(e,t,n){x(e,t,Ee(t,n.bind(e)))}function st(e,t){void 0===t&&(t=u);var n,r=t&&t.name||e.name||"Autorun@"+d();if(!t.scheduler&&!t.delay)n=new qe(r,(function(){this.track(a)}),t.onError,t.requiresObservable);else{var o=ct(t),i=!1;n=new qe(r,(function(){i||(i=!0,o((function(){i=!1,n.isDisposed||n.track(a)})))}),t.onError,t.requiresObservable)}function a(){e(n)}return n.schedule(),n.getDisposer()}ot.bound=function(e,t,n,r){return!0===r?(at(e,t,n.value),null):n?{configurable:!0,enumerable:!1,get:function(){return at(this,t,n.value||n.initializer.call(this)),this[t]},set:tt}:{enumerable:!1,configurable:!0,set:function(e){at(this,t,e)},get:function(){}}};var lt=function(e){return e()};function ct(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:lt}function ut(e,t,n){return pt("onBecomeUnobserved",e,t,n)}function pt(e,t,n,r){var o="function"==typeof r?on(t,n):on(t),i="function"==typeof r?r:n,a=o[e];return"function"!=typeof a?h(!1):(o[e]=function(){a.call(this),i.call(this)},function(){o[e]=a})}function ft(e){var t=e.enforceActions,n=e.computedRequiresReaction,r=e.computedConfigurable,o=e.disableErrorBoundaries,i=e.arrayBuffer,a=e.reactionScheduler,s=e.reactionRequiresObservable,l=e.observableRequiresReaction;if(!0===e.isolateGlobalState&&((Le.pendingReactions.length||Le.inBatch||Le.isRunningReactions)&&h("isolateGlobalState should be called before MobX is running any reactions"),Ne=!0,Re&&(0==--f().__mobxInstanceCount&&(f().__mobxGlobals=void 0),Le=new Pe)),void 0!==t){var c=void 0;switch(t){case!0:case"observed":c=!0;break;case!1:case"never":c=!1;break;case"strict":case"always":c="strict";break;default:h("Invalid value for 'enforceActions': '"+t+"', expected 'never', 'always' or 'observed'")}Le.enforceActions=c,Le.allowStateChanges=!0!==c&&"strict"!==c}void 0!==n&&(Le.computedRequiresReaction=!!n),void 0!==s&&(Le.reactionRequiresObservable=!!s),void 0!==l&&(Le.observableRequiresReaction=!!l,Le.allowStateReads=!Le.observableRequiresReaction),void 0!==r&&(Le.computedConfigurable=!!r),void 0!==o&&(!0===o&&console.warn("WARNING: Debug feature only. MobX will NOT recover from errors if this is on."),Le.disableErrorBoundaries=!!o),"number"==typeof i&&Ut(i),a&&Ge(a)}function dt(e,t,n,r){var o=(r=Q(r)).defaultDecorator||(!1===r.deep?J:K);B(e),Kt(e,r.name,o.enhancer),ze();try{for(var i in t){var a=Object.getOwnPropertyDescriptor(t,i);0;var s=(n&&i in n?n[i]:a.get?ae:o)(e,i,a,!0);s&&Object.defineProperty(e,i,s)}}finally{Ue()}return e}function ht(e,t){return mt(on(e,t))}function mt(e){var t,n,r={name:e.name};return e.observing&&e.observing.length>0&&(r.dependencies=(t=e.observing,n=[],t.forEach((function(e){-1===n.indexOf(e)&&n.push(e)})),n).map(mt)),r}function gt(){this.message="FLOW_CANCELLED"}function yt(e,t){if(null==e)return!1;if(void 0!==t){if(rn(e)){var n=e.$mobx;return n.values&&!!n.values[t]}return!1}return rn(e)||!!e.$mobx||N(e)||Ye(e)||Ie(e)}function vt(e){return 1!==arguments.length&&h(!1),yt(e)}function bt(e,t,n,r){return"function"==typeof n?function(e,t,n,r){return an(e,t).observe(n,r)}(e,t,n,r):function(e,t,n){return an(e).observe(t,n)}(e,t,n)}gt.prototype=Object.create(Error.prototype);function xt(e){switch(e.length){case 0:return Le.trackingDerivation;case 1:return on(e[0]);case 2:return on(e[0],e[1])}}function wt(e,t){void 0===t&&(t=void 0),ze();try{return e.apply(t)}finally{Ue()}}function kt(e){return void 0!==e.interceptors&&e.interceptors.length>0}function Ot(e,t){var n=e.interceptors||(e.interceptors=[]);return n.push(t),g((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function Et(e,t){var n=ge();try{var r=e.interceptors;if(r)for(var o=0,i=r.length;o0}function St(e,t){var n=e.changeListeners||(e.changeListeners=[]);return n.push(t),g((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function Tt(e,t){var n=ge(),r=e.changeListeners;if(r){for(var o=0,i=(r=r.slice()).length;o0?e.map(this.dehancer):e},e.prototype.intercept=function(e){return Ot(this,e)},e.prototype.observe=function(e,t){return void 0===t&&(t=!1),t&&e({object:this.array,type:"splice",index:0,added:this.values.slice(),addedCount:this.values.length,removed:[],removedCount:0}),St(this,e)},e.prototype.getArrayLength=function(){return this.atom.reportObserved(),this.values.length},e.prototype.setArrayLength=function(e){if("number"!=typeof e||e<0)throw new Error("[mobx.array] Out of range: "+e);var t=this.values.length;if(e!==t)if(e>t){for(var n=new Array(e-t),r=0;r0&&e+t+1>Rt&&Ut(e+t+1)},e.prototype.spliceWithArray=function(e,t,n){var r=this;fe(this.atom);var o=this.values.length;if(void 0===e?e=0:e>o?e=o:e<0&&(e=Math.max(0,o+e)),t=1===arguments.length?o-e:null==t?0:Math.max(0,Math.min(t,o-e)),void 0===n&&(n=c),kt(this)){var i=Et(this,{object:this.array,type:"splice",index:e,removedCount:t,added:n});if(!i)return c;t=i.removedCount,n=i.added}var a=(n=0===n.length?n:n.map((function(e){return r.enhancer(e,void 0)}))).length-t;this.updateArrayLength(o,a);var s=this.spliceItemsIntoValues(e,t,n);return 0===t&&0===n.length||this.notifyArraySplice(e,n,s),this.dehanceValues(s)},e.prototype.spliceItemsIntoValues=function(e,t,n){var r;if(n.length<1e4)return(r=this.values).splice.apply(r,l([e,t],n));var o=this.values.slice(e,e+t);return this.values=this.values.slice(0,e).concat(n,this.values.slice(e+t)),o},e.prototype.notifyArrayChildUpdate=function(e,t,n){var r=!this.owned&&Qe(),o=_t(this),i=o||r?{object:this.array,type:"update",index:e,newValue:t,oldValue:n}:null;r&&Ke(a(a({},i),{name:this.atom.name})),this.atom.reportChanged(),o&&Tt(this,i),r&&Je()},e.prototype.notifyArraySplice=function(e,t,n){var r=!this.owned&&Qe(),o=_t(this),i=o||r?{object:this.array,type:"splice",index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;r&&Ke(a(a({},i),{name:this.atom.name})),this.atom.reportChanged(),o&&Tt(this,i),r&&Je()},e}(),Mt=function(e){function t(t,n,r,o){void 0===r&&(r="ObservableArray@"+d()),void 0===o&&(o=!1);var i=e.call(this)||this,a=new Lt(r,n,i,o);if(w(i,"$mobx",a),t&&t.length){var s=Te(!0);i.spliceWithArray(0,0,t),je(s)}return Pt&&Object.defineProperty(a.array,"0",Dt),i}return i(t,e),t.prototype.intercept=function(e){return this.$mobx.intercept(e)},t.prototype.observe=function(e,t){return void 0===t&&(t=!1),this.$mobx.observe(e,t)},t.prototype.clear=function(){return this.splice(0)},t.prototype.concat=function(){for(var e=[],t=0;t-1&&(this.splice(t,1),!0)},t.prototype.move=function(e,t){function n(e){if(e<0)throw new Error("[mobx.array] Index out of bounds: "+e+" is negative");var t=this.$mobx.values.length;if(e>=t)throw new Error("[mobx.array] Index out of bounds: "+e+" is not smaller than "+t)}if(n.call(this,e),n.call(this,t),e!==t){var r,o=this.$mobx.values;r=e0;)r[o]=arguments[o+2];t.locks++;try{var i;return null!=e&&(i=e.apply(this,r)),i}finally{t.locks--,0===t.locks&&t.methods.forEach((function(e){e.apply(n,r)}))}}function y(e,t){return function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];g.call.apply(g,[this,e,t].concat(n))}}function v(e,t,n){var r=function(e,t){var n=e[h]=e[h]||{},r=n[t]=n[t]||{};return r.locks=r.locks||0,r.methods=r.methods||[],r}(e,t);r.methods.indexOf(n)<0&&r.methods.push(n);var o=Object.getOwnPropertyDescriptor(e,t);if(!o||!o[m]){var i=e[t],a=function e(t,n,r,o,i){var a,s=y(i,o);return(a={})[m]=!0,a.get=function(){return s},a.set=function(i){if(this===t)s=y(i,o);else{var a=e(this,n,r,o,i);Object.defineProperty(this,n,a)}},a.configurable=!0,a.enumerable=r,a}(e,t,o?o.enumerable:void 0,r,i);Object.defineProperty(e,t,a)}}var b=s.a||"$mobx",x=u("isUnmounted"),w=u("skipRender"),k=u("isForcingUpdate");function O(e){var t=e.prototype;if(t.componentWillReact)throw new Error("The componentWillReact life-cycle event is no longer supported");if(e.__proto__!==i.PureComponent)if(t.shouldComponentUpdate){if(t.shouldComponentUpdate!==_)throw new Error("It is not allowed to use shouldComponentUpdate in observer based components.")}else t.shouldComponentUpdate=_;S(t,"props"),S(t,"state");var n=t.render;return t.render=function(){return E.call(this,n)},v(t,"componentWillUnmount",(function(){if(!0!==Object(o.b)()){if(this.render[b])this.render[b].dispose();else;this[x]=!0}})),e}function E(e){var t=this;if(!0===Object(o.b)())return e.call(this);d(this,w,!1),d(this,k,!1);var n,r=(n=this).displayName||n.name||n.constructor&&(n.constructor.displayName||n.constructor.name)||"",a=e.bind(this),l=!1,c=new s.b(r+".render()",(function(){if(!l&&(l=!0,!0!==t[x])){var e=!0;try{d(t,k,!0),t[w]||i.Component.prototype.forceUpdate.call(t),e=!1}finally{d(t,k,!1),e&&c.dispose()}}}));function u(){l=!1;var e=void 0,t=void 0;if(c.track((function(){try{t=Object(s.c)(!1,a)}catch(t){e=t}})),e)throw e;return t}return c.reactComponent=this,u[b]=c,this.render=u,u.call(this)}function _(e,t){return Object(o.b)()&&console.warn("[mobx-react] It seems that a re-rendering of a React component is triggered while in static (server-side) mode. Please make sure components are rendered only once server-side."),this.state!==t||!p(this.props,e)}function S(e,t){var n=u("reactProp_"+t+"_valueHolder"),r=u("reactProp_"+t+"_atomHolder");function o(){return this[r]||d(this,r,Object(s.g)("reactive "+t)),this[r]}Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){return o.call(this).reportObserved(),this[n]},set:function(e){this[k]||p(this[n],e)?d(this,n,e):(d(this,n,e),d(this,w,!0),o.call(this).reportChanged(),d(this,w,!1))}})}var T="function"==typeof Symbol&&Symbol.for,j=T?Symbol.for("react.forward_ref"):"function"==typeof i.forwardRef&&Object(i.forwardRef)((function(){})).$$typeof,C=T?Symbol.for("react.memo"):"function"==typeof i.memo&&Object(i.memo)((function(){})).$$typeof;function A(e){if(!0===e.isMobxInjector&&console.warn("Mobx observer: You are trying to use 'observer' on a component that already has 'inject'. Please apply 'observer' before applying 'inject'"),C&&e.$$typeof===C)throw new Error("Mobx observer: You are trying to use 'observer' on function component wrapped to either another observer or 'React.memo'. The observer already applies 'React.memo' for you.");if(j&&e.$$typeof===j){var t=e.render;if("function"!=typeof t)throw new Error("render property of ForwardRef was not a function");return Object(i.forwardRef)((function(){var e=arguments;return a.a.createElement(o.a,null,(function(){return t.apply(void 0,e)}))}))}return"function"!=typeof e||e.prototype&&e.prototype.render||e.isReactClass||Object.prototype.isPrototypeOf.call(i.Component,e)?O(e):Object(o.c)(e)}a.a.createContext({});u("disposeOnUnmountProto"),u("disposeOnUnmountInst");function I(e){function t(t,n,r,o,i,a){for(var l=[],c=arguments.length-6;c-- >0;)l[c]=arguments[c+6];return Object(s.q)((function(){if(o=o||"<>",a=a||r,null==n[r]){if(t){var s=null===n[r]?"null":"undefined";return new Error("The "+i+" `"+a+"` is marked as required in `"+o+"`, but its value is `"+s+"`.")}return null}return e.apply(void 0,[n,r,o,i,a].concat(l))}))}var n=t.bind(null,!1);return n.isRequired=t.bind(null,!0),n}function P(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function R(e,t){return I((function(n,r,o,i,a){return Object(s.q)((function(){if(e&&P(n[r])===t.toLowerCase())return null;var i;switch(t){case"Array":i=s.i;break;case"Object":i=s.k;break;case"Map":i=s.j;break;default:throw new Error("Unexpected mobxType: "+t)}var l=n[r];if(!i(l)){var c=function(e){var t=P(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}(l),u=e?" or javascript `"+t.toLowerCase()+"`":"";return new Error("Invalid prop `"+a+"` of type `"+c+"` supplied to `"+o+"`, expected `mobx.Observable"+t+"`"+u+".")}return null}))}))}function N(e,t){return I((function(n,r,o,i,a){for(var l=[],c=arguments.length-5;c-- >0;)l[c]=arguments[c+5];return Object(s.q)((function(){if("function"!=typeof t)return new Error("Property `"+a+"` of component `"+o+"` has invalid PropType notation.");var s=R(e,"Array")(n,r,o);if(s instanceof Error)return s;for(var c=n[r],u=0;u",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(c),p=["%","/","?",";","#"].concat(u),f=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,h=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},v=n(235);function b(e,t,n){if(e&&o.isObject(e)&&e instanceof i)return e;var r=new i;return r.parse(e,t,n),r}i.prototype.parse=function(e,t,n){if(!o.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var i=e.indexOf("?"),s=-1!==i&&i127?R+="x":R+=P[N];if(!R.match(d)){var M=A.slice(0,T),D=A.slice(T+1),F=P.match(h);F&&(M.push(F[1]),D.unshift(F[2])),D.length&&(b="/"+D.join(".")+b),this.hostname=M.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=r.toASCII(this.hostname));var z=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+z,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!m[k])for(T=0,I=u.length;T0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift());return n.search=e.search,n.query=e.query,o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!O.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var _=O.slice(-1)[0],S=(n.host||e.host||O.length>1)&&("."===_||".."===_)||""===_,T=0,j=O.length;j>=0;j--)"."===(_=O[j])?O.splice(j,1):".."===_?(O.splice(j,1),T++):T&&(O.splice(j,1),T--);if(!w&&!k)for(;T--;T)O.unshift("..");!w||""===O[0]||O[0]&&"/"===O[0].charAt(0)||O.unshift(""),S&&"/"!==O.join("/").substr(-1)&&O.push("");var C,A=""===O[0]||O[0]&&"/"===O[0].charAt(0);E&&(n.hostname=n.host=A?"":O.length?O.shift():"",(C=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=C.shift(),n.host=n.hostname=C.shift()));return(w=w||n.host&&O.length)&&!A&&O.unshift(""),O.length?n.pathname=O.join("/"):(n.pathname=null,n.path=null),o.isNull(n.pathname)&&o.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},i.prototype.parseHost=function(){var e=this.host,t=s.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t,n){var r=n(36),o=n(11),i=n(129),a=n(16).f;e.exports=function(e){var t=r.Symbol||(r.Symbol={});o(t,e)||a(t,e,{value:i.f(e)})}},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var l,c=[],u=!1,p=-1;function f(){u&&l&&(u=!1,l.length?c=l.concat(c):p=-1,c.length&&d())}function d(){if(!u){var e=s(f);u=!0;for(var t=c.length;t;){for(l=c,c=[];++p1)for(var n=1;n
+ * @license MIT
+ */
+var r=n(239),o=n(240),i=n(131);function a(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function h(e,t){if(l.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return U(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return B(e).length;default:if(r)return U(e).length;t=(""+t).toLowerCase(),r=!0}}function m(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return S(this,t,n);case"ascii":return T(this,t,n);case"latin1":case"binary":return j(this,t,n);case"base64":return _(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function g(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function y(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=l.from(t,r)),l.isBuffer(t))return 0===t.length?-1:v(e,t,n,r,o);if("number"==typeof t)return t&=255,l.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):v(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function v(e,t,n,r,o){var i,a=1,s=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;a=2,s/=2,l/=2,n/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(o){var u=-1;for(i=n;is&&(n=s-l),i=n;i>=0;i--){for(var p=!0,f=0;fo&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var a=0;a>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function _(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function S(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o239?4:c>223?3:c>191?2:1;if(o+p<=n)switch(p){case 1:c<128&&(u=c);break;case 2:128==(192&(i=e[o+1]))&&(l=(31&c)<<6|63&i)>127&&(u=l);break;case 3:i=e[o+1],a=e[o+2],128==(192&i)&&128==(192&a)&&(l=(15&c)<<12|(63&i)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:i=e[o+1],a=e[o+2],s=e[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(l=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&l<1114112&&(u=l)}null===u?(u=65533,p=1):u>65535&&(u-=65536,r.push(u>>>10&1023|55296),u=56320|1023&u),r.push(u),o+=p}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var n="",r=0;for(;r0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},l.prototype.compare=function(e,t,n,r,o){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),a=(n>>>=0)-(t>>>=0),s=Math.min(i,a),c=this.slice(r,o),u=e.slice(t,n),p=0;po)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return b(this,e,t,n);case"utf8":case"utf-8":return x(this,e,t,n);case"ascii":return w(this,e,t,n);case"latin1":case"binary":return k(this,e,t,n);case"base64":return O(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;or)&&(n=r);for(var o="",i=t;in)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,n,r,o,i){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function R(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function N(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function L(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(e,t,n,r,i){return i||L(e,0,n,4),o.write(e,t,n,r,23,4),n+4}function D(e,t,n,r,i){return i||L(e,0,n,8),o.write(e,t,n,r,52,8),n+8}l.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(o*=256);)r+=this[e+--t]*o;return r},l.prototype.readUInt8=function(e,t){return t||I(e,1,this.length),this[e]},l.prototype.readUInt16LE=function(e,t){return t||I(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUInt16BE=function(e,t){return t||I(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUInt32LE=function(e,t){return t||I(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUInt32BE=function(e,t){return t||I(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||I(e,t,this.length);for(var r=this[e],o=1,i=0;++i=(o*=128)&&(r-=Math.pow(2,8*t)),r},l.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||I(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},l.prototype.readInt8=function(e,t){return t||I(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){t||I(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt16BE=function(e,t){t||I(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},l.prototype.readInt32LE=function(e,t){return t||I(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return t||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readFloatLE=function(e,t){return t||I(e,4,this.length),o.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return t||I(e,4,this.length),o.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return t||I(e,8,this.length),o.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return t||I(e,8,this.length),o.read(this,e,!1,52,8)},l.prototype.writeUIntLE=function(e,t,n,r){(e=+e,t|=0,n|=0,r)||P(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+o]=e/i&255;return t+n},l.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,255,0),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):N(this,e,t,!0),t+4},l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},l.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=0,a=1,s=0;for(this[t]=255&e;++i>0)-s&255;return t+n},l.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);P(this,e,t,n,o-1,-o)}var i=n-1,a=1,s=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/a>>0)-s&255;return t+n},l.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},l.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},l.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):N(this,e,t,!0),t+4},l.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):N(this,e,t,!1),t+4},l.prototype.writeFloatLE=function(e,t,n){return M(this,e,t,!0,n)},l.prototype.writeFloatBE=function(e,t,n){return M(this,e,t,!1,n)},l.prototype.writeDoubleLE=function(e,t,n){return D(this,e,t,!0,n)},l.prototype.writeDoubleBE=function(e,t,n){return D(this,e,t,!1,n)},l.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else if(i<1e3||!l.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function B(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function $(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}}).call(this,n(6))},function(e,t,n){"use strict";n.d(t,"a",(function(){return g})),n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return h}));var r=n(2),o=n(0);if(!o.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!r.o)throw new Error("mobx-react-lite requires mobx at least version 4 to be available");var i=!1;function a(){return i}
+/*! *****************************************************************************
+Copyright (c) Microsoft Corporation. All rights reserved.
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at http://www.apache.org/licenses/LICENSE-2.0
+
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+MERCHANTABLITY OR NON-INFRINGEMENT.
+
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */var s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function c(e){return e.current?Object(r.h)(e.current):""}var u=[];function p(){var e=l(Object(o.useState)(0),2)[1];return Object(o.useCallback)((function(){e((function(e){return e+1}))}),[])}var f={};function d(e,t,n){if(void 0===t&&(t="observed"),void 0===n&&(n=f),a())return e();var i=(n.useForceUpdate||p)(),s=Object(o.useRef)(null);s.current||(s.current=new r.b("observer("+t+")",(function(){i()})));var l,d,h=function(){s.current&&!s.current.isDisposed&&(s.current.dispose(),s.current=null)};if(Object(o.useDebugValue)(s,c),function(e){Object(o.useEffect)((function(){return e}),u)}((function(){h()})),s.current.track((function(){try{l=e()}catch(e){d=e}})),d)throw h(),d;return l}function h(e,t){if(a())return e;var n,r,i,l=s({forwardRef:!1},t),c=e.displayName||e.name,u=function(t,n){return d((function(){return e(t,n)}),c)};return u.displayName=c,n=l.forwardRef?Object(o.memo)(Object(o.forwardRef)(u)):Object(o.memo)(u),r=e,i=n,Object.keys(r).forEach((function(e){r.hasOwnProperty(e)&&!m[e]&&Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(r,e))})),n.displayName=c,n}var m={$$typeof:!0,render:!0,compare:!0,type:!0};function g(e){var t=e.children,n=e.render,r=t||n;return"function"!=typeof r?null:d(r)}function y(e,t,n,r,o){var i="children"===t?"render":"children",a="function"==typeof e[t],s="function"==typeof e[i];return a&&s?new Error("MobX Observer: Do not use children and render in the same time in`"+n):a||s?null:new Error("Invalid prop `"+o+"` of type `"+typeof e[t]+"` supplied to `"+n+"`, expected `function`.")}g.propTypes={children:y,render:y},g.displayName="Observer"},function(e,t,n){var r=n(18),o=n(102),i=n(20),a=n(54),s=Object.defineProperty;t.f=r?s:function(e,t,n){if(i(e),t=a(t,!0),i(n),o)try{return s(e,t,n)}catch(e){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(4),o=n(34).f,i=n(24),a=n(25),s=n(71),l=n(106),c=n(82);e.exports=function(e,t){var n,u,p,f,d,h=e.target,m=e.global,g=e.stat;if(n=m?r:g?r[h]||s(h,{}):(r[h]||{}).prototype)for(u in t){if(f=t[u],p=e.noTargetGet?(d=o(n,u))&&d.value:n[u],!c(m?u:h+(g?".":"#")+u,e.forced)&&void 0!==p){if(typeof f==typeof p)continue;l(f,p)}(e.sham||p&&p.sham)&&i(f,"sham",!0),a(n,u,f,e)}}},function(e,t,n){var r=n(8);e.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},function(e,t,n){e.exports=n(230)()},function(e,t,n){var r=n(9);e.exports=function(e){if(!r(e))throw TypeError(String(e)+" is not an object");return e}},function(e,t,n){var r;
+/*!
+ Copyright (c) 2017 Jed Watson.
+ Licensed under the MIT License (MIT), see
+ http://jedwatson.github.io/classnames
+*/!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t=0?e.substr(t).toLowerCase():""},t.getHash=function(e){var t=e.indexOf("#");return t>=0?e.substr(t):"#"},t.stripHash=function(e){var t=e.indexOf("#");return t>=0&&(e=e.substr(0,t)),e},t.isHttp=function(e){var t=s.getProtocol(e);return"http"===t||"https"===t||void 0===t&&r.browser},t.isFileSystemPath=function(e){if(r.browser)return!1;var t=s.getProtocol(e);return void 0===t||"file"===t},t.fromFileSystemPath=function(e){o&&(e=e.replace(/\\/g,"/")),e=encodeURI(e);for(var t=0;t2?r:e).apply(void 0,o)}}e.memoize=a,e.debounce=s,e.bind=l,e.default={memoize:a,debounce:s,bind:l}})?r.apply(t,o):r)||(e.exports=i)},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(36),o=n(4),i=function(e){return"function"==typeof e?e:void 0};e.exports=function(e,t){return arguments.length<2?i(r[e])||i(o[e]):r[e]&&r[e][t]||o[e]&&o[e][t]}},function(e,t,n){var r=n(16).f,o=n(11),i=n(5)("toStringTag");e.exports=function(e,t,n){e&&!o(e=n?e:e.prototype,i)&&r(e,i,{configurable:!0,value:t})}},function(e,t,n){"use strict";var r=n(265),o=Array.prototype.slice,i=["name","message","stack"],a=["name","message","description","number","code","fileName","lineNumber","columnNumber","sourceURL","line","column","stack"];function s(t){return function(n,r,i,a){var s=[],p="";"string"==typeof n?(s=o.call(arguments),n=r=void 0):"string"==typeof r?(s=o.call(arguments,1),r=void 0):"string"==typeof i&&(s=o.call(arguments,2)),s.length>0&&(p=e.exports.formatter.apply(null,s)),n&&n.message&&(p+=(p?" \n":"")+n.message);var f=new t(p);return l(f,n),c(f),u(f,r),f}}function l(e,t){!function(e,t){!function(e){if(!m)return!1;var t=Object.getOwnPropertyDescriptor(e,"stack");if(!t)return!1;return"function"==typeof t.get}(e)?e.stack=t?d(e.stack,t.stack):h(e.stack):t?function(e,t){var n=Object.getOwnPropertyDescriptor(e,"stack");Object.defineProperty(e,"stack",{get:function(){return d(n.get.apply(e),t.stack)},enumerable:!1,configurable:!0})}(e,t):(n=e,r=Object.getOwnPropertyDescriptor(n,"stack"),Object.defineProperty(n,"stack",{get:function(){return h(r.get.apply(n))},enumerable:!1,configurable:!0}));var n,r}(e,t),u(e,t)}function c(e){e.toJSON=p,e.inspect=f}function u(e,t){if(t&&"object"==typeof t)for(var n=Object.keys(t),r=0;r=0))try{e[o]=t[o]}catch(e){}}}function p(){var e={},t=Object.keys(this);t=t.concat(a);for(var n=0;n=0)return t.splice(n,1),t.join("\n")}return e}}e.exports=s(Error),e.exports.error=s(Error),e.exports.eval=s(EvalError),e.exports.range=s(RangeError),e.exports.reference=s(ReferenceError),e.exports.syntax=s(SyntaxError),e.exports.type=s(TypeError),e.exports.uri=s(URIError),e.exports.formatter=r;var m=!(!Object.getOwnPropertyDescriptor||!Object.defineProperty||"undefined"!=typeof navigator&&/Android/.test(navigator.userAgent))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},function(e,t,n){var r,o,i,a=n(165),s=n(4),l=n(9),c=n(24),u=n(11),p=n(56),f=n(43),d=s.WeakMap;if(a){var h=new d,m=h.get,g=h.has,y=h.set;r=function(e,t){return y.call(h,e,t),t},o=function(e){return m.call(h,e)||{}},i=function(e){return g.call(h,e)}}else{var v=p("state");f[v]=!0,r=function(e,t){return c(e,v,t),t},o=function(e){return u(e,v)?e[v]:{}},i=function(e){return u(e,v)}}e.exports={set:r,get:o,has:i,enforce:function(e){return i(e)?o(e):r(e,{})},getterFor:function(e){return function(t){var n;if(!l(t)||(n=o(t)).type!==e)throw TypeError("Incompatible receiver, "+e+" required");return n}}}},function(e,t,n){var r=n(18),o=n(77),i=n(42),a=n(35),s=n(54),l=n(11),c=n(102),u=Object.getOwnPropertyDescriptor;t.f=r?u:function(e,t){if(e=a(e),t=s(t,!0),c)try{return u(e,t)}catch(e){}if(l(e,t))return i(!o.f.call(e,t),e[t])}},function(e,t,n){var r=n(78),o=n(44);e.exports=function(e){return r(o(e))}},function(e,t,n){var r=n(4);e.exports=r},function(e,t,n){var r=n(75),o=Math.min;e.exports=function(e){return e>0?o(r(e),9007199254740991):0}},function(e,t,n){"use strict";var r=n(49),o=n(59),i=n(7);function a(e,t,n){var r=[];return e.include.forEach((function(e){n=a(e,t,n)})),e[t].forEach((function(e){n.forEach((function(t,n){t.tag===e.tag&&t.kind===e.kind&&r.push(n)})),n.push(e)})),n.filter((function(e,t){return-1===r.indexOf(t)}))}function s(e){this.include=e.include||[],this.implicit=e.implicit||[],this.explicit=e.explicit||[],this.implicit.forEach((function(e){if(e.loadKind&&"scalar"!==e.loadKind)throw new o("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")})),this.compiledImplicit=a(this,"implicit",[]),this.compiledExplicit=a(this,"explicit",[]),this.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{}};function r(e){n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;ee.length)return;if(!(w instanceof o)){if(m&&b!=t.length-1){if(f.lastIndex=x,!(T=f.exec(e)))break;for(var k=T.index+(h&&T[1]?T[1].length:0),O=T.index+T[0].length,E=b,_=x,S=t.length;E=(_+=t[E].length)&&(++b,x=_);if(t[b]instanceof o)continue;j=E-b,w=e.slice(x,_),T.index-=x}else{f.lastIndex=0;var T=f.exec(w),j=1}if(T){h&&(g=T[1]?T[1].length:0);O=(k=T.index+g)+(T=T[0].slice(g)).length;var C=w.slice(0,k),A=w.slice(O),I=[b,j];C&&(++b,x+=C.length,I.push(C));var P=new o(c,d?r.tokenize(T,d):T,y,T,m);if(I.push(P),A&&I.push(A),Array.prototype.splice.apply(t,I),1!=j&&r.matchGrammar(e,t,n,b,x,!0,c+","+p),s)break}else if(s)break}}}}},tokenize:function(e,t){var n=[e],o=t.rest;if(o){for(var i in o)t[i]=o[i];delete t.rest}return r.matchGrammar(e,n,t,0,0,!1),n},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var o,i=0;o=n[i++];)o(t)}},Token:o};function o(e,t,n,r,o){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length,this.greedy=!!o}if(e.Prism=r,o.stringify=function(e,t){if("string"==typeof e)return e;if(Array.isArray(e))return e.map((function(e){return o.stringify(e,t)})).join("");var n={type:e.type,content:o.stringify(e.content,t),tag:"span",classes:["token",e.type],attributes:{},language:t};if(e.alias){var i=Array.isArray(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(n.classes,i)}r.hooks.run("wrap",n);var a=Object.keys(n.attributes).map((function(e){return e+'="'+(n.attributes[e]||"").replace(/"/g,""")+'"'})).join(" ");return"<"+n.tag+' class="'+n.classes.join(" ")+'"'+(a?" "+a:"")+">"+n.content+""+n.tag+">"},!e.document)return e.addEventListener?(r.disableWorkerMessageHandler||e.addEventListener("message",(function(t){var n=JSON.parse(t.data),o=n.language,i=n.code,a=n.immediateClose;e.postMessage(r.highlight(i,r.languages[o],o)),a&&e.close()}),!1),r):r;var i=r.util.currentScript();if(i&&(r.filename=i.src,i.hasAttribute("data-manual")&&(r.manual=!0)),!r.manual){function a(){r.manual||r.highlightAll()}var s=document.readyState;"loading"===s||"interactive"===s&&i&&i.defer?document.addEventListener("DOMContentLoaded",a):window.requestAnimationFrame?window.requestAnimationFrame(a):window.setTimeout(a,16)}return r}("undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{});e.exports&&(e.exports=n),void 0!==t&&(t.Prism=n),n.languages.markup={comment://,prolog:/<\?[\s\S]+?\?>/,doctype:{pattern:/"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:(?!)*\]\s*)?>/i,greedy:!0},cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i,inside:{punctuation:[/^=/,{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/?[\da-z]{1,8};/i},n.languages.markup.tag.inside["attr-value"].inside.entity=n.languages.markup.entity,n.hooks.add("wrap",(function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))})),Object.defineProperty(n.languages.markup.tag,"addInlined",{value:function(e,t){var r={};r["language-"+t]={pattern:/(^$)/i,lookbehind:!0,inside:n.languages[t]},r.cdata=/^$/i;var o={"included-cdata":{pattern://i,inside:r}};o["language-"+t]={pattern:/[\s\S]+/,inside:n.languages[t]};var i={};i[e]={pattern:RegExp(/(<__[\s\S]*?>)(?:\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g,e),"i"),lookbehind:!0,greedy:!0,inside:o},n.languages.insertBefore("markup","cdata",i)}}),n.languages.xml=n.languages.extend("markup",{}),n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,function(e){var t=/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:/@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/,inside:{rule:/@[\w-]+/}},url:{pattern:RegExp("url\\((?:"+t.source+"|[^\n\r()]*)\\)","i"),inside:{function:/^url/i,punctuation:/^\(|\)$/}},selector:RegExp("[^{}\\s](?:[^{};\"']|"+t.source+")*?(?=\\s*\\{)"),string:{pattern:t,greedy:!0},property:/[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,important:/!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined("style","css"),e.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:n.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:e.languages.css}},alias:"language-css"}},n.tag))}(n),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|interface|extends|implements|trait|instanceof|new)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(?:true|false)\b/,function:/\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{"class-name":[n.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,lookbehind:!0}],keyword:[{pattern:/((?:^|})\s*)(?:catch|finally)\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],number:/\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/,function:/#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,operator:/--|\+\+|\*\*=?|=>|&&|\|\||[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?[.?]?|[~:]/}),n.languages.javascript["class-name"][0].pattern=/(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/,n.languages.insertBefore("javascript","keyword",{regex:{pattern:/((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=(?:\s|\/\*[\s\S]*?\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,lookbehind:!0,greedy:!0},"function-variable":{pattern:/#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,lookbehind:!0,inside:n.languages.javascript},{pattern:/[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,inside:n.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,lookbehind:!0,inside:n.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,lookbehind:!0,inside:n.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),n.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\${|}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}}}),n.languages.markup&&n.languages.markup.tag.addInlined("script","javascript"),n.languages.js=n.languages.javascript,"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(e){e=e||document;var t={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.slice.call(e.querySelectorAll("pre[data-src]")).forEach((function(e){if(!e.hasAttribute("data-src-loaded")){for(var r,o=e.getAttribute("data-src"),i=e,a=/\blang(?:uage)?-([\w-]+)\b/i;i&&!a.test(i.className);)i=i.parentNode;if(i&&(r=(e.className.match(a)||[,""])[1]),!r){var s=(o.match(/\.(\w+)$/)||[,""])[1];r=t[s]||s}var l=document.createElement("code");l.className="language-"+r,e.textContent="",l.textContent="Loading…",e.appendChild(l);var c=new XMLHttpRequest;c.open("GET",o,!0),c.onreadystatechange=function(){4==c.readyState&&(c.status<400&&c.responseText?(l.textContent=c.responseText,n.highlightElement(l),e.setAttribute("data-src-loaded","")):c.status>=400?l.textContent="✖ Error "+c.status+" while fetching file: "+c.statusText:l.textContent="✖ Error: File does not exist or is empty")},c.send(null)}}))},document.addEventListener("DOMContentLoaded",(function(){self.Prism.fileHighlight()})))}).call(this,n(6))},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t){e.exports={}},function(e,t){e.exports=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e}},function(e,t,n){var r=n(44);e.exports=function(e){return Object(r(e))}},function(e,t){e.exports={}},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(String(e)+" is not a function");return e}},function(e,t,n){var r=n(47);e.exports=function(e,t,n){if(r(e),void 0===t)return e;switch(n){case 0:return function(){return e.call(t)};case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,o){return e.call(t,n,r,o)}}return function(){return e.apply(t,arguments)}}},function(e,t,n){"use strict";function r(e){return null==e}e.exports.isNothing=r,e.exports.isObject=function(e){return"object"==typeof e&&null!==e},e.exports.toArray=function(e){return Array.isArray(e)?e:r(e)?[]:[e]},e.exports.repeat=function(e,t){var n,r="";for(n=0;n=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r=-1&&!o;i--){var a=i>=0?arguments[i]:e.cwd();if("string"!=typeof a)throw new TypeError("Arguments to path.resolve must be strings");a&&(t=a+"/"+t,o="/"===a.charAt(0))}return(o?"/":"")+(t=n(r(t.split("/"),(function(e){return!!e})),!o).join("/"))||"."},t.normalize=function(e){var i=t.isAbsolute(e),a="/"===o(e,-1);return(e=n(r(e.split("/"),(function(e){return!!e})),!i).join("/"))||i||(e="."),e&&a&&(e+="/"),(i?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(r(e,(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))},t.relative=function(e,n){function r(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=t.resolve(e).substr(1),n=t.resolve(n).substr(1);for(var o=r(e.split("/")),i=r(n.split("/")),a=Math.min(o.length,i.length),s=a,l=0;l=1;--i)if(47===(t=e.charCodeAt(i))){if(!o){r=i;break}}else o=!1;return-1===r?n?"/":".":n&&1===r?"/":e.slice(0,r)},t.basename=function(e,t){var n=function(e){"string"!=typeof e&&(e+="");var t,n=0,r=-1,o=!0;for(t=e.length-1;t>=0;--t)if(47===e.charCodeAt(t)){if(!o){n=t+1;break}}else-1===r&&(o=!1,r=t+1);return-1===r?"":e.slice(n,r)}(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},t.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,r=-1,o=!0,i=0,a=e.length-1;a>=0;--a){var s=e.charCodeAt(a);if(47!==s)-1===r&&(o=!1,r=a+1),46===s?-1===t?t=a:1!==i&&(i=1):-1!==t&&(i=-1);else if(!o){n=a+1;break}}return-1===t||-1===r||0===i||1===i&&t===r-1&&t===n+1?"":e.slice(t,r)};var o="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return t<0&&(t=e.length+t),e.substr(t,n)}}).call(this,n(13))},function(e,t,n){(function(t){!function(t){"use strict";var n={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:/^ {0,3}(`{3,}|~{3,})([^`~\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?\\?>\\n*|\\n*|\\n*|?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:g,table:g,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html)[^\n]+)*)/,text:/^[^\n]+/};function r(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||k.defaults,this.rules=n.normal,this.options.pedantic?this.rules=n.pedantic:this.options.gfm&&(this.rules=n.gfm)}n._label=/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,n._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,n.def=f(n.def).replace("label",n._label).replace("title",n._title).getRegex(),n.bullet=/(?:[*+-]|\d{1,9}\.)/,n.item=/^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/,n.item=f(n.item,"gm").replace(/bull/g,n.bullet).getRegex(),n.list=f(n.list).replace(/bull/g,n.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+n.def.source+")").getRegex(),n._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",n._comment=//,n.html=f(n.html,"i").replace("comment",n._comment).replace("tag",n._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),n.paragraph=f(n._paragraph).replace("hr",n.hr).replace("heading"," {0,3}#{1,6} +").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}|~{3,})[^`\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|!--)").replace("tag",n._tag).getRegex(),n.blockquote=f(n.blockquote).replace("paragraph",n.paragraph).getRegex(),n.normal=y({},n),n.gfm=y({},n.normal,{nptable:/^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,table:/^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/}),n.pedantic=y({},n.normal,{html:f("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?\\1> *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",n._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,fences:g,paragraph:f(n.normal._paragraph).replace("hr",n.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",n.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()}),r.rules=n,r.lex=function(e,t){return new r(t).lex(e)},r.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},r.prototype.token=function(e,t){var r,o,i,a,s,l,c,p,f,d,h,m,g,y,x,w;for(e=e.replace(/^ +$/gm,"");e;)if((i=this.rules.newline.exec(e))&&(e=e.substring(i[0].length),i[0].length>1&&this.tokens.push({type:"space"})),i=this.rules.code.exec(e)){var k=this.tokens[this.tokens.length-1];e=e.substring(i[0].length),k&&"paragraph"===k.type?k.text+="\n"+i[0].trimRight():(i=i[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",codeBlockStyle:"indented",text:this.options.pedantic?i:b(i,"\n")}))}else if(i=this.rules.fences.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"code",lang:i[2]?i[2].trim():i[2],text:i[3]||""});else if(i=this.rules.heading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:i[1].length,text:i[2]});else if((i=this.rules.nptable.exec(e))&&(l={type:"table",header:v(i[1].replace(/^ *| *\| *$/g,"")),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3]?i[3].replace(/\n$/,"").split("\n"):[]}).header.length===l.align.length){for(e=e.substring(i[0].length),h=0;h ?/gm,""),this.token(i,t),this.tokens.push({type:"blockquote_end"});else if(i=this.rules.list.exec(e)){for(e=e.substring(i[0].length),c={type:"list_start",ordered:y=(a=i[2]).length>1,start:y?+a:"",loose:!1},this.tokens.push(c),p=[],r=!1,g=(i=i[0].match(this.rules.item)).length,h=0;h1?1===s.length:s.length>1||this.options.smartLists&&s!==a)&&(e=i.slice(h+1).join("\n")+e,h=g-1)),o=r||/\n\n(?!\s*$)/.test(l),h!==g-1&&(r="\n"===l.charAt(l.length-1),o||(o=r)),o&&(c.loose=!0),w=void 0,(x=/^\[[ xX]\] /.test(l))&&(w=" "!==l[1],l=l.replace(/^\[[ xX]\] +/,"")),f={type:"list_item_start",task:x,checked:w,loose:o},p.push(f),this.tokens.push(f),this.token(l,!1),this.tokens.push({type:"list_item_end"});if(c.loose)for(g=p.length,h=0;h?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:g,tag:"^comment|^[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,strong:/^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,em:/^_([^\s_])_(?!_)|^\*([^\s*<\[])\*(?!\*)|^_([^\s<][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_<][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s<"][\s\S]*?[^\s\*])\*(?!\*|[^\spunctuation])|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:g,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\?@\\[^_{|}~",o.em=f(o.em).replace(/punctuation/g,o._punctuation).getRegex(),o._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,o._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,o._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,o.autolink=f(o.autolink).replace("scheme",o._scheme).replace("email",o._email).getRegex(),o._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,o.tag=f(o.tag).replace("comment",n._comment).replace("attribute",o._attribute).getRegex(),o._label=/(?:\[[^\[\]]*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,o._href=/<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*/,o._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,o.link=f(o.link).replace("label",o._label).replace("href",o._href).replace("title",o._title).getRegex(),o.reflink=f(o.reflink).replace("label",o._label).getRegex(),o.normal=y({},o),o.pedantic=y({},o.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,link:f(/^!?\[(label)\]\((.*?)\)/).replace("label",o._label).getRegex(),reflink:f(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",o._label).getRegex()}),o.gfm=y({},o.normal,{escape:f(o.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^~+(?=\S)([\s\S]*?\S)~+/,text:/^(`+|[^`])(?:[\s\S]*?(?:(?=[\\/i.test(a[0])&&(this.inLink=!1),!this.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(a[0])?this.inRawBlock=!0:this.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(a[0])&&(this.inRawBlock=!1),e=e.substring(a[0].length),l+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(a[0]):u(a[0]):a[0];else if(a=this.rules.link.exec(e)){var c=x(a[2],"()");if(c>-1){var p=4+a[1].length+c;a[2]=a[2].substring(0,c),a[0]=a[0].substring(0,p).trim(),a[3]=""}e=e.substring(a[0].length),this.inLink=!0,r=a[2],this.options.pedantic?(t=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(r))?(r=t[1],o=t[3]):o="":o=a[3]?a[3].slice(1,-1):"",r=r.trim().replace(/^<([\s\S]*)>$/,"$1"),l+=this.outputLink(a,{href:i.escapes(r),title:i.escapes(o)}),this.inLink=!1}else if((a=this.rules.reflink.exec(e))||(a=this.rules.nolink.exec(e))){if(e=e.substring(a[0].length),t=(a[2]||a[1]).replace(/\s+/g," "),!(t=this.links[t.toLowerCase()])||!t.href){l+=a[0].charAt(0),e=a[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(a,t),this.inLink=!1}else if(a=this.rules.strong.exec(e))e=e.substring(a[0].length),l+=this.renderer.strong(this.output(a[4]||a[3]||a[2]||a[1]));else if(a=this.rules.em.exec(e))e=e.substring(a[0].length),l+=this.renderer.em(this.output(a[6]||a[5]||a[4]||a[3]||a[2]||a[1]));else if(a=this.rules.code.exec(e))e=e.substring(a[0].length),l+=this.renderer.codespan(u(a[2].trim(),!0));else if(a=this.rules.br.exec(e))e=e.substring(a[0].length),l+=this.renderer.br();else if(a=this.rules.del.exec(e))e=e.substring(a[0].length),l+=this.renderer.del(this.output(a[1]));else if(a=this.rules.autolink.exec(e))e=e.substring(a[0].length),r="@"===a[2]?"mailto:"+(n=u(this.mangle(a[1]))):n=u(a[1]),l+=this.renderer.link(r,null,n);else if(this.inLink||!(a=this.rules.url.exec(e))){if(a=this.rules.text.exec(e))e=e.substring(a[0].length),this.inRawBlock?l+=this.renderer.text(this.options.sanitize?this.options.sanitizer?this.options.sanitizer(a[0]):u(a[0]):a[0]):l+=this.renderer.text(u(this.smartypants(a[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else{if("@"===a[2])r="mailto:"+(n=u(a[0]));else{do{s=a[0],a[0]=this.rules._backpedal.exec(a[0])[0]}while(s!==a[0]);n=u(a[0]),r="www."===a[1]?"http://"+n:n}e=e.substring(a[0].length),l+=this.renderer.link(r,null,n)}return l},i.escapes=function(e){return e?e.replace(i.rules._escapes,"$1"):e},i.prototype.outputLink=function(e,t){var n=t.href,r=t.title?u(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,u(e[1]))},i.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},i.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,o=0;o.5&&(t="x"+t.toString(16)),n+=""+t+";";return n},a.prototype.code=function(e,t,n){var r=(t||"").match(/\S*/)[0];if(this.options.highlight){var o=this.options.highlight(e,r);null!=o&&o!==e&&(n=!0,e=o)}return r?''+(n?e:u(e,!0))+"
\n":""+(n?e:u(e,!0))+"
"},a.prototype.blockquote=function(e){return"\n"+e+"
\n"},a.prototype.html=function(e){return e},a.prototype.heading=function(e,t,n,r){return this.options.headerIds?"\n":""+e+"\n"},a.prototype.hr=function(){return this.options.xhtml?"
\n":"
\n"},a.prototype.list=function(e,t,n){var r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+""+r+">\n"},a.prototype.listitem=function(e){return""+e+"\n"},a.prototype.checkbox=function(e){return" "},a.prototype.paragraph=function(e){return""+e+"
\n"},a.prototype.table=function(e,t){return t&&(t=""+t+""),"\n"},a.prototype.tablerow=function(e){return"\n"+e+"
\n"},a.prototype.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' align="'+t.align+'">':"<"+n+">")+e+""+n+">\n"},a.prototype.strong=function(e){return""+e+""},a.prototype.em=function(e){return""+e+""},a.prototype.codespan=function(e){return""+e+""},a.prototype.br=function(){return this.options.xhtml?"
":"
"},a.prototype.del=function(e){return""+e+""},a.prototype.link=function(e,t,n){if(null===(e=d(this.options.sanitize,this.options.baseUrl,e)))return n;var r='"+n+""},a.prototype.image=function(e,t,n){if(null===(e=d(this.options.sanitize,this.options.baseUrl,e)))return n;var r='
":">"},a.prototype.text=function(e){return e},s.prototype.strong=s.prototype.em=s.prototype.codespan=s.prototype.del=s.prototype.text=function(e){return e},s.prototype.link=s.prototype.image=function(e,t,n){return""+n},s.prototype.br=function(){return""},l.parse=function(e,t){return new l(t).parse(e)},l.prototype.parse=function(e){this.inline=new i(e.links,this.options),this.inlineText=new i(e.links,y({},this.options,{renderer:new s})),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t},l.prototype.next=function(){return this.token=this.tokens.pop(),this.token},l.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},l.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},l.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,p(this.inlineText.output(this.token.text)),this.slugger);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,o="",i="";for(n="",e=0;e?@[\]^`{|}~]/g,"").replace(/\s/g,"-");if(this.seen.hasOwnProperty(t)){var n=t;do{this.seen[n]++,t=n+"-"+this.seen[n]}while(this.seen.hasOwnProperty(t))}return this.seen[t]=0,t},u.escapeTest=/[&<>"']/,u.escapeReplace=/[&<>"']/g,u.replacements={"&":"&","<":"<",">":">",'"':""","'":"'"},u.escapeTestNoEncode=/[<>"']|&(?!#?\w+;)/,u.escapeReplaceNoEncode=/[<>"']|&(?!#?\w+;)/g;var h={},m=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function g(){}function y(e){for(var t,n,r=1;r=0&&"\\"===n[o];)r=!r;return r?"|":" |"})).split(/ \|/),r=0;if(n.length>t)n.splice(t);else for(;n.lengthAn error occurred:
"+u(e.message+"",!0)+"
";throw e}}g.exec=g,k.options=k.setOptions=function(e){return y(k.defaults,e),k},k.getDefaults=function(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:new a,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,xhtml:!1}},k.defaults=k.getDefaults(),k.Parser=l,k.parser=l.parse,k.Renderer=a,k.TextRenderer=s,k.Lexer=r,k.lexer=r.lex,k.InlineLexer=i,k.inlineLexer=i.output,k.Slugger=c,k.parse=k,e.exports=k}(this||"undefined"!=typeof window&&window)}).call(this,n(6))},function(e,t,n){var r=n(9);e.exports=function(e,t){if(!r(e))return e;var n,o;if(t&&"function"==typeof(n=e.toString)&&!r(o=n.call(e)))return o;if("function"==typeof(n=e.valueOf)&&!r(o=n.call(e)))return o;if(!t&&"function"==typeof(n=e.toString)&&!r(o=n.call(e)))return o;throw TypeError("Can't convert object to primitive value")}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return"Symbol("+String(void 0===e?"":e)+")_"+(++n+r).toString(36)}},function(e,t,n){var r=n(70),o=n(55),i=r("keys");e.exports=function(e){return i[e]||(i[e]=o(e))}},function(e,t,n){var r,o=n(20),i=n(173),a=n(80),s=n(43),l=n(110),c=n(72),u=n(56),p=u("IE_PROTO"),f=function(){},d=function(e){return"