Hi all -
I'm pretty new to all things Python, Esri, etc... in that stage where you know some things, but enough to realize you know very little. I do a fair amount of contract work for one organization and have created Survey123 forms for that store the data on AGOL ("Source"), but I am employed by another organization ("Target") with more access to Esri products. I have a need to run a model that updates some data in the Source feature layers and created a model in ArcGIS Pro (licensed via the Target organization). This works fine, but requires that I leave Parallels (running Windows 11) open. I am hoping to move this task to AGOL Notebooks in the Target organization so that it will just run without needing the Windows Task Scheduler.
Some Info:
- The Source feature layer collection is publicly available
- In ArcGIS Pro I use a model to do the following in both the feature layer and related table:
- Open Source Feature Layer
- Select attributes needing updating using SelectLayerByAttribute
- Convert text string to a date using ConvertTimeField (aka Convert Temporal Field in GP Tools within ArcGIS Pro)
- I have been using Advanced Notebooks to test this in AGOL
- Generally <10 attributes need updating for any particular task
- Depending on the approach I take, I get error messages indicating (1) that the dataset does not exist/is not the appropriate type or (2) that the tool cannot be executed
- Unfortunately I have not been able to determine why I get one or the other... just not good note keeping on my part probably
- If I try to run a notebook in ArcGIS Pro to accomplish the steps performed by the model, the script will not work unless the feature layer collection has been added to a map
- I have tried to troubleshoot using a test feature layer collection hosted by the Target organization, but still get the same error messages
I have tried item = gis.content.get("<item ID>") to add the feature layer collection to the notebook, but it doesn't help. I have tired to sign into the Target portal, but cannot generate a token (the organization uses enterprise authentication, which might be the issue?). I can sign into the Source portal, but get the same errors. I can create maps from the feature layer, but I get the same error messages.
Am I not properly loading the dataset/feature layer into the notebook? Has anyone used the arcpy management module successfully in a hosted Notebook? Any help is much appreciated!
## Welcome to your notebook.
#### Run this cell to connect to your GIS and get started:
```python
from arcgis.gis import GIS
gis = GIS("home")
```
/opt/conda/lib/python3.9/site-packages/arcgis/gis/__init__.py:703: UserWarning: You are logged on as lmedeiros_ui_uidaho with an administrator role, proceed with caution.
warnings.warn(
#### Now you are ready to start!
```python
from arcgis.features import FeatureLayerCollection
from arcgis.features import FeatureLayer
import pandas as pd
from arcgis.features import FeatureCollection
from datetime import datetime as dt
import arcpy
from arcpy import env
from arcpy import management
import sys
from sys import argv
```
```python
# Item Added From Toolbar
# Title: <SamplingForm> | Type: Feature Service | Owner: <SourceUsername>
item = gis.content.get("<Source ItemID>")
item
```
```python
SE_in = item.layers[0]
IR_in = item.tables[0]
```
```python
m1 = gis.map()
m1
```
```python
m1.add_layer(SE_in)
```
```python
sdf = pd.DataFrame.spatial.from_layer(SE_in)
sdf.columns = [x if x == "SHAPE" else x.lower() for x in sdf.columns]
sdf.head()
```
```python
SE_copy = gis.content.import_data(sdf,
title='SE_copy')
SE_copy
```
```python
m2 = gis.map()
m2
```
```python
m2.add_layer(SE_copy)
```
```python
arcpy.management.SelectLayerByAttribute(SE_copy, "samplingdate_Converted IS NULL")
```
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/tmp/ipykernel_400/1474714341.py in <cell line: 1>()
----> 1 arcpy.management.SelectLayerByAttribute(SE_copy, "samplingdate_Converted IS NULL")
/opt/conda/lib/python3.9/site-packages/arcpy/management.py in SelectLayerByAttribute(in_layer_or_view, selection_type, where_clause, invert_where_clause)
10449 return retval
10450 except Exception as e:
> 10451 raise e
10452
10453 @gptooldoc('SelectLayerByLocation_management', None)
/opt/conda/lib/python3.9/site-packages/arcpy/management.py in SelectLayerByAttribute(in_layer_or_view, selection_type, where_clause, invert_where_clause)
10446 from arcpy.arcobjects.arcobjectconversion import convertArcObjectToPythonObject
10447 try:
> 10448 retval = convertArcObjectToPythonObject(gp.SelectLayerByAttribute_management(*gp_fixargs((in_layer_or_view, selection_type, where_clause, invert_where_clause), True)))
10449 return retval
10450 except Exception as e:
/opt/conda/lib/python3.9/site-packages/arcpy/geoprocessing/_base.py in <lambda>(*args)
518 val = getattr(self._gp, attr)
519 if callable(val):
--> 520 return lambda *args: val(*gp_fixargs(args, True))
521 else:
522 return convertArcObjectToPythonObject(val)
RuntimeError: Object: Error in executing tool
```python
```Â