-
Notifications
You must be signed in to change notification settings - Fork 632
Initial working version using Pydantic for type annotations #378
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
Conversation
8257c15 to
e256051
Compare
f6f9f70 to
6c7be59
Compare
| # Cog: Containers for machine learning | ||
|
|
||
| Use Docker for machine learning, without all the pain. | ||
| Put your machine learning model in a standard, production-ready Docker container without having to know how Docker works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
| ``` | ||
|
|
||
| That's it! Your model will now run forever in this reproducible Docker environment. | ||
| <!-- In development, you can also run arbitrary commands inside the Docker environment: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tinkering with this. Perhaps it's more clear what Cog is for (packaging models into Docker containers) when there isn't the diversion into development environments.
| You can provide more information about the input with the `Input()` function, as shown above. It takes these basic arguments: | ||
|
|
||
| - `description`: A description of what to pass to this input for users of the model | ||
| - `default`: A default value to set the input to. If this argument is not passed, the input is required. If it is explicitly set to `None`, the input is optional. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this argument is not passed, the input is required. If it is explicitly set to
None, the input is optional.
👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be an argument for a more explicit, easier to understand design here. #114 Not sure what is best.
0f0162e to
4f934b3
Compare
Signed-off-by: Ben Firshman <[email protected]>
Signed-off-by: Ben Firshman <[email protected]>
Signed-off-by: Ben Firshman <[email protected]>
Signed-off-by: Ben Firshman <[email protected]>
Signed-off-by: Zeke Sikelianos <[email protected]>
Signed-off-by: Zeke Sikelianos <[email protected]>
..even when the user-defined predict function returns a simple type like a string. Co-Authored-By: Ben Firshman <[email protected]> Signed-off-by: Zeke Sikelianos <[email protected]>
Signed-off-by: Ben Firshman <[email protected]>
Signed-off-by: Zeke Sikelianos <[email protected]>
As a convenience for `from pydantic import BaseModel` Signed-off-by: Ben Firshman <[email protected]>
Signed-off-by: Zeke Sikelianos <[email protected]>
Signed-off-by: Zeke Sikelianos <[email protected]>
Signed-off-by: Zeke Sikelianos <[email protected]>
ec6b041 to
1fdff82
Compare
|
👍 To summarize an IRL conversion: we chose the extremely cool name "future" for the branch. I have:
We're ready to get this into our future branch, I think! Next steps, once this is in:
|
zeke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The future looks bright. 😎
Ship it (to a feature branch)! 🚢
|
I have added a few tickets for the far flung future that can be seen in the mentions above. They're in the "next" status in our project to remind us to look at them before we ship new Cog. |
The exploration in #343 was sufficiently explored and getting very messy, so I thought I would create a new pull request for the real implementation.
This is an implementation of #193, #205, and #259 using Pydantic for the type system, FastAPI for the model server, and OpenAPI for the schema.
Models now look a bit like this:
The HTTP model server is a work in progress and will be finalized as part of future work.
The Redis queue worker remains in place and the API is unchanged. As part of future work we will implement an AMQP API with a better API.
Commits are significant and this should be reviewed commit by commit. This is an intentionally large and long-running branch --
mainis currently used as the documentation for Replicate.Todo
cog predictwith new APIchoicesoption toInputto generate anEnum.cog inittemplatePredictortoBasePredictorso we can dofrom cog import BasePredictor, Input, Pathwithout colliding with aPredictorsubclass.Reliably set Cog version. In development, the version is set toWe're just going to support version0.0.1which is pretty useless. It should probably be hardcoded somewhere, and the release process needs updating. We need this to be able to switch between old and new Cog API in Replicate.deveverywhere which means "latest".go.sumup to date?Future (Pydantic + OpenAPI)
@cog.input()with new Cog.@input()to Pydantic type annotations.cog predictin a simple way until we lock down HTTP APIAny, but they need to be explicit!)cog predictwith an existing image backwards compatible? ('cos there are old models on Replicate)pathlib.Pathas an input type? Does it work? Should we throw an error? (This might happen if you import wrong package / collide imports)pathlib.Pathfrom a predict function? Does this work? Should it throw an error?additionalProperties? Should we even allow extra properties tocog.Input()?Far-flung future
cog predict. It currently just outputs the plain JSON if there isn't a single file output.inputlevel so we can have top-level request options?/predict?Based on (& blocked by)
Refs
Closes #58
Closes #113
Closes #193
Closes #205
Closes #212
Closes #246
Closes #259
Closes #262
Closes #263
Closes #304
Closes #306
Closes #327
Closes #328