-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: store model download paths in "path" key #274
Conversation
28643c8
to
7ff191d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #274 +/- ##
==========================================
- Coverage 94.69% 94.65% -0.04%
==========================================
Files 47 47
Lines 5405 5407 +2
==========================================
Hits 5118 5118
- Misses 287 289 +2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@kyteinsky should we merge this? |
hey, I was working on your (and Andrey's) proposed solution to have a key in the models dict itself. It works like this. Is it too complex? class ModelConfig(dict):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def __setitem__(self, key, value):
if key == "path":
config["loader"]["hf_model_path"] = value
service.load_config(config)
save_config_file(config)
super().__setitem__(key, value)
# download models if "model_name" key is present in the config
models_to_fetch = None
cache_dir = os.getenv("APP_PERSISTENT_STORAGE", "models/")
if "model_name" in config["loader"]:
models_to_fetch = { config["loader"]["model_name"]: ModelConfig({ "cache_dir": cache_dir }) }
@asynccontextmanager
async def lifespan(_: FastAPI):
set_handlers(
fast_api_app=APP,
enabled_handler=enabled_handler,
models_to_fetch=models_to_fetch,
)
t = BackgroundProcessTask()
t.start()
yield |
I like it, it looks very nice :) |
Models downloaded wrt `models_to_fetch` dict have the output path of the downloaded model files in the "path" key for each model Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
7ff191d
to
0b7f49c
Compare
Models downloaded wrt
models_to_fetch
dict have the output path of the downloaded model files in the "path" key for each model.