Skip to content

WorkspaceTree

laktory.models.resources.databricks.WorkspaceTree ยค

Bases: BaseModel, VirtualTerraformResource

Databricks Workspace Tree (collections of directories, notebooks and workspace files)

Examples:

import io

from laktory import models

tree_yaml = '''
source: ./source/
path: /.laktory/source
'''
tree = models.resources.databricks.WorkspaceTree.model_validate_yaml(
    io.StringIO(tree_yaml)
)

By default, file content is uploaded verbatim. Opt individual files into variable rendering (${vars.x} / ${{ expr }}) via render_paths - useful for deploying an environment-specific Databricks App source tree, for example. Resolved content is staged under settings.build_root, the original files on disk are never modified.

import io

from laktory import models

tree_yaml = '''
source: ./app/
path: /apps/myapp
render_paths:
- '*.json'
- configs/*.yaml
variables:
  env: dev
'''
tree = models.resources.databricks.WorkspaceTree.model_validate_yaml(
    io.StringIO(tree_yaml)
)

Files can be excluded from the tree with exclude_paths, using .gitignore syntax (including negation) - independent of git, so a file can be committed to the repo and still be kept out of the deployed tree. A real .gitignore found at the root of source can also be honored via use_gitignore, for the common case where "don't commit" and "don't deploy" coincide. Dotfiles and dot-directories (e.g. .git, .venv) are excluded by default; re-include one explicitly with a negated pattern (e.g. !.streamlit/, !.streamlit/**) - useful for a Databricks App source tree that relies on a dotdir like .streamlit/config.toml.

import io

from laktory import models

tree_yaml = '''
source: ./app/
path: /apps/myapp
exclude_paths:
- '*.log'
- build/
- '!.streamlit/'
- '!.streamlit/**'
use_gitignore: true
'''
tree = models.resources.databricks.WorkspaceTree.model_validate_yaml(
    io.StringIO(tree_yaml)
)
PARAMETER DESCRIPTION
access_controls

Access controls list

TYPE: list[AccessControl | VariableType] | VariableType DEFAULT: []

exclude_paths

Gitignore-style patterns, relative to source, identifying files and directories to exclude from the tree (e.g. ['.log', 'build/', '!build/keep.txt']). Matched with the same syntax as a .gitignore file (supports negation). Applied after the built-in dotfile/dot-directory exclusion and, when use_gitignore is enabled, after source/.gitignore - so it wins on conflicting/negated patterns, and can be used to re-include a dotdir (e.g. '!.streamlit/', '!.streamlit/*').

TYPE: list[str | VariableType] | VariableType DEFAULT: []

path

Workspace filepath for the tree. If not specified, workspace laktory root is used.

TYPE: str | VariableType DEFAULT: None

render_paths

Glob patterns, relative to source, identifying files whose content is variable-resolved (${vars.x} / ${{ expr }}) and staged under settings.build_root before upload (e.g. ['.json', 'configs/.yaml', 'settings/prod.yaml']). Matched with PurePosixPath.match() against each file's path relative to source - a bare pattern like '*.json' matches any file with that extension at any depth. Nothing is rendered by default.

TYPE: list[str | VariableType] | VariableType DEFAULT: []

source

Path to directory on local filesystem.

TYPE: str | VariableType

use_gitignore

If True and a .gitignore file exists at the root of source, its patterns are automatically applied when building the tree. Off by default, since it changes which files deploy based on a file unrelated to this resource. Governs git tracking, not deployment - use exclude_paths for files that are committed but shouldn't be deployed.

TYPE: bool | VariableType DEFAULT: False