Skip to content

Conversation

kyteinsky
Copy link
Contributor

@kyteinsky kyteinsky commented Jul 16, 2024

Models downloaded wrt models_to_fetch dict have the output path of the downloaded model files in the "path" key for each model.

@kyteinsky kyteinsky force-pushed the feat/snapshot-path-return branch 2 times, most recently from 28643c8 to 7ff191d Compare July 16, 2024 13:17
Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 94.65%. Comparing base (1bcd2b9) to head (ca87be0).

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     
Files Coverage Δ
nc_py_api/ex_app/integration_fastapi.py 24.51% <0.00%> (-0.33%) ⬇️

Copy link
Member

@bigcat88 bigcat88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@bigcat88
Copy link
Member

@kyteinsky should we merge this?

@kyteinsky
Copy link
Contributor Author

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

@bigcat88
Copy link
Member

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 <[email protected]>
@kyteinsky kyteinsky force-pushed the feat/snapshot-path-return branch from 7ff191d to 0b7f49c Compare July 18, 2024 11:28
@kyteinsky kyteinsky changed the title feat: return model_paths in fetch_models_task feat: store model download paths in "path" key Jul 18, 2024
@bigcat88 bigcat88 merged commit 1926973 into main Jul 18, 2024
@bigcat88 bigcat88 deleted the feat/snapshot-path-return branch July 18, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants