<?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 Custom Library not found in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4369661#M6201</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have compiled a whl file and placed it unde rthe custom library section and published it and when i try to import it under notebook using the environment which has this library it says "&lt;SPAN class=""&gt;ModuleNotFoundError&lt;/SPAN&gt;&lt;SPAN&gt;: No module named 'sun_five9_runreport'"&lt;BR /&gt;&lt;BR /&gt;when I do %pip list I can see the library under the list. can't wrap my head on why this this is happening.&lt;BR /&gt;&lt;BR /&gt;here is how i constructed setup.py&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;from setuptools import setup, find_packages&lt;/P&gt;&lt;P&gt;setup(&lt;BR /&gt;name="sun_five9_runreport",&lt;BR /&gt;version="1.0.0",&lt;BR /&gt;packages=find_packages(),&lt;BR /&gt;description="A library to fetch reports from Five9 and process them into Spark DataFrames.",&lt;BR /&gt;author="xxx",&lt;BR /&gt;company="xxx",&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;please help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jan 2025 18:04:26 GMT</pubDate>
    <dc:creator>sun-sboyanapall</dc:creator>
    <dc:date>2025-01-17T18:04:26Z</dc:date>
    <item>
      <title>Custom Library not found</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4369661#M6201</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have compiled a whl file and placed it unde rthe custom library section and published it and when i try to import it under notebook using the environment which has this library it says "&lt;SPAN class=""&gt;ModuleNotFoundError&lt;/SPAN&gt;&lt;SPAN&gt;: No module named 'sun_five9_runreport'"&lt;BR /&gt;&lt;BR /&gt;when I do %pip list I can see the library under the list. can't wrap my head on why this this is happening.&lt;BR /&gt;&lt;BR /&gt;here is how i constructed setup.py&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;from setuptools import setup, find_packages&lt;/P&gt;&lt;P&gt;setup(&lt;BR /&gt;name="sun_five9_runreport",&lt;BR /&gt;version="1.0.0",&lt;BR /&gt;packages=find_packages(),&lt;BR /&gt;description="A library to fetch reports from Five9 and process them into Spark DataFrames.",&lt;BR /&gt;author="xxx",&lt;BR /&gt;company="xxx",&lt;BR /&gt;)&lt;BR /&gt;&lt;BR /&gt;please help!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 18:04:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4369661#M6201</guid>
      <dc:creator>sun-sboyanapall</dc:creator>
      <dc:date>2025-01-17T18:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Library not found</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4370284#M6208</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/352282"&gt;@sun-sboyanapall&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you try republishing once? I have previously used a custom wheel in spark and faced no issues.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, can you try installing in a virtual environment in your local machine to check if the module gets correctly installed and imports without issue?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2025 17:00:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4370284#M6208</guid>
      <dc:creator>govindarajan_d</dc:creator>
      <dc:date>2025-01-18T17:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Library not found</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4373115#M6296</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/352282"&gt;@sun-sboyanapall&lt;/a&gt;&amp;nbsp;, thank you for reaching out to the Microsoft Fabric Community Forum.&lt;/P&gt;
&lt;P&gt;Please try the following:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Double-check the name of the package and the import statement in your notebook. Make sure they match exactly, as Python is case-sensitive.&lt;/LI&gt;
&lt;LI&gt;Sometimes the library might be installed in a different environment or path. Check if the notebook is using the same Python environment where the package is installed. You can verify this by running: &lt;BR /&gt;import sys&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;print(sys.executable)&lt;/P&gt;
&lt;OL start="3"&gt;
&lt;LI&gt;Sometimes, reinstalling the package can resolve issues. Try uninstalling and reinstalling the package.&lt;/LI&gt;
&lt;LI&gt;Ensure the module is being imported correctly in your notebook. Your import statement should look something like this:&lt;BR /&gt;from sun_five9_runreport import YourModuleName&lt;/LI&gt;
&lt;LI&gt;Make sure your package structure is correct and includes an __init__.py file in each directory. Your file structure should look something like this:&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;sun_five9_runreport/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __init__.py&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this helps, please consider marking it &lt;STRONG&gt;'Accept as Solution'&lt;/STRONG&gt; so others with similar queries may find it more easily. If not, please share the details.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 07:35:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4373115#M6296</guid>
      <dc:creator>v-hashadapu</dc:creator>
      <dc:date>2025-01-21T07:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Library not found</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4376359#M6393</link>
      <description>&lt;P&gt;I have rebulished it with a different name it worked this time.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is an example library for refreshing SQL Analytics End Point&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os
