<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: TableToNumPyArray creates schema lock in File Geodatabase in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/tabletonumpyarray-creates-schema-lock-in-file/m-p/1338815#M74066</link>
    <description>&lt;P&gt;This appears to be a wider problem with the &lt;FONT face="courier new,courier"&gt;arcpy.da&lt;/FONT&gt; module. As documented in &lt;A href="https://community.esri.com/t5/arcgis-pro-questions/arcpy-da-describe-locks-geodatabase/td-p/1236184" target="_blank" rel="noopener"&gt;this post&lt;/A&gt;, &lt;FONT face="courier new,courier"&gt;arcpy.da.Describe()&lt;/FONT&gt; also creates a schema lock in a file geodatabase when a layer is used as the argument. I am hoping this topic gets some attention and is ultimately addressed without having to resort to workarounds, but in my case and in the case of using &lt;FONT face="courier new,courier"&gt;arcpy.da.Describe()&lt;/FONT&gt;, I found a workaround using &lt;FONT face="courier new,courier"&gt;arcpy.management.GetCount()&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;In my case, I was able to call GetCount with the path to a table in the file geodatabase that has the lock from using the arcpy.da module and the lock was released. Note that I was using paths to the data and not arcpy.mp.Layer objects.&lt;/P&gt;&lt;P&gt;In the post referenced above, that wasn't quite enough. As mentioned in that post, using &lt;FONT face="courier new,courier"&gt;arcpy.Describe()&lt;/FONT&gt; with a path as the argument was the workaround. Using &lt;FONT face="courier new,courier"&gt;arcpy.Describe()&lt;/FONT&gt;&amp;nbsp;with a Layer object as the argument still created a schema lock, and using &lt;FONT face="courier new,courier"&gt;arcpy.&lt;STRONG&gt;da&lt;/STRONG&gt;.Describe()&lt;/FONT&gt; with a path as the argument also resulted in a schema lock. Calling &lt;FONT face="courier new,courier"&gt;arcpy.management.GetCount()&lt;/FONT&gt;released the lock only when &lt;FONT face="courier new,courier"&gt;arcpy.da.Describe()&lt;/FONT&gt; was used with a path as the argument; it did not work when the Layer object was passed as the argument in either the &lt;FONT face="courier new,courier"&gt;arcpy.Describe()&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;arcpy.&lt;STRONG&gt;da&lt;/STRONG&gt;.Describe()&lt;/FONT&gt; cases.&lt;/P&gt;&lt;P&gt;I've included a code sample below that demonstrates the schema locks and partial success in releasing them for &lt;FONT face="courier new,courier"&gt;arcpy.da.Describe()&lt;/FONT&gt;. Note that you'll have to reset the Python environment between cases 3 and 4 since case 3 doesn't release the lock.&lt;/P&gt;&lt;P&gt;Edit: I've included a 5th case demonstrating lock files being created by the Layer object without the use of the &lt;FONT face="courier new,courier"&gt;arcpy.da&lt;/FONT&gt; module. Note again that the Python environment should be reset between cases 4 and 5.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
aprx_path = r"path to a Pro project with a map containing feature layers in a file gdb"
aprx = arcpy.mp.ArcGISProject(aprx_path)
m = aprx.listMaps()[0]
lyrs = m.listLayers()
lyr = lyrs[0]

# case 1 - lock created by arcpy.da.Describe() with a path as the argument
# lock released using arcpy.management.GetCount() with a path as the argument
desc1 = arcpy.da.Describe(lyr.dataSource)
result1 = arcpy.management.GetCount(lyr.dataSource)

# case 2 - lock NOT created using arcpy.Describe() with a path as the argument
desc2 = arcpy.Describe(lyr.dataSource)

# case 3 - lock created by arcpy.da.Describe() with a Layer object as the argument
# lock NOT released using arcpy.management.GetCount() with a path as the argument
desc3 = arcpy.da.Describe(lyr)
result3 = arcpy.management.GetCount(lyr.dataSource)

# case 4 - lock created by arcpy.Describe() with a Layer object as the argument
# lock NOT released using arcpy.management.GetCount() with a path as the argument
desc4 = arcpy.Describe(lyr)
result4 = arcpy.management.GetCount(lyr.dataSource)

# case 5 - lock created by using arcpy.management.GetCount() with a Layer object as the argument
# lock NOT released using arcpy.management.GetCount() with a path as the argument
result5 = arcpy.management.GetCount(lyr)
del result5 # this does remove one of two lock files from the gdb
result6 = arcpy.management.GetCount(lyr.dataSource)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Oct 2023 19:38:26 GMT</pubDate>
    <dc:creator>isburns</dc:creator>
    <dc:date>2023-10-17T19:38:26Z</dc:date>
    <item>
      <title>TableToNumPyArray creates schema lock in File Geodatabase</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/tabletonumpyarray-creates-schema-lock-in-file/m-p/1337478#M73961</link>
      <description>&lt;P&gt;I'm using ArcGIS Pro 3.1.2. Calling TableToNumPyArray or FeatureClassToNumPyArray creates a schema lock on the File Geodatabase containing the feature class or table used as input to the function when the code is executed in a Jupyter Notebook in a standalone environment. It also creates a schema lock when executed via a standalone Python window. This does not happen when the code is executed from a Jupyter Notebook run inside of ArcGIS Pro, or from the Python Console in ArcGIS Pro. The only method I found for releasing the schema lock is restarting the Kernel or exiting Python in the standalone window.&lt;/P&gt;&lt;P&gt;This seems like a bug since it doesn't occur when the code is executed inside Pro.&amp;nbsp;Is there a way to release the schema lock that is unadvertised?&lt;/P&gt;&lt;P&gt;Provide a path to your data and a valid field name and the code below will produce locks in your geodatabase when executed in Jupyter Notebooks outside of Pro.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import numpy
