Skip to content

Getting the dependencies of web map doesn't work depending on the arcgis active environment #2436

@MathieuLegault1

Description

@MathieuLegault1

Hello,

Describe the bug
Fetching the dependencies of a web map doesn't work if a different GIS environment is used than the one from arcgis. Check the Additional context portion for more information.

Expected behavior
The dependencies are correctly fetched

Platform (please complete the following information):

  • OS: Windows 11
  • Browser [e.g. chrome, safari]
  • Python API Version: 2.4.2

Additional context
When getting the dependencies of a web map is needs to fetch the item properties. When building the FeatureLayer class the current code does this: (apps/itemgraph/_get_dependencies under _parse_webmap)

FeatureLayer(layer["url"])

since the gis item is not provided the FeatureLayer class will determine it this way:

if gis is None:
    import arcgis

    gis = arcgis.env.active_gis

This might not work if arcgis.env.active_gis points to the wrong environment. I expect the correct gis object to be used since when fetching the dependencies I provide the correct GIS object.

It uses the gis object down the line to determine the properties url. Since the correct one might not be used it means that it won't work.

We can fix the behavior by doing this:
FeatureLayer(layer["url"], gis=item._gis)

Thanks,
Mathieu

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions