Skip to content

Adding the convert scripts which will now prevent converting models#59

Merged
Narsil merged 2 commits intomainfrom
updating_convert_script_to_include_warnings_as_failures
Nov 4, 2022
Merged

Adding the convert scripts which will now prevent converting models#59
Narsil merged 2 commits intomainfrom
updating_convert_script_to_include_warnings_as_failures

Conversation

@Narsil
Copy link
Copy Markdown
Contributor

@Narsil Narsil commented Nov 4, 2022

in case they will trigger warnigns in the transformers side.
Even if the model is perfectly fine, core maintainers fear an influx
of opened issues.

This is perfectly legit.
On the transformers side fixes are on the way: huggingface/transformers#20042

We can wait for this PR to hit main before communicating super widely.

In the meantime this script of convertion will now prevent converting
models that would trigger such warnings (so the output of the script
will depend on the transformers freshness.

in case they will trigger warnigns in the `transformers` side.
Even if the model is perfectly fine, core maintainers fear an influx
of opened issues.

This is perfectly legit.
On the `transformers` side fixes are on the way: huggingface/transformers#20042

We can wait for this PR to hit `main` before communicating super widely.

In the meantime this script of convertion will now prevent converting
models that would trigger such warnings (so the output of the script
**will** depend on the `transformers` freshness.
@Narsil Narsil requested a review from sgugger November 4, 2022 14:11
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.

Copy link
Copy Markdown
Contributor

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Thanks for adding this!

pt_model = pt_model
sf_model = sf_model
if pt_infos != sf_infos:
raise ValueError(f"different infos {model_id}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe add some info on the differences?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's quite noisy which is why I didn't include it (I mean infos can be quite numerous even on pure PT for transformers).

Doing a proper diff could help mitigate that but also relatively verbose code. I'll give it a stab.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Diff added.



def convert(api: "HfApi", model_id: str, force: bool=False) -> Optional["CommitInfo"]:
def convert(api: "HfApi", model_id: str, force: bool = False) -> Optional["CommitInfo"]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Didn't catch this before but we shouldn't use any api object and just the top level methods (create_commit is directly in the main init).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why ?

I figured it was actually better to pass around an HfApi codewise, so you can include a specific token (for instance to create conversions directly).
The original space convertion was passing around a Token, but I figure HfApi was even easier to transport around and there's less risk to forget to include token=token in whatever call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think anyone who uses hugginface_hub uses the HfApi object.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You should include a kwarg for token instead IMO

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 don't think anyone who uses hugginface_hub uses the HfApi object.

I do :)

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 feature of setting a token on HfApi is quite recent though, but it's useful IMO)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let me rephrase, I don't think many people except Julien use HfApi :-p

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did use it naturally actually an I think it's pretty cool to encapsulate common client options (most important of which the token).

I really think the "oh but you forgot to pass the token" is a real failure case, and it did happen when I used get_repo_discussions where I failed to pass the token and it would fail on private models on the space.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll go ahead and merge this.

Please open an issue if you feel so strongly about the HfApi object :)

@Narsil Narsil merged commit 764ff0f into main Nov 4, 2022
@Narsil Narsil deleted the updating_convert_script_to_include_warnings_as_failures branch November 4, 2022 16:39
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.

4 participants