Select to view content in your preferred language

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

3721
19
08-15-2025 04:57 AM
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
19 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
adongre1
Emerging Contributor

Final thought: Seems that ESRI needs to release a patch to ArcPro so we can get a default conda environment  iwth python 3.13 to get the package upgraded to 2.4.2, in lieu of writing my own http requests against their API.

0 Kudos
SerjStol
Frequent Contributor

@KenGalliher1 This is a bit confusing. We upgraded from Enterprise 11.3 to 11.5 and our GP Web Tool now returns an error that Job object has no 'done' attribute. Reading the github post it says the documentation has been updated to reflect that but the documentations still says 'done' method exists? Or you have removed and then re added it in the latest 2.4.2 verison of Python API? https://github.com/Esri/arcgis-python-api/issues/2273

0 Kudos
KenGalliher1
Esri Contributor

@SerjStol Are you able to use the result() method instead of done()? I am not sure why we're seeing a wide range of discrepancies with Folder.add. I tested with ArcGIS Pro 3.5 which has version 2.4.1 of the Python API and get expected results:

 

from arcgis.gis import GIS
import uuid

portal = GIS(profile="your_enterprise_profile", verify_cert=False
)
portal_folder = portal.content.folders.get()
item_props = {
    "servicePassword": "abc123",
    "serviceUsername": "arcgis_python",
    "tags": "Tool, Service, ArcGIS Server",
    "title": f"test_async_folder_issue_{uuid.uuid4()}",
    "type": "Geoprocessing Service",
    "url": "https://elevation.arcgis.com/arcgis/rest/services/Tools/Elevation/GPServer",
}
svc_item = portal_folder.add(item_props)
print(type(svc_item))
print(svc_item.done())
print(svc_item.result())
svc_item.result().delete(permanent=True)

 

Type: <class 'concurrent.futures._base.Future'>
Done: True
Result: <Item title:"test_async_folder_issue_329d7c52-fa01-4683-9bfa-2b212a18f387" type:Geoprocessing Toolbox owner:arcgis_python>

 

0 Kudos
SerjStol
Frequent Contributor

Thanks for the prompt reply. Yes, this is exactly what we did in the end, replace done() with result() and it works now. I was just confused as it worked before in 11.3, then now in with Enterprise 11.5 that has ArcGIS Python API 2.4.1 ( i checked version in ArcGIS Server) it gives an error. Yet the documentation says done() should work. We have ArcGIS Pro 3.3 from where we did the publishing which has 2.3.0 version of Python API, but i would of thought that doesnt matter since its the 2.4.1 version thats running the Web Tool in ArcGIS Server.