Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.2.5: improvements for Vahalla generation #78

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## x.y.z

## 2.2.5

CHANGED:
- Valhalla build config: increase default isochrone limits
- subprocess : check return code and raise Runtime exception if not 0

## 2.2.4

CHANGED:
Expand Down
2 changes: 1 addition & 1 deletion r2gg/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
__uri_tracker__ = f"{__uri_repository__}issues/"
__uri__ = __uri_repository__

__version__ = "2.2.4"
__version__ = "2.2.5"
__version_info__ = tuple(
[
int(num) if num.isdigit() else num
Expand Down
12 changes: 8 additions & 4 deletions r2gg/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,16 +407,20 @@ def valhalla_convert(config, resource, logger, build_lua_from_cost_config = True
start_command = time.time()
valhalla_build_config_args = ["valhalla_build_config",
"--mjolnir-tile-dir", source["storage"]["dir"],
"--mjolnir-tile-extract", source["storage"]["tar"]]
"--mjolnir-tile-extract", source["storage"]["tar"],
# Modification des limites par défaut du service : 10h pour isochrone et 1000km pour iso distance
# contre 2h et 200km par défaut
"--service-limits-isochrone-max-time-contour", "600",
"--service-limits-isochrone-max-distance-contour", "1000",
# Ajout de l'autorisation à exclure les ponts/tunnels/péages
"--service-limits-allow-hard-exclusions", "True"]
subprocess_execution(valhalla_build_config_args, logger, outfile = source["storage"]["config"])
# Nécessaire le temps que le fichier s'écrive...
time.sleep(1)
# Ajout du graph custom dans la config valhalla
# Ajout du graph custom dans la config valhalla (impossible via les paramètres du build_config)
with open(source["storage"]["config"], "r") as valhalla_config:
config_dict = json.load(valhalla_config)
config_dict["mjolnir"]["graph_lua_name"] = source["costs"][0]["compute"]["storage"]["file"]
# Ajout de l'autorisation à exclure les ponts/tunnels/péages
config_dict["service_limits"]["allow_hard_exclusions"] = True

with open(source["storage"]["config"], "w") as valhalla_config:
valhalla_config.write(json.dumps(config_dict))
Expand Down
9 changes: 8 additions & 1 deletion r2gg/_subprocess_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def subprocess_execution(args, logger, outfile = None):
"""
try:
str_args = [str(arg) for arg in args]
logger.info('Subprocess: \"' + " ".join(str_args) + '\"')
subprocess_arg = " ".join(str_args)
logger.info('Subprocess: \"' + subprocess_arg + '\"')
if outfile is not None:
with open(outfile, "w") as out:
process = subprocess.Popen(
Expand All @@ -32,6 +33,12 @@ def subprocess_execution(args, logger, outfile = None):
process_output, _ = process.communicate()
logger.info(process_output.decode("utf-8"))

returncode = process.returncode
if process.returncode != 0:
error_msg = f"Invalid returncode {returncode} for subprocess '{subprocess_arg}'"
logger.error(error_msg)
raise RuntimeError(error_msg)


except (OSError, subprocess.CalledProcessError) as exception:
logger.info('Exception occured: ' + str(exception))
Expand Down
Loading