Esri / arcgis-python-api

Documentation and samples for ArcGIS API for Python
https://developers.arcgis.com/python/
Apache License 2.0
1.91k stars 1.11k forks source link

Cannot set sharing level using new ItemProperties object of gis.content.folder.add() function #2138

Open sogunsemi opened 1 month ago

sogunsemi commented 1 month ago

Describe the bug I recently upgraded my arcgis python library from 2.3.0 -> 2.4.0 and noticed the deprecation warning on the function gis.content.add(). According to the message, that function should still be available until 3.0.0 but it throws a confusing error instead. My goal is to add a GeoJSON item into the root of my account with the Organization sharing level.

To save time I updated my code to the recommended function gis.content.folder.add(). To use the new Folder.add() function I created an ItemProperties object. The issue is that I don't see a way to replicate the access parameter of the previous item_properties dictionary. I would like to set whatever the corresponding parameter is in the ItemProperties object to org but the closest thing I can find in the parameter list is access_information but that does not seem to do anything.

To Reproduce Steps to reproduce the behavior:

def upload(data: str) -> Item:
        item_props = ItemProperties(
            title="My Title",
            item_type=ItemTypeEnum.GEOJSON.value,
            file_name="myfile.geojson",
            access_information="org",
        )
        LOGGER.info("publishing item")
        folders_obj = gis.content.folders
        item_folder = folders_obj.get()  # root folder of logged-in user is returned
        add_job = item_folder.add(item_properties=item_props, file=io.StringIO(data))
        return add_job.result()

error:

The GeoJSON item is added at the Owner sharing level instead of Organization in ArcGIS Online.

Deprecation warning for gis.content.add():

DeprecatedWarning: add is deprecated as of 2.3.0 and has been removed in 3.0.0. Use `Folder.add()` instead.

Error message I get when I try to use the gis.content.add() function:

AttributeError: module 'arcgis.features.geo' has no attribute '_is_geoenabled'

Screenshots After I call the gis.content.add() function, the GeoJSON item should have the org icon (the one in the red box) next to it in the UI but it instead has the "person" icon indicating the Owner sharing level. Screenshot 2024-10-23 at 9 53 34 AM

Expected behavior For my GeoJSON item to be created with the org sharing level

Platform (please complete the following information):

achapkowski commented 1 month ago

What is data?

sogunsemi commented 1 month ago

What is data?

It's a GeoJSON string that was generated using GeoPandas like this:

gdf = gpd.GeoDataFrame(
            result_df, geometry=result_df["centroid"].apply(wkt.loads), crs="EPSG:4326"
        )
data = gdf.to_json()