Skip to content

Commit 80dee3d

Browse files
authored
Merge pull request #238 from GispoCoding/Fix_lambda_libraries
Fix lambda libraries
2 parents da2dfd6 + 559d30c commit 80dee3d

12 files changed

+721
-125
lines changed

.pre-commit-config.yaml

+51-51
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
exclude: ".enc.json$"
2-
repos:
3-
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.1.0
5-
hooks:
6-
- id: check-yaml
7-
- id: end-of-file-fixer
8-
- id: trailing-whitespace
9-
- id: mixed-line-ending
10-
- repo: https://github.com/pre-commit/mirrors-eslint
11-
rev: v8.5.0
12-
hooks:
13-
- id: eslint
14-
additional_dependencies:
15-
16-
17-
18-
19-
20-
21-
22-
- "@typescript-eslint/[email protected]"
23-
- "@typescript-eslint/[email protected]"
24-
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
25-
types: [file]
26-
- repo: https://github.com/pre-commit/mirrors-prettier
27-
rev: v2.5.1
28-
hooks:
29-
- id: prettier
30-
types_or: [css, javascript]
31-
- repo: https://github.com/PyCQA/isort
32-
rev: 5.10.1
33-
hooks:
34-
- id: isort
35-
- repo: https://github.com/psf/black
36-
rev: 22.3.0
37-
hooks:
38-
- id: black
39-
- repo: https://github.com/pre-commit/mirrors-mypy
40-
rev: v0.910-1
41-
hooks:
42-
- id: mypy
43-
additional_dependencies:
44-
- types-requests
45-
- repo: https://github.com/PyCQA/flake8
46-
rev: 4.0.1
47-
hooks:
48-
- id: flake8
49-
additional_dependencies:
50-
- flake8-bugbear~=21.9.2
51-
- pep8-naming~=0.12.1
1+
exclude: ".enc.json$"
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.1.0
5+
hooks:
6+
- id: check-yaml
7+
- id: end-of-file-fixer
8+
- id: trailing-whitespace
9+
- id: mixed-line-ending
10+
- repo: https://github.com/pre-commit/mirrors-eslint
11+
rev: v8.5.0
12+
hooks:
13+
- id: eslint
14+
additional_dependencies:
15+
16+
17+
18+
19+
20+
21+
22+
- "@typescript-eslint/[email protected]"
23+
- "@typescript-eslint/[email protected]"
24+
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
25+
types: [file]
26+
- repo: https://github.com/pre-commit/mirrors-prettier
27+
rev: v2.5.1
28+
hooks:
29+
- id: prettier
30+
types_or: [css, javascript]
31+
- repo: https://github.com/PyCQA/isort
32+
rev: 5.12.0
33+
hooks:
34+
- id: isort
35+
- repo: https://github.com/psf/black
36+
rev: 22.3.0
37+
hooks:
38+
- id: black
39+
- repo: https://github.com/pre-commit/mirrors-mypy
40+
rev: v0.910-1
41+
hooks:
42+
- id: mypy
43+
additional_dependencies:
44+
- types-requests
45+
- repo: https://github.com/PyCQA/flake8
46+
rev: 4.0.1
47+
hooks:
48+
- id: flake8
49+
additional_dependencies:
50+
- flake8-bugbear~=21.9.2
51+
- pep8-naming~=0.12.1

backend/arcgis.Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
FROM public.ecr.aws/lambda/python:3.8
2-
1+
FROM public.ecr.aws/lambda/python:3.10
32
# common code
43
COPY lambda_functions/base_loader/__init__.py ${LAMBDA_TASK_ROOT}/app/__init__.py
54
COPY lambda_functions/base_loader/base_loader.py ${LAMBDA_TASK_ROOT}/app/base_loader.py
65
# common deps
76
RUN pip3 install \
87
psycopg2-binary \
98
geoalchemy2 \
9+
sqlalchemy==1.4 \
1010
requests \
1111
shapely==1.8.0 \
12+
urllib3==1.26 \
1213
--target "${LAMBDA_TASK_ROOT}"
1314

1415
# this code

backend/db_manager.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/lambda/python:3.8
1+
FROM public.ecr.aws/lambda/python:3.10
22

33
# Copy function code
44
COPY lambda_functions/db_manager/db_manager.py ${LAMBDA_TASK_ROOT}/db_manager.py

backend/lambda_functions/lipas_loader/lipas_loader.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import time
12
from typing import Any, Dict, List, Optional, Tuple
23

34
import requests
@@ -50,6 +51,7 @@ def __init__(
5051
**kwargs,
5152
) -> None:
5253
super().__init__(connection_string, **kwargs)
54+
self.feature_counter: int = 0 # Sorry but this had to be done :-)
5355

