old_contents: import io
  import os
  from pathlib import Path
  import zipfile
  
  import appdirs
  import databroker
  from databroker_pack import unpack_inplace
  import requests
  
  
  DEFAULT_DATA_DIR = Path(appdirs.user_data_dir(), "bluesky_tutorial_data")
  
  
  def fetch_BMM_example(version=1):
      if "bluesky-tutorial-BMM" in databroker.catalog:
          return
      URL = "https://nsls2datasamples.blob.core.windows.net/bluesky-tutorial-example-data/BMM-example-v1.zip"
      directory = Path(
          os.getenv("BLUESKY_TUTORIAL_DATA", DEFAULT_DATA_DIR),
          "BMM_example_v1"
      )
      with requests.get(URL) as response:
          download = io.BytesIO(response.content)
          with zipfile.ZipFile(download) as archive:
              archive.extractall(directory)
          unpack_inplace(directory, "bluesky-tutorial-BMM")
      databroker.catalog.force_reload()
  
new_contents: import io
  import os
  from pathlib import Path
  from shutil import copyfileobj
  import sys
  import zipfile
  
  import appdirs
  import databroker
  from databroker_pack import unpack_inplace
  import requests
  from tqdm.auto import tqdm  # automatically chooses tqdm.tqdm or tqdm.notebook
  from tqdm.utils import CallbackIOWrapper
  
  
  DEFAULT_DATA_DIR = Path(appdirs.user_data_dir(), "bluesky_tutorial_data")
  data_dir = os.getenv("BLUESKY_TUTORIAL_DATA", DEFAULT_DATA_DIR)
  
  
  def _extractall_with_progress_bar(source, dest):
      "Unzip source into dest, updating a progress bar as we go."
      # Derived from https://stackoverflow.com/a/65513860rchive.extractall(directory)
      dest = Path(dest).expanduser()
      with zipfile.ZipFile(source) as zipf, tqdm(
          desc="Extracting",
          unit="iB",
          unit_scale=True,
          unit_divisor=1024,
          total=sum(getattr(i, "file_size", 0) for i in zipf.infolist()),
      ) as pbar:
          os.makedirs(dest, exist_ok=True)
          for i in zipf.infolist():
              if not getattr(i, "file_size", 0):  # directory
                  zipf.extract(i, os.fspath(dest))
              else:
                  with zipf.open(i) as fi, open(os.fspath(dest / i.filename), "wb") as fo:
                      copyfileobj(CallbackIOWrapper(pbar.update, fi), fo)
      print(f"Extracted to {dest}", file=sys.stderr)
  
  
  def _download_with_progress_bar(response, buffer):
      "Stream the data from the response into the buffer, updating a progress bar as we go."
      # Derived from https://stackoverflow.com/a/37573701
      total_size = int(response.headers.get("Content-Length", 0))
      block_size = 1024
      with tqdm(
          total=total_size, unit="iB", unit_scale=True, desc="Downloading"
      ) as progress_bar:
          for chunk in response.iter_content(block_size):
              progress_bar.update(len(chunk))
              buffer.write(chunk)
  
  
  def fetch_RSOXS_example(version=1):
      if "bluesky-tutorial-RSOXS" in databroker.catalog:
          return
      buffer = io.BytesIO()
      URL = "https://nsls2datasamples.blob.core.windows.net/bluesky-tutorial-example-data/RSOXS-example-v1.zip"
  
      directory = Path(data_dir, "BMM_example_v1")
      with requests.get(URL, stream=True) as response:
          _download_with_progress_bar(response, buffer)
      _extractall_with_progress_bar(buffer, directory)
      unpack_inplace(directory, "bluesky-tutorial-BMM")
      databroker.catalog.force_reload()
  
  
  def fetch_BMM_example(version=1):
      if "bluesky-tutorial-BMM" in databroker.catalog:
          return
      buffer = io.BytesIO()
      URL = "https://nsls2datasamples.blob.core.windows.net/bluesky-tutorial-example-data/BMM-example-v1.zip"
  
      directory = Path(data_dir, "BMM_example_v1")
      with requests.get(URL, stream=True) as response:
          _download_with_progress_bar(response, buffer)
      _extractall_with_progress_bar(buffer, directory)
      unpack_inplace(directory, "bluesky-tutorial-BMM")
      databroker.catalog.force_reload()
  
subject: Add progress bar, RSOXS example.