Select to view content in your preferred language

Folder.add() no longer always returns a Future object?

1226
15
08-15-2025 04:57 AM
Labels (1)
IsakL
by
Occasional Contributor

After returning to work after my summer holidays, I was told that a Python script which we use very frequently had stopped working. The relevant part of the script uploads objects to ArcGIS Online of various types, including File Geodatabases, using Folder.add().

As mentioned in the documentation this function is supposed to return a concurrent.futures.Future object and nothing else. In the past this was true. However what has started to happen is that if the object added is a File Geodatabase it now returns some kind of Job object instead, of a type which I haven't seen documented. (type() names it as arcgis.gis._impl._content_manager.folder.core.Job.) Whether this happens to other types I don't know, I haven't investigated this beyond what our script does.

Crucially, this Job object lacks the done() method which breaks both my script and the sample code on the linked documentation page, although result() still works on it. I was able to fix my script after I discovered that the Job object contained a property called futures. But now I need to have code to detect the type returned, since it varies depending on the type of object added. 

I haven't found this change documented anywhere, so I'm not sure what's going on, if this is an intentional change that was not documented or a bug. But whatever it is, it broke scripts that we rely on and it was not easy to fix due to the lack of documentation.

0 Kudos
15 Replies
KenGalliher1
Esri Contributor

Can you try with the latest version of the Python API (2.4.2)? The `folder.add` method returns a `Job` object. The `Job` object has the `done` method to allow for polling of the upload status and the `result()` method to retrieve the `Item`.

arcgis.gis module | ArcGIS API for Python | Esri Developer

RobertHolliday
Regular Contributor

I'll verify API version and try again shortly.

Ef
by
Emerging Contributor

Thanks @KenGalliher1 , I upgraded to 2.4.2, and I'm now able to call `done()` for the `folder.add` returned object

 

adongre1
Emerging Contributor

How did you upgrade? @Ef, The upgrade all button in Package Manager is pretty flaky, and I don't have an option to individually upgrade that package.

0 Kudos
adongre1
Emerging Contributor

Well, seems that it's allowable directly through miniconda.

0 Kudos
RobertHolliday
Regular Contributor

I am using API version 2.4.1 & arcpy. Suggestions in this thread have been helpful, but ultimately I ended up using arcpy.management.SharePackage for uploading/publishing vector tile packages.

There was something peculiar about the set of tile packages i was trying to upload via folder.add. Uploads were timing out even after I set a 2 hour timeout. Other packages of the same size and larger are uploading in minutes via folder.add.

0 Kudos