<?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: graceful dbutils mount/unmount in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29754#M21461</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Is there a way to mount a drive with Databricks CLI, I want the drive to be present from the time the cluster boots up.. I want to use a mounted blob storage to redirect the logs.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2019 21:13:36 GMT</pubDate>
    <dc:creator>viswanathboga</dc:creator>
    <dc:date>2019-04-17T21:13:36Z</dc:date>
    <item>
      <title>graceful dbutils mount/unmount</title>
      <link>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29748#M21455</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Is there a way to indicate to dbutils.fs.mount to not throw an error if the mount is already mounted?&lt;/P&gt;
&lt;P&gt;And viceversa, for unmount to not throw an error if it is already unmounted?&lt;/P&gt;
&lt;P&gt;I am trying to run my notebook as a job and it has a init section that mounts S3 buckets it needs. Sometimes the mounts are already done by an earlier script.&lt;/P&gt;
&lt;P&gt;Since mounting an already mounted mount (wow) throws an error my job exits out.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 May 2016 22:36:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29748#M21455</guid>
      <dc:creator>dchokkadi1_5588</dc:creator>
      <dc:date>2016-05-10T22:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: graceful dbutils mount/unmount</title>
      <link>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29749#M21456</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;@Deepak Chokkadi&lt;/P&gt;
&lt;P&gt;This is the function that I use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;def mountBucket(dstBucketName:String, dstMountName:String) {
  import java.lang.IllegalArgumentException
  val accessKey = "YOUR ACCESS KEY"
  val encodedSecretKey = "YOUR SECRET".replace("/", "%2F")
  try {
    dbutils.fs.mount(s"s3a://$accessKey:$encodedSecretKey@$dstBucketName", dstMountName) 
    println("All done!")
  } catch {
    case e: java.rmi.RemoteException =&amp;gt; {
      println("Directory is Already Mounted")
      dbutils.fs.unmount(dstMountName)
      mountBucket(dstBucketName, dstMountName)
    }
    case e: Exception =&amp;gt; {
      println("There was some other error")
    }
  }
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I've put it in a simple accessible notebook, then just run that notebook using %run. Then to mount a bucket I use that function and it automatically remount it.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 03:51:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29749#M21456</guid>
      <dc:creator>Bill_Chambers</dc:creator>
      <dc:date>2016-05-11T03:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: graceful dbutils mount/unmount</title>
      <link>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29750#M21457</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;On my side, I tested if the mount point existed before mounted it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;if (!dbutils.fs.mounts.map(mnt =&amp;gt; mnt.mountPoint).contains("/mnt/&amp;lt;directory&amp;gt;"))
  dbutils.fs.mount(
    source = "adl://&amp;lt;datalake_name&amp;gt;.azuredatalakestore.net/&amp;lt;directory&amp;gt;",
    mountPoint = s"/mnt/&amp;lt;directory&amp;gt;",
    extraConfigs = configs)    &lt;/CODE&gt;&lt;/PRE&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 15:49:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29750#M21457</guid>
      <dc:creator>DonatienTessier</dc:creator>
      <dc:date>2018-10-22T15:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: graceful dbutils mount/unmount</title>
      <link>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29751#M21458</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;For python, you could do something like this: &lt;/P&gt;mountName = 'abc'
&lt;P&gt;&lt;/P&gt; 
&lt;P&gt;mounts = [str(i) for i in dbutils.fs.ls('/mnt/')] if "FileInfo(path='dbfs:/mnt/" +mountName + "/', name='" +mountName + "/', size=0)" in mounts: print(mountName + " has already been mounted") else: dbutils.fs.mount( source = "wasbs://"+mountName+"@&amp;lt;datalake_name&amp;gt;.blob.core.windows.net/", mount_point = "/mnt/" + mountName, extra_configs = {"fs.azure.sas."+ mountName +".&amp;lt;datalake_name&amp;gt;.blob.core.windows.net":dbutils.secrets.get(scope = "&amp;lt;secret_scope&amp;gt;", key = "&amp;lt;key_name&amp;gt;")}) &lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 07:11:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29751#M21458</guid>
      <dc:creator>__NikolajPurup</dc:creator>
      <dc:date>2018-11-14T07:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: graceful dbutils mount/unmount</title>
      <link>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29752#M21459</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Very nice! This is an equivalent if statement in Python:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;if any(mount.mountPoint == '/mnt/&amp;lt;directory&amp;gt;' for mount in dbutils.fs.mounts()): 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jan 2019 21:56:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29752#M21459</guid>
      <dc:creator>MatthewValenti</dc:creator>
      <dc:date>2019-01-30T21:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: graceful dbutils mount/unmount</title>
      <link>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29753#M21460</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;With a not for python no?&lt;/P&gt;
&lt;P&gt;if not any(mount.mountPoint == mountPoint for mount in dbutils.fs.mounts()):&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Apr 2019 02:13:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29753#M21460</guid>
      <dc:creator>Rodneyjoyce</dc:creator>
      <dc:date>2019-04-14T02:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: graceful dbutils mount/unmount</title>
      <link>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29754#M21461</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Is there a way to mount a drive with Databricks CLI, I want the drive to be present from the time the cluster boots up.. I want to use a mounted blob storage to redirect the logs.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 21:13:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29754#M21461</guid>
      <dc:creator>viswanathboga</dc:creator>
      <dc:date>2019-04-17T21:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: graceful dbutils mount/unmount</title>
      <link>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29755#M21462</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I guess you should create an init script that will be run when the cluster starts.&lt;/P&gt;
&lt;P&gt;I asked the question here: &lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.databricks.com/questions/17305/mount-blob-storage-with-init-scripts.html" target="test_blank"&gt;https://forums.databricks.com/questions/17305/mount-blob-storage-with-init-scripts.html&lt;/A&gt;&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 14:43:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29755#M21462</guid>
      <dc:creator>DonatienTessier</dc:creator>
      <dc:date>2019-04-18T14:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: graceful dbutils mount/unmount</title>
      <link>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29756#M21463</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt; If you use scala to mount a gen 2 data lake you could try something like this&lt;/P&gt;
&lt;P&gt; /&lt;I&gt;Gather relevant Keys&lt;/I&gt;/ &lt;/P&gt;
&lt;P&gt; var ServicePrincipalID = "" &lt;/P&gt;
&lt;P&gt; var ServicePrincipalKey = "" &lt;/P&gt;
&lt;P&gt; var DirectoryID = ""&lt;/P&gt;
&lt;P&gt;/&lt;I&gt;Create configurations for our connection&lt;/I&gt;/&lt;/P&gt;
&lt;P&gt;var configs = Map ("fs.azure.account.auth.type" -&amp;gt; "OAuth", &lt;/P&gt;
&lt;P&gt; "fs.azure.account.oauth.provider.type" -&amp;gt; "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider", "fs.azure.account.oauth2.client.id" -&amp;gt; ServicePrincipalID, &lt;/P&gt;
&lt;P&gt; "fs.azure.account.oauth2.client.secret" -&amp;gt; ServicePrincipalKey, "fs.azure.account.oauth2.client.endpoint" -&amp;gt; DirectoryID)&lt;/P&gt;
&lt;P&gt; // Optionally, you can add &amp;lt;directory-name&amp;gt; to the source URI of your mount point. &lt;/P&gt;
&lt;P&gt;if (dbutils.fs.mounts.map(mnt =&amp;gt; mnt.mountPoint).contains("/mnt/ventas")){&lt;/P&gt;
&lt;P&gt; "already mount"&lt;/P&gt;
&lt;P&gt; }else{ &lt;/P&gt;
&lt;P&gt; dbutils.fs.mount( source = "/", mountPoint = "/mnt/", extraConfigs = configs) } &lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2020 02:59:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/graceful-dbutils-mount-unmount/m-p/29756#M21463</guid>
      <dc:creator>Mariano_IrvinLo</dc:creator>
      <dc:date>2020-11-01T02:59:00Z</dc:date>
    </item>
  </channel>
</rss>

