Skip to content

Added save_format to config.json and hub_utils.init()#242

Merged
BenjaminBossan merged 18 commits intoskops-dev:mainfrom
merveenoyan:format_in_config
Dec 13, 2022
Merged

Added save_format to config.json and hub_utils.init()#242
BenjaminBossan merged 18 commits intoskops-dev:mainfrom
merveenoyan:format_in_config

Conversation

@merveenoyan
Copy link
Copy Markdown
Collaborator

Big chunk of work is to refactor tests. TIL you could add parametrization to fixtures

This is a draft PR, feel free to skim through it but don't look for nits

Copy link
Copy Markdown
Member

@adrinjalali adrinjalali 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. you should also send a commit including the text [CI inference] in the commit message to run the inference tests.

Comment thread skops/hub_utils/_hf_hub.py Outdated
Comment thread skops/hub_utils/_hf_hub.py Outdated
Comment thread skops/hub_utils/_hf_hub.py Outdated
Copy link
Copy Markdown
Collaborator

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Not much to add from my side on top of what Adrin wrote.

Comment thread skops/hub_utils/tests/test_hf_hub.py Outdated
Comment thread skops/hub_utils/_hf_hub.py Outdated
merveenoyan and others added 4 commits December 9, 2022 13:10
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Copy link
Copy Markdown
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Thanks @merveenoyan

We also need an entry in the changelog

Comment thread skops/hub_utils/tests/test_hf_hub.py Outdated
Comment on lines +475 to +479
# a model card is needed for inference engine to work.
model_card = card.Card(
model, metadata=card.metadata_from_config(Path(destination_path))
)
model_card.save(Path(destination_path) / "README.md")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add a comment to remove when #207 is merged.

Comment thread skops/hub_utils/tests/test_hf_hub.py Outdated
Comment on lines +454 to +455
if file_format != "pickle":
return
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think instead of silently skipping the inference test, we should parameterize and only test for pickle, and when inference API starts working with .skops, we add it here.

@merveenoyan
Copy link
Copy Markdown
Collaborator Author

there was a problem with fixture temp_path with python 3.7 so I swapped it with mkdtemp instead.

Comment thread skops/hub_utils/tests/test_hf_hub.py Outdated
Comment thread docs/changes.rst Outdated
Comment on lines +54 to +55
- Add `model_format` argument to :meth:`skops.hub_utils.init` to write it
as a section to `config.json`. :pr:`242`by `Merve Noyan`_.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should go to v0.4 section.

merveenoyan and others added 2 commits December 9, 2022 20:33
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
@merveenoyan
Copy link
Copy Markdown
Collaborator Author

@adrinjalali I don't know I could swear adding it to v0.4 🥲🥲🥲 addressed both

@merveenoyan
Copy link
Copy Markdown
Collaborator Author

@adrinjalali ran black, apparently previous pre-commit didn't catch something (I looked at my CLI and it was all passed 🥲)

Copy link
Copy Markdown
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

Comment thread docs/changes.rst Outdated
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
@adrinjalali
Copy link
Copy Markdown
Member

I'll let @BenjaminBossan have another look and merge.

Copy link
Copy Markdown
Collaborator

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Implementation-wise, this looks good to me.

I have a small issue with the wording, please take a look if my concern is valid. Apart from that, I suggested a empty lines in the docstring for consistency.

Comment thread docs/changes.rst
Comment on lines +19 to +21
- Add `model_format` argument to :meth:`skops.hub_utils.init` to be stored in
`config.json` so that we know how to load a model from the repository.
:pr:`242` by `Merve Noyan`_.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If I didn't already know, I would be confused about what this new feature does. Maybe we should avoid the word "we" in the changes.rst and instead use more neutral language.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what do you suggest here @BenjaminBossan

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's not a blocker, so feel free to merge.

Maybe something like:

Add model_format argument to :meth:skops.hub_utils.init to be stored in
config.json, which is used to determine the format of the model file
(pickle or skops).

Comment thread skops/hub_utils/_hf_hub.py Outdated
``"text-regression"``, the data needs to be a ``list`` of strings.

model_format: str
The format used to persist the model. Can be ``"auto"``, ``"skops"``
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe it's just me, but when I read this docstring, it could also mean "the model format that is being used [by this function] to persist the model", when what it really means is "the model format that was used to persist the model [by the user]". The former interpretation could lead the user to believe that init will create a new model file using that format. E.g. when I have a pickle file and I use model_format="skops", then init will create a skops file from the pickle file for me.

Something like "The format used by the persisted model" could help to disambiguate the two meanings. WDYT?

The same ambiguity can be found in the docstring of _create_config but there it's less important, as it's internal.

Comment thread skops/hub_utils/_hf_hub.py
Comment thread skops/hub_utils/_hf_hub.py
Comment thread skops/hub_utils/_hf_hub.py
@merveenoyan
Copy link
Copy Markdown
Collaborator Author

@adrinjalali I accidentally asked for review 🥲

merveenoyan and others added 3 commits December 12, 2022 18:09
Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>
Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>
Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

LGTM, thanks. Last point is no blocker for merging.

Comment thread docs/changes.rst
Comment on lines +19 to +21
- Add `model_format` argument to :meth:`skops.hub_utils.init` to be stored in
`config.json` so that we know how to load a model from the repository.
:pr:`242` by `Merve Noyan`_.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's not a blocker, so feel free to merge.

Maybe something like:

Add model_format argument to :meth:skops.hub_utils.init to be stored in
config.json, which is used to determine the format of the model file
(pickle or skops).

@BenjaminBossan BenjaminBossan merged commit 7ebf893 into skops-dev:main Dec 13, 2022
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.

3 participants