tbl = r"path to your table here"
fld = "a field in your table"
nulls_bool = False # Tested with both True and False, doesn't matter
arr = arcpy.da.TableToNumPyArray(tbl, fld, skip_nulls=nulls_bool)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 19:52:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/tabletonumpyarray-creates-schema-lock-in-file/m-p/1337478#M73961</guid>
      <dc:creator>isburns</dc:creator>
      <dc:date>2023-10-12T19:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: TableToNumPyArray creates schema lock in File Geodatabase</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/tabletonumpyarray-creates-schema-lock-in-file/m-p/1338815#M74066</link>
      <description>&lt;P&gt;This appears to be a wider problem with the &lt;FONT face="courier new,courier"&gt;arcpy.da&lt;/FONT&gt; module. As documented in &lt;A href="https://community.esri.com/t5/arcgis-pro-questions/arcpy-da-describe-locks-geodatabase/td-p/1236184" target="_blank" rel="noopener"&gt;this post&lt;/A&gt;, &lt;FONT face="courier new,courier"&gt;arcpy.da.Describe()&lt;/FONT&gt; also creates a schema lock in a file geodatabase when a layer is used as the argument. I am hoping this topic gets some attention and is ultimately addressed without having to resort to workarounds, but in my case and in the case of using &lt;FONT face="courier new,courier"&gt;arcpy.da.Describe()&lt;/FONT&gt;, I found a workaround using &lt;FONT face="courier new,courier"&gt;arcpy.management.GetCount()&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;In my case, I was able to call GetCount with the path to a table in the file geodatabase that has the lock from using the arcpy.da module and the lock was released. Note that I was using paths to the data and not arcpy.mp.Layer objects.&lt;/P&gt;&lt;P&gt;In the post referenced above, that wasn't quite enough. As mentioned in that post, using &lt;FONT face="courier new,courier"&gt;arcpy.Describe()&lt;/FONT&gt; with a path as the argument was the workaround. Using &lt;FONT face="courier new,courier"&gt;arcpy.Describe()&lt;/FONT&gt;&amp;nbsp;with a Layer object as the argument still created a schema lock, and using &lt;FONT face="courier new,courier"&gt;arcpy.&lt;STRONG&gt;da&lt;/STRONG&gt;.Describe()&lt;/FONT&gt; with a path as the argument also resulted in a schema lock. Calling &lt;FONT face="courier new,courier"&gt;arcpy.management.GetCount()&lt;/FONT&gt;released the lock only when &lt;FONT face="courier new,courier"&gt;arcpy.da.Describe()&lt;/FONT&gt; was used with a path as the argument; it did not work when the Layer object was passed as the argument in either the &lt;FONT face="courier new,courier"&gt;arcpy.Describe()&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;arcpy.&lt;STRONG&gt;da&lt;/STRONG&gt;.Describe()&lt;/FONT&gt; cases.&lt;/P&gt;&lt;P&gt;I've included a code sample below that demonstrates the schema locks and partial success in releasing them for &lt;FONT face="courier new,courier"&gt;arcpy.da.Describe()&lt;/FONT&gt;. Note that you'll have to reset the Python environment between cases 3 and 4 since case 3 doesn't release the lock.&lt;/P&gt;&lt;P&gt;Edit: I've included a 5th case demonstrating lock files being created by the Layer object without the use of the &lt;FONT face="courier new,courier"&gt;arcpy.da&lt;/FONT&gt; module. Note again that the Python environment should be reset between cases 4 and 5.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
aprx_path = r"path to a Pro project with a map containing feature layers in a file gdb"
aprx = arcpy.mp.ArcGISProject(aprx_path)
m = aprx.listMaps()[0]
lyrs = m.listLayers()
lyr = lyrs[0]

# case 1 - lock created by arcpy.da.Describe() with a path as the argument
# lock released using arcpy.management.GetCount() with a path as the argument
desc1 = arcpy.da.Describe(lyr.dataSource)
result1 = arcpy.management.GetCount(lyr.dataSource)

# case 2 - lock NOT created using arcpy.Describe() with a path as the argument
desc2 = arcpy.Describe(lyr.dataSource)

# case 3 - lock created by arcpy.da.Describe() with a Layer object as the argument
# lock NOT released using arcpy.management.GetCount() with a path as the argument
desc3 = arcpy.da.Describe(lyr)
result3 = arcpy.management.GetCount(lyr.dataSource)

# case 4 - lock created by arcpy.Describe() with a Layer object as the argument
# lock NOT released using arcpy.management.GetCount() with a path as the argument
desc4 = arcpy.Describe(lyr)
result4 = arcpy.management.GetCount(lyr.dataSource)

# case 5 - lock created by using arcpy.management.GetCount() with a Layer object as the argument
# lock NOT released using arcpy.management.GetCount() with a path as the argument
result5 = arcpy.management.GetCount(lyr)
del result5 # this does remove one of two lock files from the gdb
result6 = arcpy.management.GetCount(lyr.dataSource)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 19:38:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/tabletonumpyarray-creates-schema-lock-in-file/m-p/1338815#M74066</guid>
      <dc:creator>isburns</dc:creator>
      <dc:date>2023-10-17T19:38:26Z</dc:date>
    </item>
  </channel>
</rss>

