Azure machine Learning Workspace Notebooks - write sqlite files

Daun (Daniel) Lee 125 Reputation points
2025-11-21T07:54:22.0066667+00:00

Hi,

I am running this and AML notebooks not accepting SQLite writing process due to SQL lock.

db = Chroma.from_documents(
    docs, emb,
    persist_directory="chroma_db" # not working

)

But not saving/writing and the cell is not fininshing but keeps running on and on.

Requirements

  1. sqlite or chromadb write function must work
  2. Must show on AML Workspace Notebooks : “/home/azureuser/cloudfiles/code/Users/here_new_folder", neither /tmp nor “/home/azureuser”

Previous Attempts

"chroma_db" : cell not finishing

“./chroma_db" : cell not fininshing

“~/chroma_db” : cell not fininshing

“/home/azureuser” : working but not a path showing AML notebooks UI # SSD

“/home/azureuser/cloudfiles/code/Users/lc03” # pwd path from terminal : not working

"/mnt/batch/tasks/shared/LS_root/mounts/clusters/compute03lc/code/Users/lc03/Ch2_RAG/chroma1" # pwd path from .ipynb : not working

Please provide me with proper SQLite Saving Path.

Thank you.

Azure Machine Learning
{count} votes

Answer accepted by question author
  1. SRILAKSHMI C 10,885 Reputation points Microsoft External Staff Moderator
    2025-11-21T11:23:25.8366667+00:00

    Hello Daun (Daniel) Lee,

    Welcome to Microsoft Q&A.

    Thank you for sharing the details and all the paths you’ve already tried. What you’re seeing is expected behavior in Azure Machine Learning (AML) notebooks. The issue occurs because SQLite requires exclusive file-locking, but many directories in AML notebooks are FUSE-mounted or shared, which prevents SQLite/Chroma from acquiring the lock causing the cell to run indefinitely.

    Below is the recommended guidance, combining troubleshooting steps and correct AML filesystem behavior:

    Where SQLite / Chroma can successfully write in AML

    1. User workspace directory

    Supports SQLite locking and appears in Notebook Explorer.

    Use this path format:

    /home/azureuser/cloudfiles/code/Users/<your-username>/chroma_db
    

    Example code:

    import os
    
    persist_directory = "/home/azureuser/cloudfiles/code/Users/<your-username>/chroma_db"
    os.makedirs(persist_directory, exist_ok=True)
    
    db = Chroma.from_documents(
        docs,
        emb,
        persist_directory=persist_directory
    )
    

    SQLite locking works, Visible in AML UI, Persistent across compute restarts

    2. Local SSD ephemeral storage

    /mnt/azureml/cr/
    

    Fast, Locking supported, not visible in UI, not persistent

    Directories where SQLite will NOT work

    These paths are FUSE-mounted → SQLite file-locking fails:

    ./chroma_db

    ~/chroma_db

    /home/azureuser/cloudfiles/... (certain internal subfolders)

    /mnt/batch/tasks/...

    /home/azureuser root

    /tmp

    Notebook mount paths inside /mnt/.../code/...

    These cause your cell to "hang" because SQLite waits forever on a lock.

    Troubleshooting & Best Practices

    (Merged from your list + correct AML behavior)

    Ensure the folder exists

    os.makedirs("chroma_db", exist_ok=True)
    

    Make sure no other process holds a lock

    If another notebook/cell is using the same SQLite DB, Chroma may hang.

    Try saving locally then moving

    Save in /mnt/azureml/cr/ first, then move into cloudfiles if needed.

    Validate permissions

    Use only directories where your workspace user has write access.

    Check known Azure ML notebook issues

    Some updates temporarily affect write behavior on mounted paths.

    Consider ADLS for persistence

    If long-term durability is needed, you can export the Chroma folder to ADLS after creation.

    Consider DuckDB if issues continue

    DuckDB handles cloud-mounted filesystems better than SQLite.

    Recommended Solution

    Use the workspace-visible directory the only one that meets all your requirements:

    Path:

    /home/azureuser/cloudfiles/code/Users/<your-username>/chroma_db
    

    Code:

    import os
    
    persist_directory = "/home/azureuser/cloudfiles/code/Users/<your-username>/chroma_db"
    os.makedirs(persist_directory, exist_ok=True)
    
    db = Chroma.from_documents(
        docs,
        emb,
        persist_directory=persist_directory
    )
    

    This ensures:

    SQLite writes succeed, no locking issues, Folder appears in AML Notebooks UI, fully persistent.

    I Hope this helps. Do let me know if you have any further queries.

    Thank you!

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.