Hi I encountered a werid situation as follows:
1. I set my working space by using the code following code and then using UpdateCursor api:
import arcpy
from pprint import pprint
# Setting the default location for geoprocessing tool inputs and outputs.
arcpy.env.workspace = r"original_path\....gdb"
arcpy.env.overwriteOutput = True
merge_chinesefields = ["CHINESENAME","CHINESESTREETNAME"]
with arcpy.da.UpdateCursor("test", merge_chinesefields) as cursor:
for row in cursor:
print (row)
2. I closed ArcGIS Pro and changed my whole working folder from "original_path\....gdb" to a new place as "new_path\....gdb"
3. I reopened the ArcGIS Project file from the new folder and then re-runed the exactly same code as above without changing the workspace. Therefore, in this time the code was still
arcpy.env.workspace = r"original_path\....gdb"
4. The werid thing is that although I did not change the workspace path, the code still worked and succesfully printed each row of the table. The code did not report error like:
Input Workspace: Dataset original_path\....gdb does not exist or is not supported
5. It seemed that the notebook can memory previous results and recall the previous results without noticing path change. Therefore, I tried the command of "arcpy.management.ClearWorkspaceCache()" as well as the process "Options - Display - Clear Cache Now". But the kernel can still run without errors and return the previous print result to me.
Did anyone encounter the same problem before? Is it because ArcGIS Pro somehow automatically generate a connection to my folder whereever it is stored in my computer?
Here's another example of Notebooks remembering things you'd prefer they didn't
Once you assign a value to a variable in an ArcGIS Pro notebook, it will remember and use that variable for the remainder of that session until you close ArcGIS Pro. It's super easy to demonstrate. It is even better if you do the same thing side by side in IDLE.
In IDLE create, and reference a variable:
Then, edit the code to delete the variable and re-run.
X is not defined. Good!
Let's try the same experiment in a Notebook. First, when the variable exists:
Then, when it does not exist
It remembers. Refactoring code to rename variables in a Notebook is fraught with danger.
Hi MicZatorsky,
Yes, I think that's exactly what I encountered in ArcGIS Notebook. And even I closed ArcGIS Pro and re-opened it, Notebook still remembered what I deleted. I don't know how I can clear its memories. Do you have any idea?
No, but I've yet to notice this persist between sessions. A restart usually fixes it.
You mean restarting the ArcGIS Pro software?
Standalone Jupyter notebooks have a 'Kernel > Restart" menu option, but Pro does not, so you have to restart Pro.