Skip to content

Commit

Permalink
Improve error message for missing ffmpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
mthrok committed Sep 5, 2024
1 parent e447ef1 commit dc25fd1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conda_cpu_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Unit test
run: |
conda install -c file://${HOME}/package/ spdl
conda install -c conda-forge "ffmpeg==${{ matrix.ffmpeg-version}}"
conda install -c conda-forge "ffmpeg==${{ matrix.ffmpeg-version }}"
conda install -c pytorch numpy pytest pytorch numba
pytest -v \
tests/spdl_unittest/io/ \
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/conda_cuda_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ jobs:
- name: Unit test
run: |
conda install -c file://${HOME}/package/ spdl
conda install -c conda-forge "ffmpeg==${{ matrix.ffmpeg-version}}"
conda install -c conda-forge "ffmpeg==${{ matrix.ffmpeg-version }}"
conda install pytorch pytorch-cuda=${{ inputs.cu-version }} -c pytorch -c nvidia
conda install pytest numba
ffmpeg -version
python -c 'import logging;logging.basicConfig(level=logging.DEBUG);from spdl.lib import _libspdl;_libspdl.Demuxer'
pytest -v \
tests/spdl_unittest/cuda/
12 changes: 8 additions & 4 deletions src/spdl/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ def _import_libspdl() -> ModuleType:
]
# Newer FFmpeg first
libs.sort(reverse=True)
err_msgs = {}
for lib in libs:
_LG.debug("Importing %s", lib)
try:
ext = importlib.import_module(lib)
except Exception:
except Exception as err:
_LG.debug("Failed to import %s.", lib, exc_info=True)
err_msgs[lib] = str(err)
continue

try:
Expand All @@ -77,7 +79,9 @@ def _import_libspdl() -> ModuleType:

return ext

raise RuntimeError(
f"Failed to import libspdl. Tried {libs}. "
"Enable DEBUG logging to see details about the failure."
msg = (
"Failed to import libspdl. "
"Enable DEBUG logging to see details about the failure. "
", ".join(f"{k}: {v}" for k, v in err_msgs.items())
)
raise RuntimeError(msg)

0 comments on commit dc25fd1

Please sign in to comment.