import shutil
import subprocess

# Recreate the directory structure from scratch
source_dir = "/mnt/data/lakehouse_sync_new"
dist_dir = os.path.join(source_dir, "dist")

if os.path.exists(source_dir):
    shutil.rmtree(source_dir)
os.makedirs(os.path.join(source_dir, "lakehouse_sync_new"))

# Create an empty __init__.py file
with open(os.path.join(source_dir, "lakehouse_sync_new", "__init__.py"), "w") as f:
    f.write("")

# Write the updated script without logging
script_content_no_logging = """
import json
import time
from sempy.fabric import FabricRestClient
from sempy.fabric.exceptions import FabricHTTPException, WorkspaceNotFoundException

class LakehouseSync:
    def __init__(self, tenant_id, workspace_id, lakehouse_id):
        self.tenant_id = tenant_id
        self.workspace_id = workspace_id
        self.lakehouse_id = lakehouse_id
        self.client = FabricRestClient()
        self.max_retries = 60  # Timeout after 60 seconds
        self.sleep_duration = 1  # Sleep 1 second between retries

    def _make_get_request(self, uri):
        \"\"\"Helper to make a GET request and return JSON data.\"\"\"
        response = self.client.get(uri)
        response.raise_for_status()
        return response.json()

    def _make_post_request(self, uri, payload):
        \"\"\"Helper to make a POST request and return JSON data.\"\"\"
        response = self.client.post(uri, json=payload)
        response.raise_for_status()
        return response.json()

    def get_sql_endpoint(self):
        \"\"\"Retrieve the SQL endpoint ID for the lakehouse.\"\"\"
        uri = f"/v1/workspaces/{self.workspace_id}/lakehouses/{self.lakehouse_id}"
        data = self._make_get_request(uri)
        return data['properties']['sqlEndpointProperties']['id']

    def sync_metadata(self, sql_endpoint_id):
        \"\"\"Initiate metadata synchronization and monitor progress.\"\"\"
        sync_uri = f"/v1.0/myorg/lhdatamarts/{sql_endpoint_id}"
        payload = {"commands": [{"$type": "MetadataRefreshExternalCommand"}]}

        # Start the sync
        response = self._make_post_request(sync_uri, payload)
        batch_id = response["batchId"]
        progress_state = response["progressState"]

        # Monitor sync progress
        status_uri = f"/v1.0/myorg/lhdatamarts/{sql_endpoint_id}/batches/{batch_id}"
        retries = 0

        while progress_state == 'inProgress' and retries &amp;lt; self.max_retries:
            time.sleep(self.sleep_duration)
            retries += 1
            status_response = self._make_get_request(status_uri)
            progress_state = status_response["progressState"]

        if retries &amp;gt;= self.max_retries:
            raise TimeoutError("Sync process timed out.")

        if progress_state == 'failure':
            raise Exception(f"Sync failed. Details: {status_response}")

    def run(self):
        \"\"\"Main method to orchestrate the synchronization process.\"\"\"
        sql_endpoint_id = self.get_sql_endpoint()
        self.sync_metadata(sql_endpoint_id)
"""
with open(os.path.join(source_dir, "lakehouse_sync_new", "lakehouse_sync_new.py"), "w") as f:
    f.write(script_content_no_logging)

# Create a minimal setup.py file
setup_content_minimal = """
from setuptools import setup, find_packages

setup(
    name="lakehouse_sync_new",
    version="1.0.0",
    packages=find_packages(),
    author="Sai Boyanapalli",
)
"""
with open(os.path.join(source_dir, "setup.py"), "w") as f:
    f.write(setup_content_minimal)

# Rebuild the .whl file
subprocess.run(["python3", "setup.py", "bdist_wheel"], cwd=source_dir, capture_output=True, text=True)
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 22 Jan 2025 19:29:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4376359#M6393</guid>
      <dc:creator>sun-sboyanapall</dc:creator>
      <dc:date>2025-01-22T19:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Library not found</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4376469#M6396</link>
      <description>&lt;P&gt;Wow. This is useful!&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 21:06:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Custom-Library-not-found/m-p/4376469#M6396</guid>
      <dc:creator>govindarajan_d</dc:creator>
      <dc:date>2025-01-22T21:06:53Z</dc:date>
    </item>
  </channel>
</rss>

