Select to view content in your preferred language

ArcGIS Online - Notebook Task - Set Task Schedule Details

624
7
01-13-2025 01:25 PM
Status: Open
ChristopherMask
Regular Contributor

I would like to suggest a 2-minute interval option in the dropdown. I only request this to aid with wildfire situational awareness and rapid deployment of resources. The notebook code we developed copies NWS hotspot and potentially dangerous wildfire notification feature into our initial attack feature layer used in field maps by our resources. Currently, there is a 15-minute and 30-minute, but that time span is not sufficient. Thanks, Chris Mask - GIS Manager Oklahoma Forestry Services.

Tags (2)
7 Comments
AlfredBaldenweck

Why not a "type in your number of minutes" option? 2 minutes is great, but being able to specify an exact number would be great.

Otherwise, how about like: 1,2,3,4,5,10,15,20,25,30,45,60,90....

BobBooth1

You could embed your update code in a timed loop inside the notebook, have the notebook run every 15  minutes, and then have the timed loop within the notebook run every two minutes (for a counted number of runs or a timed duration), then quit.

I've done something similar with time.sleep() in a loop.

ChristopherMask

Do what @BobBooth1  , smh!?!   I can't tell you thanks enough for the idea, much appreciated! Added this code snippet at the end of the code and worked like a charm.

 

# Timed loop to execute the function 14 times, every 1 minute
for _ in range(14):
logging.info("Starting hotspot feature synchronization...")
copy_new_hotspot_features_to_event_layer(NWS_HotSpotPoint_layer, EventPoint_layer, CriticalFireArea_layer)
logging.info("Synchronization complete. Waiting for the next interval...")
time.sleep(60)

BobBooth1

Awesome!  Glad it worked for you!

ChristopherMask

So, the task will start but consistently receives this error message. Then, the task is set to failed and will not resume. I have to manually resume the task, which is not sufficient. Thoughts @BobBooth1 ? I have tested and reduced the iterations, but it appears to happen after 5 or 6 attempts. 

KeyboardInterrupt                         Traceback (most recent call last)
Cell In[1], line 149
    147     copy_new_hotspot_features_to_event_layer(NWS_HotSpotPoint_layer, EventPoint_layer, CriticalFireArea_layer)
    148     logging.info("Synchronization complete. Waiting for the next interval...")
--> 149     time.sleep(60)  # Wait for 1 minutes before the next attempt
    150 except Exception as e:
    151     logging.error(f"Error during attempt {attempt + 1}: {e}")

KeyboardInterrupt: 

 

BobBooth1

@ChristopherMask - When there is data to update, how long does the process take (within a given loop cycle?) I wonder if maybe the notebook is being run again by the task scheduler while it is still busy doing an update?

Could manage for that case by including a check of current time when the notebook starts, then within each loop check the time, calculate duration since start, and cause it to exit if there is less time left in the current notebook task's run cycle than it would typically take to make an update?

ChristopherMask

Well, it there is definitely a pattern. In all the failed task, it appears there is a 4-minute mark the task is stopped and fails. If you run the script from the menu, it works like it should. Bummed