<?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>article Using JFrog Artifactory PyPi libraries in Databricks Apps in Technical Blog</title>
    <link>https://community.databricks.com/t5/technical-blog/using-jfrog-artifactory-pypi-libraries-in-databricks-apps/ba-p/128099</link>
    <description>&lt;P&gt;&lt;SPAN&gt;In today's dynamic application development landscape, it is paramount to be able to leverage your own custom libraries within an App environment. These libraries often contain proprietary logic, critical algorithms, or specific data access patterns that are essential to your application's functionality. Furthermore, using a private repository like &lt;/SPAN&gt;&lt;A href="https://jfrog.com/artifactory/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;JFrog Artifactory&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; for these libraries significantly enhances security by isolating your code from public repositories and providing granular access control. This ensures that your valuable intellectual property remains protected.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This blog post guides you on how to install a private PyPI package from JFrog Artifactory within a &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/dev-tools/databricks-apps/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Databricks App&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; (DBApps) environment.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;SPAN&gt;Adding a private PyPi package to JFrog Artifactory&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;For this blog post, we have created a private PyPI package named “custom_calculator” in JFrog Artifactory and showed how that private package can be installed within DBApps. The package custom_calculator implements some simple arithmetic operations:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;"""
Basic arithmetic operations module.
"""

def add(a: float, b: float) -&amp;gt; float:
  """Add two numbers."""
  return a + b

def subtract(a: float, b: float) -&amp;gt; float:
  """Subtract b from a."""
  return a - b

def multiply(a: float, b: float) -&amp;gt; float:
  """Multiply two numbers."""
  return a * b

def divide(a: float, b: float) -&amp;gt; float:
  """Divide a by b."""
  if b == 0:
      raise ValueError("Cannot divide by zero")
  return a / b&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;We won’t focus on how this project will be &lt;/SPAN&gt;&lt;A href="https://packaging.python.org/en/latest/tutorials/packaging-projects/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;built and packaged&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;. Any standard python packaging solution should be able to build the project and generate a wheel file encapsulating the custom_calculator package. This package is then uploaded into and indexed inside a Jfrog Artifactory repository. Below is how it appears in the repository:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="uday_satapathy_4-1754936233330.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/18954iCB08BAA589A17583/image-size/large?v=v2&amp;amp;px=999" role="button" title="uday_satapathy_4-1754936233330.png" alt="uday_satapathy_4-1754936233330.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;H2&gt;&lt;SPAN&gt;Configuring the Databricks App&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;You can use this &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/dev-tools/databricks-apps/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;article&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; to create a Databricks App. The steps we outline below can be used to make the package &lt;/SPAN&gt;&lt;SPAN&gt;custom_calculator accessible from this App’s environment.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Grab the PyPI index-URL from JFrog Artifactory:&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;SPAN&gt;To connect your Databricks App to your private repository, you first need the specific PyPI index-URL provided by your JFrog Artifactory instance. This URL acts as the entry point for accessing your private packages. Below is the format of the index-url from JFrog:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;https://&amp;lt;username&amp;gt;:&amp;lt;password&amp;gt;@mycompany.jfrog.io/artifactory/api/pypi/pypi-local/simple&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;You can notice that credentials are included in the provided URL, which are essential for authenticating with JFrog Artifactory and accessing libraries. To maintain security and avoid exposing these credentials in application code, the index-url should be stored as a &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/security/secrets/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Databricks Secret&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;. This approach enables secure credential management and ensures proper referencing within the Databricks environment.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Put the value of the above index-URL into a Databricks Secret:&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;Using &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/dev-tools/cli/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Databricks CLI’s&lt;/SPAN&gt;&lt;/A&gt; &lt;A href="https://docs.databricks.com/aws/en/security/secrets/example-secret-workflow" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Secrets&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; module, you can add a secret named, say, jfrog-pypi-url into a Scope (a container of secrets).&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;databricks secrets create-scope my-secret-scope

databricks secrets put-secret my-secret-scope jfrog-pypi-url&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Add a pointer to this secret in the Databricks Apps - Resources:&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;SPAN&gt;Once the secret is created, you need to make it accessible to your application. This is done by adding a pointer to the secret in the Databricks Apps - Resources section. This step links the secret to your app's deployment configuration.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="uday_satapathy_5-1754936233336.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/18956iC6E18D3CD6ECF4E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="uday_satapathy_5-1754936233336.png" alt="uday_satapathy_5-1754936233336.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;
&lt;H3&gt;&lt;STRONG&gt;Set PIP_EXTRA_INDEX_URL inside app.yaml:&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;SPAN&gt;The app.yaml file in a Databricks app defines how your app is executed. In your app.yaml file, add a PIP_EXTRA_INDEX_URL environment variable. This variable tells pip to look for packages in your private JFrog Artifactory. In this case, pip first checks the public PyPI and then falls back to your private Artifactory. The value of this variable should be sourced from the 'key' you defined in the previous step, ensuring that the Artifactory URL is dynamically retrieved from the secret.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;app.yaml:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;command: [
"flask",
"--app",
"app.py",
"run"
]

env:
- name: "PIP_EXTRA_INDEX_URL"
  valueFrom: "external-pypi-url"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Add the library in &lt;/STRONG&gt;&lt;STRONG&gt;&lt;I&gt;requirements.txt&lt;/I&gt;&lt;/STRONG&gt;&lt;STRONG&gt;:&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;To ensure that your private library is installed during the app's deployment, add its name (e.g., custom_calculator) to your &lt;/SPAN&gt;&lt;I&gt;&lt;SPAN&gt;requirements.txt&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN&gt; file. This file lists all the Python dependencies required by your application.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;requirements.txt:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;flask
custom_calculator&lt;/LI-CODE&gt;
&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;
&lt;H3&gt;&lt;STRONG&gt;Import the package in your code&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;SPAN&gt;As a part of demonstrating the successful import of this package, we will display the execution of these arithmetic operations inside a Flask Application, created as a Databricks App. The app.py file for this application looks like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from flask import Flask, render_template_string, request
from custom_calculator import operations
import logging

log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)

app = Flask(__name__)

HTML_TEMPLATE = """
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;title&amp;gt;Custom Calculator Sample Execution&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;h1&amp;gt;Custom Calculator Sample Execution&amp;lt;/h1&amp;gt;
  &amp;lt;form method="post"&amp;gt;
      &amp;lt;label for="a"&amp;gt;a:&amp;lt;/label&amp;gt;
      &amp;lt;input type="number" step="any" name="a" id="a" value="{{ a }}"&amp;gt;
      &amp;lt;label for="b"&amp;gt;b:&amp;lt;/label&amp;gt;
      &amp;lt;input type="number" step="any" name="b" id="b" value="{{ b }}"&amp;gt;
      &amp;lt;button type="submit"&amp;gt;Calculate&amp;lt;/button&amp;gt;
  &amp;lt;/form&amp;gt;
  {% if results %}
  &amp;lt;ul&amp;gt;
      &amp;lt;li&amp;gt;Add: {{ a }} + {{ b }} = {{ results['add'] }}&amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;Subtract: {{ a }} - {{ b }} = {{ results['subtract'] }}&amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;Multiply: {{ a }} * {{ b }} = {{ results['multiply'] }}&amp;lt;/li&amp;gt;
      &amp;lt;li&amp;gt;Divide: {{ a }} / {{ b }} = {{ results['divide'] }}&amp;lt;/li&amp;gt;
  &amp;lt;/ul&amp;gt;
  {% endif %}
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
"""

@app.route("/", methods=["GET", "POST"])
def index():
  a = request.form.get("a", 10)
  b = request.form.get("b", 5)
  results = None

  try:
      a_val = float(a)
      b_val = float(b)
      results = {
          "add": operations.add(a_val, b_val),
          "subtract": operations.subtract(a_val, b_val),
          "multiply": operations.multiply(a_val, b_val),
      }
      try:
          results["divide"] = operations.divide(a_val, b_val)
      except Exception as e:
          results["divide"] = f"Error: {e}"
  except Exception:
      results = None

  return render_template_string(HTML_TEMPLATE, a=a, b=b, results=results)

if __name__ == "__main__":
  app.run(debug=True)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;Deploy + start the App and verify the library installation in the Environment tab:&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;SPAN&gt;After configuring your `app.yaml` and `requirements.txt`, deploy and start your Databricks App. You can then verify the successful installation of your private library by checking the Environment tab in your Databricks App's interface. This provides confirmation that your dependencies were correctly resolved and installed.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="uday_satapathy_6-1754936233340.png" style="width: 795px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/18955iD279E01BDB4C55E1/image-size/large?v=v2&amp;amp;px=999" role="button" title="uday_satapathy_6-1754936233340.png" alt="uday_satapathy_6-1754936233340.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Finally, run the App to verify that the logic defined in the imported package is working correctly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="uday_satapathy_7-1754936233335.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/18957i26A5308662C7BE40/image-size/large?v=v2&amp;amp;px=999" role="button" title="uday_satapathy_7-1754936233335.png" alt="uday_satapathy_7-1754936233335.png" /&gt;&lt;/span&gt;&lt;SPAN&gt;Summary&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;In a nutshell, integrating your private PyPI libraries from JFrog Artifactory into your Databricks Apps environment involves securely storing your Artifactory URL as a secret, referencing that secret in your app's configuration, and specifying your private library in your application's requirements. This process ensures that your custom code is deployed and available within your Databricks application securely and efficiently.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Build &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/aws/en/dev-tools/databricks-apps/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Apps&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; on Databricks today!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Aug 2025 20:36:23 GMT</pubDate>
    <dc:creator>uday_satapathy</dc:creator>
    <dc:date>2025-08-11T20:36:23Z</dc:date>
    <item>
      <title>Using JFrog Artifactory PyPi libraries in Databricks Apps</title>
      <link>https://community.databricks.com/t5/technical-blog/using-jfrog-artifactory-pypi-libraries-in-databricks-apps/ba-p/128099</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Installing private PyPI packages from JFrog Artifactory within a Databricks Apps&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;environment&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Aug 2025 20:36:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/using-jfrog-artifactory-pypi-libraries-in-databricks-apps/ba-p/128099</guid>
      <dc:creator>uday_satapathy</dc:creator>
      <dc:date>2025-08-11T20:36:23Z</dc:date>
    </item>
  </channel>
</rss>

