Skip to content

Commit

Permalink
python: don't use importlib as_file for a directory
Browse files Browse the repository at this point in the history
The only reason to use as_file is to support copying a file from a
frozen package. We don't currently support this anyway, and as_file
isn't supported until Python 3.9, so get rid of it.

Fixes nomic-ai#1605
  • Loading branch information
cebtenzzre committed Dec 11, 2023
1 parent 1df3da0 commit 778264f
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions gpt4all-bindings/python/gpt4all/pyllmodel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import atexit
import ctypes
import importlib.resources
import logging
Expand All @@ -8,20 +7,14 @@
import subprocess
import sys
import threading
from contextlib import ExitStack
from queue import Queue
from typing import Callable, Iterable, List

logger: logging.Logger = logging.getLogger(__name__)


file_manager = ExitStack()
atexit.register(file_manager.close) # clean up files on exit

# TODO: provide a config file to make this more robust
MODEL_LIB_PATH = file_manager.enter_context(importlib.resources.as_file(
importlib.resources.files("gpt4all") / "llmodel_DO_NOT_MODIFY" / "build",
))
MODEL_LIB_PATH = importlib.resources.files("gpt4all") / "llmodel_DO_NOT_MODIFY" / "build"


def load_llmodel_library():
Expand Down

0 comments on commit 778264f

Please sign in to comment.