Skip to content

Commit

Permalink
Update importlib import
Browse files Browse the repository at this point in the history
  • Loading branch information
prouast committed Oct 26, 2024
1 parent 6a15d2e commit 633e870
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vitallens/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import importlib.resources
import logging
import math
import numpy as np
import os
from prpy.ffmpeg.probe import probe_video
from prpy.ffmpeg.readwrite import read_video_from_path
from prpy.numpy.image import crop_slice_resize
import sys
from typing import Union, Tuple
import urllib.request
import yaml

if sys.version_info >= (3, 9):
from importlib.resources import open_binary
else:
from importlib_resources import open_binary

from vitallens.constants import API_MIN_FRAMES, VIDEO_PARSE_ERROR

def load_config(filename: str) -> dict:
Expand All @@ -40,7 +45,7 @@ def load_config(filename: str) -> dict:
Returns:
loaded: The contents of the yaml config file
"""
with importlib.resources.open_binary('vitallens.configs', filename) as f:
with open_binary('vitallens.configs', filename) as f:
loaded = yaml.load(f, Loader=yaml.Loader)
return loaded

Expand Down

0 comments on commit 633e870

Please sign in to comment.