Skip to content

Generic push_to_hub by adding optional save_fn #310

Open
@nateraw

Description

@nateraw

Something I've encountered in #284 and elsewhere (when integrating 3rd party libraries directly), is that folks may have to rewrite push_to_hub to fit their needs. However, it seems to me the only change you end up needing to make is specifying what needs to be saved.

I propose we do something like this:

  1. add a generic push_to_hub function.
  2. add a kwarg to this function, save_fn, that will allow users to pass a function that saves any assets specific to their model.

The logic would then look like the following:

def push_to_hub(model, save_directory, ..., save_fn=None):
    # Init/clone repo
    # ...

    # Run save func if provided or run the default if its not
    save_fn = save_fn or default_save_fn
    
    with repo.commit(commit_message):
        save_fn(model, save_directory, config)

    return repo.remote_url

What do you think? @LysandreJik @osanseviero

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions