Skip to content

Commit 92a5751

Browse files
author
matthias_schaub
committed
avoid circular imports
1 parent fb0c999 commit 92a5751

File tree

2 files changed

+17
-29
lines changed

2 files changed

+17
-29
lines changed

mapswipe_workers/mapswipe_workers/definitions.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55

66
import sentry_sdk
77

8-
from mapswipe_workers.project_types.build_area.build_area_project import (
9-
BuildAreaProject,
10-
)
11-
from mapswipe_workers.project_types.change_detection.change_detection_project import (
12-
ChangeDetectionProject,
13-
)
14-
from mapswipe_workers.project_types.footprint.footprint_project import FootprintProject
15-
168

179
class CustomError(Exception):
1810
pass
@@ -38,18 +30,6 @@ def load_config(CONFIG_PATH) -> dict:
3830

3931
DATA_PATH = os.path.abspath("/var/lib/mapswipe_workers/")
4032

41-
PROJECT_TYPE_CLASSES = {
42-
1: BuildAreaProject,
43-
2: FootprintProject,
44-
3: ChangeDetectionProject,
45-
}
46-
47-
PROJECT_TYPE_NAMES = {
48-
1: BuildAreaProject.project_type_name,
49-
2: FootprintProject.project_type_name,
50-
3: ChangeDetectionProject.project_type_name,
51-
}
52-
5333
logging.config.fileConfig(fname=LOGGING_CONFIG_PATH, disable_existing_loggers=True)
5434
logger = logging.getLogger("Mapswipe Workers")
5535

mapswipe_workers/mapswipe_workers/mapswipe_workers.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,25 @@
44
import json
55
import time
66

7-
import schedule as sched
8-
97
import click
8+
import schedule as sched
109
from mapswipe_workers import auth
11-
from mapswipe_workers.definitions import (
12-
PROJECT_TYPE_CLASSES,
13-
CustomError,
14-
logger,
15-
sentry,
16-
)
10+
from mapswipe_workers.definitions import CustomError, logger, sentry
1711
from mapswipe_workers.firebase_to_postgres import (
1812
archive_project,
1913
transfer_results,
2014
update_data,
2115
)
2216
from mapswipe_workers.generate_stats import generate_stats
2317
from mapswipe_workers.project_types.build_area import build_area_tutorial
18+
from mapswipe_workers.project_types.build_area.build_area_project import (
19+
BuildAreaProject,
20+
)
2421
from mapswipe_workers.project_types.change_detection import change_detection_tutorial
22+
from mapswipe_workers.project_types.change_detection.change_detection_project import (
23+
ChangeDetectionProject,
24+
)
25+
from mapswipe_workers.project_types.footprint.footprint_project import FootprintProject
2526
from mapswipe_workers.utils import user_management
2627
from mapswipe_workers.utils.slack_helper import send_slack_message
2728

@@ -53,6 +54,13 @@ def run_create_projects():
5354
Create projects with groups and tasks.
5455
Save created projects, groups and tasks to Firebase and Postgres.
5556
"""
57+
58+
project_type_classes = {
59+
1: BuildAreaProject,
60+
2: FootprintProject,
61+
3: ChangeDetectionProject,
62+
}
63+
5664
fb_db = auth.firebaseDB()
5765
ref = fb_db.reference("v2/projectDrafts/")
5866
project_drafts = ref.get()
@@ -66,7 +74,7 @@ def run_create_projects():
6674
project_name = project_draft["name"]
6775
try:
6876
# Create a project object using appropriate class (project type).
69-
project = PROJECT_TYPE_CLASSES[project_type](project_draft)
77+
project = project_type_classes[project_type](project_draft)
7078
project.geometry = project.validate_geometries()
7179
project.create_groups()
7280
project.calc_required_results()

0 commit comments

Comments
 (0)