Mechanical Edits/Mateusz Konieczny - bot account/removing Covid from USA

From OpenStreetMap Wiki
Jump to navigation Jump to search

Page content created as advised on Automated_Edits_code_of_conduct#Document and discuss your plans.

Who

I, Mateusz Konieczny using my bot account

contact

message via OSM I will respond also to PMs to the bot account, though messaging my main account is preferable as I will get notifications in OSM editors.

English and Polish languages are preferable, for other I need to use an automatic translator.

What

Remove

in USA.

Why

opening_hours:covid19=* tags are problematic, confusing and should not be promoted. The original idea was to have them temporary, for duration of Covid - and sadly, "temporary, until Covid19 goes away" has become an oxymoron.

While say opening_hours:covid19=closed provides some info and indicates need to resurvey location, some provide no useful info at all.

Especially

This tags can be safely removed with an automated edit.

Numbers

Large enough to make it useful to automate it.

How

state after a mechanical edit:

Changeset would be described and tagged with tags that mark it as automatic, provide link to discussion approving edit, include link promoting https://matkoniecz.github.io/OSM-wikipedia-tag-validator-reports/ etc

Discussion

Discussed at https://osmus.slack.com/archives/C029HV951/p1678474037466969 and https://community.openstreetmap.org/t/proposed-bot-edit-removing-opening-hours-covid19-that-duplicate-opening-hours/96725

See also https://community.openstreetmap.org/t/opening-hours-covid19-tag-2023-discussion/9377

Repetition

This is reoccurring edit and may be made as soon as new matching elements appear. At this moment triggering new edit requires human intervention so exact schedule is not predictable and bot may stop running at any moment.

This can change in a future. If bot is abandoned and does not run, feel free to ping me. If I am unable to run it any more feel free to use my code. Note that it may require going through bot approval process again and that code is on specific license.

https://codeberg.org/matkoniecz/OpenStreetMap_cleanup_scripts/src/branch/master/recurrent_bot_edits may have more up to date code version that what is listed on this page

Source code

GPL 3.0 licensed

from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task
import osm_bot_abstraction_layer.overpass_downloader as overpass_downloader
from osm_iterator.osm_iterator import Data
import osm_bot_abstraction_layer.world_data as world_data
import time

def edit_element(tags):
    if tags.get('opening_hours:covid19') in ["open", "same"]:
        tags.pop('opening_hours:covid19', None)
    if tags.get('opening_hours:covid19') != None and tags.get('opening_hours:covid19') == tags.get('opening_hours'):
        tags.pop('opening_hours:covid19', None)
    return tags

def query(area_name):
  return """
[out:xml][timeout:1000];
area['name'='""" + area_name + """']->.searchArea;
nwr(area.searchArea)["opening_hours:covid19"];
out meta;
>;
out meta qt;"""

def edit_part(area_name):
    run_simple_retagging_task(
        max_count_of_elements_in_one_changeset=5000,
        objects_to_consider_query= query(area_name),
        cache_folder_filepath='/media/mateusz/OSM_cache/osm_bot_cache',
        is_in_manual_mode=False,
        changeset_comment='remove unnecessary opening_hours:covid19, repeating opening_hours (opening_hours_covid:19 is not a good idea as Covid is not temporary)',
        discussion_url='https://community.openstreetmap.org/t/proposed-bot-edit-removing-opening-hours-covid19-that-duplicate-opening-hours/96725 and https://osmus.slack.com/archives/C029HV951/p1678474037466969',
        osm_wiki_documentation_page='https://wiki.openstreetmap.org/wiki/Mechanical_Edits/Mateusz_Konieczny_-_bot_account/removing_Covid_from_USA',
        edit_element_function=edit_element,
    )

def main():
    edit_part("United States")

main()

See also

Opt-out

Please write at bot approval thread. Note that in case of opt-out exactly the same edit will be made manually for objects where bot opt-out was used.