Mapping Local Directories Examples and Reference

This documentation is for Dash Enterprise,
Plotly’s commercial platform for managing and improving
Dash applications in your organization.
View the docs or
request a trial.

In Dash Enterprise, Dash Apps are run in isolated containers.
Dash Enterprise builds the entire system for each individual app
from scratch, including installing a fresh instance of Python, installing
dependencies, and more. This isolation and containerization is great: it
allows for one app’s dependencies to not impact the next app’s and,
from a security perspective, ensures that applications can’t modify or
access the underlying server. One part of this isolation is that each app
has its own “ephemeral” filesystem. This means that:

  • By default, files that are saved in the app’s environment aren’t
    persisted across deploys.
  • By default, files (even networked file systems) that are on the actual
    physical server aren’t actually accessible to the application.

 

Starting in Plotly Enterprise 2.5.0, you can map filesystems from the
underlying server into the application. This allows you to save files
persistently as well as read files from the underlying server, including
networked file systems.

Since this feature has security implications, only directories specified
in the Plotly-On-Premise Server Manager can be mapped to Dash Apps.

Note that in Plotly Enterprise versions before 3.1.0 only users with admin privileges
could map local directories into their apps. Please contact onpremise.support@plotly.com if
you have any questions.


Approve Directories for Mapping

A server administrator with access to https://<your.plotly.domain>:8800/settings
can allow certain directories on the host server to be mapped to dash apps. Go to
the Allowed Directories for Mapping section of the settings page and add the path(s)
of approved directories.

Add Admin/Superuser Status

Add Directory Mapping

To add a directory mapping via the Dash Enterprise UI,
navigate to the application Settings and scroll down to
Directory Mappings. Here, use the text boxes to
add the Host Path and App Path. For example, /srv/app-data
and /data.

Add Directory Mapping

 

If the directory you’re trying to map from isn’t admin-approved, you will see an error
message.

 

Add Directory Mapping

Referencing the File System in Your Code

If you have mapped the directory from /srv/app-data to /data, then you
can read files from this folder in your application with the following code:

import os
file_pathname = os.path.join(os.sep, 'data', 'my-dataset.csv')

 

In some cases, the filesystems that you reference in your deployed
application may be different from those that you reference locally.
In your application code, you can check which environment you are in
with the following code:

if 'DASH_APP_NAME' in os.environ:
    # this is a deployed app
    filepath = os.path.join(os.sep, 'data', 'my-dataset.csv')
else:
    # local file path
    filepath = os.path.join(os.sep, 'Users', 'chris', 'data', 'my-dataset.csv')

Recommendations

If you are mounting a filesystem, we have the following recommendations:


Remove Directory Mapping

To remove directory mappings via the Dash Enterprise UI,
navigate to the application Settings and scroll down to
Directory Mappings. Next, use the red cross situated to the
right-hand side of the environment variable.

Remove Directory Mapping