Κοινή χρήση μέσω


What are workspace files?

A workspace file is a file in your Azure Databricks workspace file tree that is not one of the types listed as follows:

  • Notebooks
  • Queries
  • Dashboards
  • Genie spaces
  • Experiments

Other than these excluded types, workspace files can be any file type. Common examples include:

  • .py files used in custom modules.
  • .md files, such as README.md.
  • .csv or other small data files.
  • .txt files.
  • .whl libraries.
  • Log files.

For recommendations on working with files, see Recommendations for files in volumes and workspace files.

Your Azure Databricks workspace file tree can contain folders attached to a Git repository called “Databricks Git folders”. They have some additional limitations in file type support. For a list of file types supported in Git folders (formerly “Repos”), see Asset types supported in Git folders.

Important

Workspace files are enabled everywhere by default in Databricks Runtime version 11.2. For production workloads, use Databricks Runtime 11.3 LTS or above. Contact your workspace administrator if you cannot access this functionality.

What you can do with workspace files

Azure Databricks provides functionality similar to local development for many workspace file types, including a built-in file editor. Not all use cases for all file types are supported.

You can create, edit, and manage access to workspace files using familiar patterns from notebook interactions. You can use relative paths for library imports from workspace files, similar to local development. For more details, see:

Init scripts stored in workspace files have special behavior. You can use workspace files to store and reference init scripts in any Databricks Runtime versions. See Store init scripts in workspace files.

Note

In Databricks Runtime 14.0 and above, the the default current working directory (CWD) for code executed locally is the directory containing the notebook or script being run. This is a change in behavior from Databricks Runtime 13.3 LTS and below. See What is the default current working directory?.

Limitations

  • If your workflow uses source code located in a remote Git repository, you cannot write to the current directory or write using a relative path. Write data to other location options.
  • You cannot use git commands when you save to workspace files. The creation of .git directories is not allowed in workspace files.
  • Reading from workspace files using Spark executors (such as spark.read.format("csv").load("file:/Workspace/Users/<user-folder>/data.csv")) is not supported with serverless compute.
  • Executors cannot write to workspace files.
  • Symlinks are supported for target directories under the /Workspace root folder.
  • Workspace files can’t be accessed from user-defined functions (UDFs) on clusters with shared access mode on Databricks Runtime 14.2 and below.

File size limit

  • Workspace file size is limited to 500MB from the UI. The maximum file size allowed when writing from a cluster is 256 MB.

File access permission limit

Permission to access files in folders under /Workspace expire after 36 hours for interactive compute and after 30 days for jobs. Databricks recommends running long executions as jobs if they need /Workspace file access.

Enable workspace files

To enable support for non-notebook files in your Databricks workspace, call the /api/2.0/workspace-conf REST API from a notebook or other environment with access to your Databricks workspace. Workspace files are enabled by default.

To enable or re-enable support for non-notebook files in your Databricks workspace, call the /api/2.0/workspace-conf and get the value of the enableWorkspaceFileSystem key. If it is set to true, non-notebook files are already enabled for your workspace.

The following example demonstrates how you can call this API from a notebook to check if workspace files are disabled and if so, re-enable them.

Example: Notebook for re-enabling Databricks workspace file support

Get notebook