<?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: ModuleNotFoundError when run with foreachBatch on serverless mode in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/modulenotfounderror-when-run-with-foreachbatch-on-serverless/m-p/71390#M34305</link>
    <description>&lt;P&gt;Thank&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;for your response.&lt;/P&gt;&lt;P&gt;Today, I re-run my job again, without any changes. It doesn’t raise module not found &lt;STRONG&gt;my_lib&lt;/STRONG&gt; as I mentioned above, but it raises the Access Denied on my S3 bucket. I don't see anywhere to set my IAMr or instance profile on the serverless as I did with provision compute.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jun 2024 05:00:22 GMT</pubDate>
    <dc:creator>fury-kata</dc:creator>
    <dc:date>2024-06-03T05:00:22Z</dc:date>
    <item>
      <title>ModuleNotFoundError when run with foreachBatch on serverless mode</title>
      <link>https://community.databricks.com/t5/data-engineering/modulenotfounderror-when-run-with-foreachbatch-on-serverless/m-p/71068#M34241</link>
      <description>&lt;P&gt;I using Notebooks to do some transformations&amp;nbsp;&lt;/P&gt;&lt;P&gt;I install a new whl:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;%pip install --force-reinstall /Workspace/&amp;lt;my_lib&amp;gt;.whl
%restart_python&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I&amp;nbsp; successfully import the installed lib&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from my_lib.core import test&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I run my code with&amp;nbsp;&lt;SPAN&gt;foreachBatch it raises ModuleNotFoundError: No module named 'my_lib'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is my code:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from my_lib.utils import clogs
logs = clogs.logs()
def _test(df, b):
    logs.add_logs('test')

mystream =  spark.readStream\
                                    .table('my_tbale') \
                                .writeStream\
                                    .format("delta")\
                                    .foreachBatch(_test)\
                                    .trigger(once=True) \
                                .start()
mystream.awaitTermination()
streaming_silver.awaitTermination()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It raises an error:&lt;SPAN&gt;&amp;nbsp;ModuleNotFoundError: No module named 'my_lib'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 04:52:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/modulenotfounderror-when-run-with-foreachbatch-on-serverless/m-p/71068#M34241</guid>
      <dc:creator>fury-kata</dc:creator>
      <dc:date>2024-05-30T04:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: ModuleNotFoundError when run with foreachBatch on serverless mode</title>
      <link>https://community.databricks.com/t5/data-engineering/modulenotfounderror-when-run-with-foreachbatch-on-serverless/m-p/71390#M34305</link>
      <description>&lt;P&gt;Thank&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;for your response.&lt;/P&gt;&lt;P&gt;Today, I re-run my job again, without any changes. It doesn’t raise module not found &lt;STRONG&gt;my_lib&lt;/STRONG&gt; as I mentioned above, but it raises the Access Denied on my S3 bucket. I don't see anywhere to set my IAMr or instance profile on the serverless as I did with provision compute.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 05:00:22 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/modulenotfounderror-when-run-with-foreachbatch-on-serverless/m-p/71390#M34305</guid>
      <dc:creator>fury-kata</dc:creator>
      <dc:date>2024-06-03T05:00:22Z</dc:date>
    </item>
  </channel>
</rss>

