[generator] Renamed NEED_BUILD_WORLD_ROADS and refactored stage as helper_stage.

This commit is contained in:
Olga Khlopkova 2020-12-30 17:21:33 +03:00 committed by Maksim Andrianov
parent 6add0b136d
commit 1c5297ce86
6 changed files with 14 additions and 18 deletions

View file

@ -278,6 +278,9 @@ def main():
if not settings.NEED_PLANET_UPDATE:
skipped_stages.add(sd.StageUpdatePlanet)
if not settings.NEED_BUILD_WORLD_ROADS:
skipped_stages.add(sd.StageRoutingWorld)
# Make env and run maps generation.
env = Env(
countries=countries,

View file

@ -234,14 +234,10 @@ class PathProvider:
def world_roads_path(self) -> AnyStr:
return (
os.path.join(self.intermediate_data_path, "world_roads.txt")
if settings.BUILD_WORLD_ROADS
if settings.NEED_BUILD_WORLD_ROADS
else ""
)
@property
def need_to_build_world_roads(self) -> bool:
return settings.BUILD_WORLD_ROADS
@property
def planet_osm_pbf(self) -> AnyStr:
return os.path.join(self.build_path, f"{settings.PLANET}.osm.pbf")
@ -438,8 +434,7 @@ class Env:
if item.endswith(".download"):
os.remove(os.path.join(self.paths.status_path, item))
if self.paths.need_to_build_world_roads:
self.world_roads_builder_tool = self.setup_world_roads_builder_tool()
self.world_roads_builder_tool = self.setup_world_roads_builder_tool()
self.main_status = status.Status()
# self.countries_meta stores log files and statuses for each country.

View file

@ -115,7 +115,7 @@ PROMO_CATALOG_COUNTRIES_URL = ""
POPULARITY_URL = ""
SUBWAY_URL = ""
TRANSIT_URL = ""
BUILD_WORLD_ROADS = True
NEED_BUILD_WORLD_ROADS = True
FOOD_URL = ""
FOOD_TRANSLATIONS_URL = ""
UK_POSTCODES_URL = ""
@ -277,7 +277,7 @@ def init(default_settings_path: AnyStr):
global POPULARITY_URL
global SUBWAY_URL
global TRANSIT_URL
global BUILD_WORLD_ROADS
global NEED_BUILD_WORLD_ROADS
global FOOD_URL
global UK_POSTCODES_URL
global US_POSTCODES_URL
@ -301,7 +301,7 @@ def init(default_settings_path: AnyStr):
POPULARITY_URL = cfg.get_opt_path("External", "POPULARITY_URL", POPULARITY_URL)
SUBWAY_URL = cfg.get_opt("External", "SUBWAY_URL", SUBWAY_URL)
TRANSIT_URL = cfg.get_opt("External", "TRANSIT_URL", TRANSIT_URL)
BUILD_WORLD_ROADS = cfg.get_opt("External", "BUILD_WORLD_ROADS", BUILD_WORLD_ROADS)
NEED_BUILD_WORLD_ROADS = cfg.get_opt("External", "NEED_BUILD_WORLD_ROADS", NEED_BUILD_WORLD_ROADS)
FOOD_URL = cfg.get_opt("External", "FOOD_URL", FOOD_URL)
UK_POSTCODES_URL = cfg.get_opt("External", "UK_POSTCODES_URL", UK_POSTCODES_URL)

View file

@ -233,17 +233,16 @@ class StageCitiesIdsWorld(Stage):
@country_stage
@helper_stage_for("StageRoutingWorld")
class StagePrepareRoutingWorld(Stage):
def apply(self, env: Env, country, **kwargs):
if env.paths.need_to_build_world_roads:
steps.step_prepare_routing_world(env, country, **kwargs)
steps.step_prepare_routing_world(env, country, **kwargs)
@country_stage
class StageRoutingWorld(Stage):
def apply(self, env: Env, country, **kwargs):
if env.paths.need_to_build_world_roads:
steps.step_routing_world(env, country, **kwargs)
steps.step_routing_world(env, country, **kwargs)
@country_stage

View file

@ -15,7 +15,7 @@ from maps_generator.generator.env import PathProvider
from maps_generator.generator.env import WORLDS_NAMES
from maps_generator.generator.env import WORLD_NAME
from maps_generator.generator.env import get_all_countries_list
from maps_generator.generator.exceptions import ValidationError
from maps_generator.generator.exceptions import ValidationError, wait_and_raise_if_fail
from maps_generator.generator.gen_tool import run_gen_tool
from maps_generator.generator.osmtools import osmconvert
from maps_generator.generator.osmtools import osmupdate
@ -213,8 +213,7 @@ def step_prepare_routing_world(env: Env, country: AnyStr, **kwargs):
env=os.environ
)
if sub_proc.wait() != 0:
raise Exception(f"Error running {world_roads_builder_tool_with_args}")
wait_and_raise_if_fail(sub_proc)
def step_routing_world(env: Env, country: AnyStr, **kwargs):

View file

@ -59,7 +59,7 @@ DIFF_VERSION_DEPTH: 2
# PLANET_COASTS_URL:
# Set to 'true' to build special routing section in World.mwm for alerting about absent regions without which the
# route can't be built.
BUILD_WORLD_ROADS: true
NEED_BUILD_WORLD_ROADS: true
# The url to the subway file.
SUBWAY_URL: http://osm-subway.maps.me/mapsme/latest.json