Added new file format param to skops snippet script#417
Conversation
|
The current code snippet does not work I think. E.g. go to https://huggingface.co/Ramos-Ramos/emb-gam-dino-resnet The snippet is from skops.hub_utils import download
from skops.io import load
download("Ramos-Ramos/emb-gam-dino-resnet", "path_to_folder")
# make sure model file is in skops format
# if model is a pickle file, make sure it's from a source you trust
model = load("path_to_folder/model.pkl")If you try the above, it will give an error The expectation is actually to use named arguments download(repo_id="Ramos-Ramos/emb-gam-dino-resnet", dst="emb-gam-dino-resnet")But then model = load("path_to_folder/model.pkl")Gives me an error What did work for me was Could we update the auto-snippet for it to work end to end? |
|
@osanseviero I'm working on this PR: skops-dev/skops#242 (my work is done, waiting for review) |
| const skopssaveFormat = model.config?.sklearn?.save_format; | ||
| if (skopssaveFormat == "pickle") | ||
| { | ||
| return `download("${model.id}", "path_to_folder") |
There was a problem hiding this comment.
Please add the imports at the top, and also with from skops.hub_utils import download which is not in this one
|
@osanseviero please don't review until I can test it 😅 (had a problem in codespaces) |
|
The work on this is done: skops-dev/skops#242 (just made a mistake on changelog, fixed it) we can merge this one after that one. |
osanseviero
left a comment
There was a problem hiding this comment.
The results look nice! I think we might want to:
- Keep showing security message for joblib as we were doing before
- Looking at the file (), there are some minor indentation/formatting issues in the sklearn function. Please try to be consistent (e.g. opening curly braces in same line - 237/238; double indent in lines 247 and 254)
hub-docs/js/src/lib/interfaces/Libraries.ts
Line 236 in 02dc01d
| model = load("path_to_folder/${skopsmodelFile}")`; | ||
| } else { | ||
| } | ||
| } else { |
There was a problem hiding this comment.
Should we bring the security warning back?
There was a problem hiding this comment.
brought it back
| model = load("path_to_folder/${skopsmodelFile}")`; | ||
| } else { | ||
| } | ||
| } else { |
There was a problem hiding this comment.
Please unindent the closing ) in the vanilla sklearn code snippet
|
This looks good to me, but I'm more comfortable if @osanseviero has a final look before merging. |
|
@adrinjalali we need to merge the one on @osanseviero |
|
In your code snippet you do But there is no |
|
@osanseviero screenshot has the one I'm using for build and it doesn't say 'model_format', it does 'fileformat', hence it gets into the if with 'pickle' (see what's logged) (the code in the HEAD is not updated, don't check that) |
|
I guess I was using a wrong version on moon-landing and everything was working fine. @osanseviero 😂 We can merge after this one is merged: https://github.com/skops-dev/skops/pull/242 |
Co-authored-by: Omar Sanseviero <osanseviero@gmail.com>
|
@osanseviero updated variable name in accordance to moon-landing |
|
@osanseviero can we merge this since one in moon-landing is merged? |
osanseviero
left a comment
There was a problem hiding this comment.
Feel free to merge :)









As discussed with @rajshah4 in Slack, it's better to state explicitly to load a model using pickle if it's a pickle file. Also cc @adrinjalali