I have to change my script for downloading feature layers from webmaps from AGOL due to the most recent update in September 2024 which changed the arcgis.mapping and arcgis.widgets into a new arcgis.map module. As a result it also changed the function WebMap() to Map() and this is where my error lies.
I am following the steps in this link and this link but neither are working. I have tried to search for my webmap by name and by id and input it to the new functionality of Map(item=my_result) but everytime I do, I get a huge result of errors. I can post the entire file is needed. Can anyone help with what I am doing wrong or what the new methodology is please?
pydantic_core._pydantic_core.ValidationError: 568 validation errors for Webmap
Here is some of the outputs for the error list, the list goes on for 1715 lines.
webmapobj = Map(item=wm_result1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py", line 254, in __init__
self._setup_webmap_properties(item)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\map\map_widget.py", line 402, in _setup_webmap_properties
self._webmap = ws.Webmap(**data)
^^^^^^^^^^^^^^^^^
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\pydantic\main.py", line 164, in __init__
__pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 568 validation errors for Webmap
operationalLayers.1.AnnotationLayerArcGISAnnotationLayer.layerDefinition.drawingInfo.renderer
Field required [type=missing, input_value={'labelingInfo': [{'label...fset': 0, 'angle': 0}}]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.4/v/missing
operationalLayers.1.AnnotationLayerArcGISAnnotationLayer.layerType
Input should be 'ArcGISAnnotationLayer' [type=literal_error, input_value='ArcGISFeatureLayer', input_type=str]
For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.1.CatalogLayerCatalogLayer.layerDefinition.drawingInfo.renderer
Field required [type=missing, input_value={'labelingInfo': [{'label...fset': 0, 'angle': 0}}]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.4/v/missing
operationalLayers.1.CatalogLayerCatalogLayer.layerType
Input should be 'CatalogLayer' [type=literal_error, input_value='ArcGISFeatureLayer', input_type=str]
For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.1.CSVLayerCSV.layerDefinition.drawingInfo.renderer
Field required [type=missing, input_value={'labelingInfo': [{'label...fset': 0, 'angle': 0}}]}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.4/v/missing
operationalLayers.1.CSVLayerCSV.layerType
Input should be 'CSV' [type=literal_error, input_value='ArcGISFeatureLayer', input_type=str]
For further information visit https://errors.pydantic.dev/2.4/v/literal_error
operationalLayers.1.DimensionLayerArcGISDimensionLayer.layerDefinition.drawingInfo.renderer
Field required [type=missing, input_value={'labelingInfo': [{'label...fset': 0, 'angle': 0}}]}, input_type=dict]
More info.. the vector symbology, didn't place a renderer tag in the layerDefintion, and there is type param there, what is why in the error message you see type=missing
I got a notification that this bug has been fixed in Python 2.4.2. I have tested it out in an AGOL Notebook v12.0 and the same script that was failing before is now working.
Email from Esri:
Updates have been made to the following defect which you are associated with:
BUG-000177131 - Enabling labelling within a web map causes validation errors when utilising the arcgis.map submodule in ArcGIS API for Python 2.4.x.
Status: Fixed (Learn More)
Version Fixed: 2.4.2