5456
self.type_codes_all_year = (
5557
type_codes_all_year
@@ -86,7 +88,6 @@ def get_features(self, only_page: Optional[int] = None) -> List[int]: # type: i
8688
r = requests.get(url, params=params, headers=self.HEADERS)
8789
r.raise_for_status()
8890
data = r.json()
89-
9091
if data:
9192
ids += [item[ID_FIELD] for item in data if "location" in item]
9293
current_page += 1
@@ -160,7 +161,10 @@ def get_feature(self, sports_place_id: int): # type: ignore[override]
160161
"deleted": False,
161162
"tarmo_category": tarmo_category,
162163
}
163-
164+
# LOGGER.info(f"Features loaded: {len(flattened)}")
165+
self.feature_counter = self.feature_counter + 1
166+
if self.feature_counter % 10 == 0:
167+
time.sleep(1)
164168
return flattened
165169

166170
def save_feature(self, sport_place: Dict[str, Any], session: Session) -> bool:
@@ -218,7 +222,7 @@ def _sport_places_url_and_params(self, page: int) -> Tuple[str, Dict[str, Any]]:
218222
return main_url, params
219223

220224
def _sport_place_url(self, sports_place_id: int):
221-
print(self.api_url)
225+
# print(self.api_url)
222226
return "/".join((self.api_url, LipasLoader.SPORT_PLACES, str(sports_place_id)))
223227

224228

backend/lipas.Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/lambda/python:3.8
1+
FROM public.ecr.aws/lambda/python:3.10
22

33
# common code
44
COPY lambda_functions/base_loader/__init__.py ${LAMBDA_TASK_ROOT}/app/__init__.py
@@ -7,8 +7,10 @@ COPY lambda_functions/base_loader/base_loader.py ${LAMBDA_TASK_ROOT}/app/base_lo
77
RUN pip3 install \
88
psycopg2-binary \
99
geoalchemy2 \
10+
sqlalchemy==1.4 \
1011
requests \
1112
shapely==1.8.0 \
13+
urllib3==1.26 \
1214
--target "${LAMBDA_TASK_ROOT}"
1315

1416
# this code

backend/notifier.Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
FROM public.ecr.aws/lambda/python:3.8
1+
FROM public.ecr.aws/lambda/python:3.10
22

33
# Copy function code
44
COPY lambda_functions/notifier/notifier.py ${LAMBDA_TASK_ROOT}/app/notifier.py
55

66
RUN pip3 install \
77
requests \
8+
urllib3==1.26 \
89
--target "${LAMBDA_TASK_ROOT}"
910

1011
CMD [ "app.notifier.handler" ]

backend/osm.Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/lambda/python:3.8
1+
FROM public.ecr.aws/lambda/python:3.10
22

33
# common code
44
COPY lambda_functions/base_loader/__init__.py ${LAMBDA_TASK_ROOT}/app/__init__.py
@@ -7,8 +7,10 @@ COPY lambda_functions/base_loader/base_loader.py ${LAMBDA_TASK_ROOT}/app/base_lo
77
RUN pip3 install \
88
psycopg2-binary \
99
geoalchemy2 \
10+
sqlalchemy==1.4 \
1011
requests \
1112
shapely==1.8.0 \
13+
urllib3==1.26 \
1214
--target "${LAMBDA_TASK_ROOT}"
1315

1416
# this code

backend/wfs.Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/lambda/python:3.8
1+
FROM public.ecr.aws/lambda/python:3.10
22

33
# common code
44
COPY lambda_functions/base_loader/__init__.py ${LAMBDA_TASK_ROOT}/app/__init__.py
@@ -7,8 +7,10 @@ COPY lambda_functions/base_loader/base_loader.py ${LAMBDA_TASK_ROOT}/app/base_lo
77
RUN pip3 install \
88
psycopg2-binary \
99
geoalchemy2 \
10+
sqlalchemy==1.4 \
1011
requests \
1112
shapely==1.8.0 \
13+
urllib3==1.26 \
1214
--target "${LAMBDA_TASK_ROOT}"
1315

1416
# this code

requirements-dev.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
2-
# This file is autogenerated by pip-compile with python 3.10
3-
# To update, run:
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
44
#
55
# pip-compile requirements-dev.in
66
#

requirements.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
2-
# This file is autogenerated by pip-compile with python 3.10
3-
# To update, run:
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
44
#
55
# pip-compile requirements.in
66
#
@@ -14,7 +14,7 @@ charset-normalizer==2.0.10
1414
# requests
1515
geoalchemy2==0.10.0
1616
# via -r requirements.in
17-
greenlet==1.1.2
17+
greenlet==2.0.2
1818
# via sqlalchemy
1919
idna==3.3
2020
# via requests
@@ -34,7 +34,7 @@ python-slugify==6.1.1
3434
# via -r requirements.in
3535
requests==2.27.0
3636
# via -r requirements.in
37-
shapely==1.8.0
37+
shapely==1.8.5
3838
# via -r requirements.in
3939
sqlalchemy==1.4.29
4040
# via

0 commit comments

Comments
 (0)