Select to view content in your preferred language

Intermitent Variable Issue with Python Notebook

474
1
08-10-2023 06:03 PM
JCann
by
New Contributor II

I have a Notebook that I have been working on for  more than 3 months. I have a persistent, intermittent issue affecting multiple variables in the notebook. It does not happen every time it is used, sometimes it goes weeks without issues, other times it will not run at all, throwing random errors constantly.

The notebook uses multiple functions, two of which are below. The set_time( ) function runs without issues as does the get_hosted feature(gis) in other scripts and projects.

cal - Copy.PNG

Output from set_time( ).

today.PNG

The issue that comes up is when "today" is called as a parameter a couple of cells down. It will randomly throw an error 'missing 1 required positional argument: today' despite the set_time ( ) cell having been run.

It gets more perplexing because there are three cells that use 'today' as a parameter in a function and there are times when the first two cells run and the third does not, throwing the same error.

check.PNG

This has also happens with the cal_ipmt_dc variable and a couple of other variables cause the the same intermittent, none of the cells, or some of the cells that use it throwing errors.

The most recent test was to modify the functions that used 'today' and put just the code from set_time( ) in each of the functions that used 'today' and remove the parameter. The first two functions ran to completion, third function threw the error 'datetime does not exist', which obviously had to be imported, and was imported in the first cell, in order for two of the three functions to run. But two hours later, a restart of the computer, and of VS Studio Code, all three functions ran fine.

This Notebook is being used by other people, hence using functions to create a cleaner Notebook. The other users do not want to mess with waiting, restarting everything multiple times, etc.  for the Notebook to randomly decided to start recognizing variables again. This is happening from both ArcGIS Pro 3.1.2 and VS Studio Code, across multiple computers, and multiple internet connections at differing speeds.

Any thoughts or suggestions would be appreciated, I really do not want to have to strip out all variables to make this Notebook more reliable.

0 Kudos
1 Reply
David_McRitchie
Esri Contributor

Hey JCann,

 

This sounds like quite a complex issue and will be hard to pinpoint where it is going wrong. Given the methods you have used I would recommend testing against the data first.

If you were to setup a copy of the notebook and point this to other Hosted Feature Layers does the issue reproduce? This will let us know if the script will need adjustment, or if this could be dataspecific, potentially if there is joined data or some sort of Schema lock occuring. 

Please feel to @mention me in future as I appreciate this might take a few weeks/months to test.

Many thanks,

David

Esri UK -Technical Support Analyst
0 Kudos