Skip to content

Auto model download in the init phase is not working #389

@kyteinsky

Description

@kyteinsky

Describe the bug

Noticed today the snapshot_download function from huggingface_hub throws an error which comes from a call within the huggingface library. Not sure what changed but rolling back huggingface_hub until 1.1.0 does not solve it. tqdm had its last release in Nov 2024 so nothing changed there either.

Steps/Code to Reproduce

  1. in an ex-app set models to fetch:
MODELS_TO_FETCH = {
	"Nextcloud-AI/vosk-models": {
		"local_dir": persistent_storage(),
		"revision": "06f2f156dcd79092400891afb6cf8101e54f6ba2",
	}
}
  1. pass it in fastapi's lifetime function:
@asynccontextmanager
async def lifespan(app: FastAPI):
	set_handlers(app, enabled_handler, models_to_fetch=MODELS_TO_FETCH)
  1. register the app

Expected Results

/

Actual Results

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/nc_py_api/ex_app/integration_fastapi.py", line 194, in fetch_models_task
    models[model]["path"] = __fetch_model_as_snapshot(
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/nc_py_api/ex_app/integration_fastapi.py", line 261, in __fetch_model_as_snapshot
    return snapshot_download(
           ^^^^^^^^^^^^^^^^^^
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/huggingface_hub/utils/_validators.py", line 89, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/huggingface_hub/_snapshot_download.py", line 388, in snapshot_download
    bytes_progress = tqdm_class(
                     ^^^^^^^^^^^
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/tqdm/std.py", line 1001, in __init__
    raise (
tqdm.std.TqdmKeyError: "Unknown argument(s): {'name': 'huggingface_hub.snapshot_download'}"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/fastapi/applications.py", line 1139, in __call__
    await super().__call__(scope, receive, send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/applications.py", line 107, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/nc_py_api/ex_app/integration_fastapi.py", line 317, in __call__
    await self.app(scope, receive, send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/middleware/exceptions.py", line 63, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/routing.py", line 716, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/routing.py", line 736, in app
    await route.handle(scope, receive, send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/routing.py", line 290, in handle
    await self.app(scope, receive, send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/fastapi/routing.py", line 120, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/fastapi/routing.py", line 107, in app
    await response(scope, receive, send)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/responses.py", line 167, in __call__
    await self.background()
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/background.py", line 36, in __call__
    await task()
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/background.py", line 23, in __call__
    await run_in_threadpool(self.func, *self.args, **self.kwargs)
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/starlette/concurrency.py", line 32, in run_in_threadpool
    return await anyio.to_thread.run_sync(func)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/anyio/to_thread.py", line 61, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2525, in run_sync_in_worker_thread
    return await future
           ^^^^^^^^^^^^
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/anyio/_backends/_asyncio.py", line 986, in run
    result = context.run(func, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/nextcloud-docker-dev/workspace/server/apps-shared/live_transcription/.venv/lib64/python3.12/site-packages/nc_py_api/ex_app/integration_fastapi.py", line 200, in fetch_models_task
    raise ModelFetchError(f"Downloading of '{model}' failed.") from e
nc_py_api._exceptions.ModelFetchError: Downloading of 'Nextcloud-AI/vosk-models' failed.

Setup configuration

NC 33
huggingface_hub==1.2.3
nc-py-api==0.23.0
tqdm==4.67.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions