Skip to content

Commit 00d0cce

Browse files
committed
change test
1 parent 0b2175b commit 00d0cce

File tree

13 files changed

+78
-29
lines changed

13 files changed

+78
-29
lines changed

mapswipe_workers/.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
repos:
33
- repo: https://github.com/psf/black
4-
rev: 19.10b0
4+
rev: 22.3.0
55
hooks:
66
- id: black
77
- repo: https://gitlab.com/pycqa/flake8

mapswipe_workers/mapswipe_workers/generate_stats/project_stats.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ def get_agg_results_by_task_id(
335335
# add task geometry using left join
336336
tasks_df.drop(columns=["project_id", "group_id"], inplace=True)
337337
agg_results_df = results_by_task_id_df.merge(
338-
tasks_df, left_on="task_id", right_on="task_id",
338+
tasks_df,
339+
left_on="task_id",
340+
right_on="task_id",
339341
)
340342
logger.info("added geometry to aggregated results")
341343

mapswipe_workers/mapswipe_workers/mapswipe_workers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ def run_create_tutorials() -> None:
331331

332332
@cli.command("archive")
333333
@click.option(
334-
"--project-id", "-i", help=("Archive project with giving project id"), type=str,
334+
"--project-id",
335+
"-i",
336+
help=("Archive project with giving project id"),
337+
type=str,
335338
)
336339
@click.option(
337340
"--project-ids",
@@ -359,7 +362,10 @@ def run_archive_project(project_id, project_ids):
359362

360363
@cli.command("delete")
361364
@click.option(
362-
"--project-id", "-i", help=("Delete project with giving project id"), type=str,
365+
"--project-id",
366+
"-i",
367+
help=("Delete project with giving project id"),
368+
type=str,
363369
)
364370
@click.option(
365371
"--project-ids",

mapswipe_workers/mapswipe_workers/project_types/arbitrary_geometry/group.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ class Group(BaseGroup):
88
def __init__(self, project: object, groupId: int) -> None:
99
super().__init__(project, groupId)
1010

11-
def create_tasks(self, feature_ids: List, features: List,) -> None:
11+
def create_tasks(
12+
self,
13+
feature_ids: List,
14+
features: List,
15+
) -> None:
1216
"""Create tasks for a group
1317
1418
feature_geometries is a list of geometries or feature in geojson format.

mapswipe_workers/mapswipe_workers/project_types/arbitrary_geometry/task.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
class Task(BaseTask):
99
def __init__(
10-
self, group: object, featureId: Union[int, str], feature: Dict,
10+
self,
11+
group: object,
12+
featureId: Union[int, str],
13+
feature: Dict,
1114
):
1215
"""
1316
Parameters

mapswipe_workers/mapswipe_workers/project_types/base/project.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ def save_project(self):
136136
# Make sure projects get saved in Postgres and Firebase successful
137137
try:
138138
self.save_to_postgres(
139-
project, groups, groupsOfTasks,
139+
project,
140+
groups,
141+
groupsOfTasks,
140142
)
141143
logger.info(
142144
f"{self.projectId}" f" - the project has been saved" f" to postgres"
@@ -168,7 +170,9 @@ def save_project(self):
168170

169171
try:
170172
self.save_to_firebase(
171-
project, groups, groupsOfTasks,
173+
project,
174+
groups,
175+
groupsOfTasks,
172176
)
173177
logger.info(
174178
f"{self.projectId}" f" - the project has been saved" f" to firebase"
@@ -493,7 +497,10 @@ def create_groups_txt_file(self, groups):
493497
"project_type_specifics",
494498
)
495499
w = csv.DictWriter(
496-
groups_txt_file, fieldnames=fieldnames, delimiter="\t", quotechar="'",
500+
groups_txt_file,
501+
fieldnames=fieldnames,
502+
delimiter="\t",
503+
quotechar="'",
497504
)
498505

499506
for groupId, group in groups.items():
@@ -575,7 +582,10 @@ def create_tasks_txt_file(self, groupsOfTasks):
575582
"project_type_specifics",
576583
)
577584
w = csv.DictWriter(
578-
tasks_txt_file, fieldnames=fieldnames, delimiter="\t", quotechar="'",
585+
tasks_txt_file,
586+
fieldnames=fieldnames,
587+
delimiter="\t",
588+
quotechar="'",
579589
)
580590

581591
for groupId, tasks in groupsOfTasks.items():

mapswipe_workers/mapswipe_workers/utils/geojson_functions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ def create_geojson_file_from_dict(final_groups_dict, outfile):
206206

207207
dataSource = driver.CreateDataSource(outfile_temp)
208208
# create layer
209-
layer = dataSource.CreateLayer(outfile_temp, srs, geom_type=ogr.wkbPolygon,)
209+
layer = dataSource.CreateLayer(
210+
outfile_temp,
211+
srs,
212+
geom_type=ogr.wkbPolygon,
213+
)
210214

211215
# create fields
212216
field_id = ogr.FieldDefn("group_id", ogr.OFTInteger)
@@ -295,7 +299,11 @@ def create_geojson_file(geometries, outfile):
295299

296300
dataSource = driver.CreateDataSource(outfile_temp)
297301
# create layer
298-
layer = dataSource.CreateLayer(outfile_temp, srs, geom_type=ogr.wkbPolygon,)
302+
layer = dataSource.CreateLayer(
303+
outfile_temp,
304+
srs,
305+
geom_type=ogr.wkbPolygon,
306+
)
299307

300308
# create fields
301309
field_id = ogr.FieldDefn("id", ogr.OFTInteger)

mapswipe_workers/mapswipe_workers/utils/tile_functions.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ def tile_coords_zoom_and_tileserver_to_url(
9696
# https://www.maptiler.com/google-maps-coordinates-tile-bounds-projection/
9797
tile_y = int(math.pow(2, tile_z) - tile_y) - 1
9898
url = tile_server["url"].format(
99-
key=tile_server["apiKey"], x=tile_x, y=tile_y, z=tile_z,
99+
key=tile_server["apiKey"],
100+
x=tile_x,
101+
y=tile_y,
102+
z=tile_z,
100103
)
101104
elif "{-y}" in tile_server["url"]:
102105
# this uses not the standard TMS tile y coordinate,
@@ -105,10 +108,18 @@ def tile_coords_zoom_and_tileserver_to_url(
105108
# https://www.maptiler.com/google-maps-coordinates-tile-bounds-projection/
106109
tile_y = int(math.pow(2, tile_z) - tile_y) - 1
107110
url = tile_server["url"].replace("{-y}", "{y}")
108-
url = url.format(key=tile_server["apiKey"], x=tile_x, y=tile_y, z=tile_z,)
111+
url = url.format(
112+
key=tile_server["apiKey"],
113+
x=tile_x,
114+
y=tile_y,
115+
z=tile_z,
116+
)
109117
else:
110118
url = tile_server["url"].format(
111-
key=tile_server["apiKey"], x=tile_x, y=tile_y, z=tile_z,
119+
key=tile_server["apiKey"],
120+
x=tile_x,
121+
y=tile_y,
122+
z=tile_z,
112123
)
113124

114125
return url

mapswipe_workers/python_scripts/update_project_status.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def run_update_project_status(filter_string: str) -> None:
5858
logger.info("### Start update project status workflow ###")
5959
active_projects = get_projects(status="active")
6060
finished_projects = filter_projects_by_name_and_progress(
61-
active_projects, filter_string, progress_threshold=100,
61+
active_projects,
62+
filter_string,
63+
progress_threshold=100,
6264
)
6365

6466
inactive_projects = get_projects(status="inactive")
@@ -69,7 +71,9 @@ def run_update_project_status(filter_string: str) -> None:
6971
)
7072

7173
new_active_projects = filter_projects_by_name_and_progress(
72-
inactive_projects, filter_string, progress_threshold=0,
74+
inactive_projects,
75+
filter_string,
76+
progress_threshold=0,
7377
)[0 : len(finished_projects)]
7478

7579
# Here we check that there is at least one inactive project
@@ -89,11 +93,11 @@ def run_update_project_status(filter_string: str) -> None:
8993
if __name__ == "__main__":
9094
"""Use this command to run in docker container.
9195
docker-compose run -d mapswipe_workers_creation python3 python_scripts/update_project_status.py "test" 30 # noqa
92-
96+
9397
You need to use two arguments for the script
9498
- filter string, e.g. "test"
9599
- time interval in minutes, e.g. 30
96-
100+
97101
Make sure that you don't run this script too frequently as it pulls data from firebase and
98102
this will have implications on costs. Running this script once every 15-30 minutes should be totally fine.
99103
This means that there can be a "delay" in setting a project to finished about roughly the same time.

mapswipe_workers/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ firebase-admin==4.4.0
55
flake8==3.8.3
66
mapswipe-workers==3.0
77
pandas==1.1.3
8-
pre-commit==1.21.0
8+
pre-commit==2.9.2
99
psycopg2-binary==2.8.6
1010
python-dateutil==2.8.1
1111
schedule==0.6.0

0 commit comments

Comments
 (0)