1
0
Fork 0

fix bunch of bugs noticed on actual code use

This commit is contained in:
Mateusz Konieczny 2025-03-20 18:33:16 +01:00
parent 8c59d5537f
commit 73cca0d9a5

View file

@ -35,21 +35,27 @@ def latest_atp_unpacked_folder():
for entry in get_atp_history()[::-1]:
run_id = entry['run_id']
candidate = atp_unpacked_folder(run_id)
if os.path.isdir() == True:
if os.path.isdir(candidate) == True:
return candidate
def atp_unpacked_folder(run_id):
def atp_folder_root(run_id):
return config.atp_cache_folder() + run_id + "/"
def atp_unpacked_folder(run_id):
return atp_folder_root(run_id) + "output/"
def download_latest_atp_dataset():
response = get_atp_latest()
run_id = response['run_id']
download_specific_atp_run(run_id)
def download_specific_atp_run(run_id):
folder_path = config.atp_cache_folder() + "/" + run_id + "/"
folder_path = atp_folder_root(run_id)
success_marker = folder_path + "atp_download_completed.success"
if os.path.isfile(success_marker) == True:
return # done already
if os.path.isfile(success_marker) == False:
if os.path.isdir(folder_path) == True:
raise Exception(folder_path + " is in inconsistent state")
@ -60,7 +66,9 @@ def download_specific_atp_run(run_id):
download_url = "https://alltheplaces-data.openaddresses.io/runs/" + run_id + "/output.zip"
filename = "entire_atp.zip"
osm_bot_abstraction_layer.util_download_file.download_file_if_not_present_already(download_url, folder_path, filename)
os.system('unzip "' + config.atp_cache_folder() + filename + '" -d "' + config.atp_cache_folder() + '"')
os.system('unzip "' + folder_path + filename + '" -d "' + folder_path + '"')
with open(success_marker, "w") as myfile:
myfile.write("data prepared")
if __name__ == "__main__":
main()