Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve typing of pipeline helper function #485

Merged
merged 35 commits into from
Jan 2, 2024
Merged

Improve typing of pipeline helper function #485

merged 35 commits into from
Jan 2, 2024

Conversation

xenova
Copy link
Collaborator

@xenova xenova commented Dec 29, 2023

A first attempt at improving the types inferred when creating a new pipeline.

image

Still to do: return actual call parameters instead of (...args: any[]) => any.

Closes #484.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@xenova
Copy link
Collaborator Author

xenova commented Dec 29, 2023

After a bit of tinkering, I think I've got a good solution, which I've tested with the image segmentation pipeline, since this was requested by @wesbos in the original issue.

typing-demo

This also means when you hover over the class name, you'll get example code to help you out.
typing-demo2

@kungfooman
Copy link
Contributor

Wow, very nice work! 💯 👍

@xenova xenova merged commit 38ec1d4 into main Jan 2, 2024
4 checks passed
@xenova xenova mentioned this pull request Jan 3, 2024
@vickkhera
Copy link

This changed the interface of pipeline() which broke my typescript. It should have caused a bump in minor version number at least, not just the patch number. See #504

@xenova
Copy link
Collaborator Author

xenova commented Jan 5, 2024

Hi there. This was fixed in a subsequent version (2.13.3), could you please upgrade and try again?

@vickkhera
Copy link

Hi there. This was fixed in a subsequent version (2.13.3), could you please upgrade and try again?

I updated to 2.13.4 when I noticed the breakage and just narrowed it down to 2.13.1 release.

Even with 2.13.4 I had to rewrite my TS code to work with these changes. They are good changes but they are breaking changes so should have caused a version bump rather than a patch level.

Specifically I had to change the type of the function returned by pipeline() and then the type returned by that generated function also changed for some but not all tasks.

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.

TypeScript Pipline Types for different models?
4 participants