Cog

Latest version: v0.9.9

Safety actively analyzes 639658 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 20 of 24

0.1.5

0aa109c Clean up console package
c02b0a3 Disable Tensorflow package picking for CPU
f451eea Display log output for predict
bb220c1 Explain how inputs are passed to model
6dcaf31 Fix git lfs install instructions
fd86dc8 Fix goreleaser setting version
ca4908b Fix queue worker test
317a809 Fix release
3904768 Move Dockerfile generation to a separate package
d6bee41 Move Python package into separate directory
9839a72 Move pkg/model into pkg/config
3d45495 Move runtime LD_LIBRARY_PATH envvar to dockerfile
87b9dc9 Move source code directory to /src
070d331 Print stderr from predict server
ff53d2a Re-introduce Mac M1 builds with buildx
47b56dc Refactor predict and run to share code
20cd4bd Remove Dockerfile section labels
be4fc8d Remove server and client
1a5177b Remove terminal package
edb0d88 Remove workdir option from cog.yaml
36f3bcb Rename `cog.Model` to `cog.Predictor`
9f9e00c Rename `environment` to `build`
669e0b9 Rename end-to-end-test to test-integration
9e8fdd3 Replace helper scripts with Python

0.1.4

Changelog
* dd9e228 Add Schema test for int enums
* 50c0295 Bump github.com/docker/cli (510)
* 20b3a0e Bump github.com/golangci/golangci-lint from 1.44.2 to 1.45.0 (501)
* cad7cfb Bump github.com/golangci/golangci-lint from 1.45.0 to 1.45.2 (509)
* 9c7c4a9 Bump github.com/stretchr/testify from 1.7.0 to 1.7.1
* 556dcfc Bump golang.org/x/tools from 0.1.9 to 0.1.10 (492)
* 709c807 Fix int enums
* 5dc27a2 Update README (507)
* e08392e document input and output types (503)
* 244a811 fix invalid empty lists from `cog init` (493)
* 7464b27 make heredocs consistent for Request and Response
* 451882a remove stops from heredocs for consistency
* 4505b80 s/build, ship, run/package/ (508)
* 9c26117 use `ge` and `le` options in predictor template

0.1.3

Changelog
* 12707a1 Bump github.com/docker/cli
* eeff3cd Bump github.com/docker/docker
* afe6826 Bump github.com/getkin/kin-openapi from 0.91.0 to 0.92.0 (487)
* e1d5729 Bump github.com/spf13/cobra from 1.3.0 to 1.4.0
* 34ae4d6 Fix yielding predictor cleanup bug in HTTP server
* 3f7bfa6 Remove lies (477)
* 814f002 Support int choices
* d39709c document `cog debug dockerfile` (474)

0.1.2

A little release that fixes the `choices` option to `Input` and progressive output when there are input files.

Changelog
* 7464588 Add redis queue test for inputting and yielding files
* bc3ea9d Add type to Response.status schema
* 5184cab Add types to enums in the schema
* 6c6988d Bump github.com/getkin/kin-openapi from 0.90.0 to 0.91.0
* 5dec7f2 Fix yielding predictor cleanup bug
* 4898008 Remove cog.Predictor
* 5d6197f document how to yield progressive output

0.1.1

This small release includes support for progressive output. [(docs forthcoming)](https://github.com/replicate/cog/issues/435).

👉🏼 If you're upgrading from 0.0.x, see the [0.1.0 release notes](https://github.com/replicate/cog/releases/tag/v0.1.0) for details on how to upgrade your model to be compatible with 0.1.x versions.

Changelog
* e5497b8 Fix progressive output being one iteration behind
* aa30ec7 Make progressive output a list
* cf94f63 Show a replicate.com link after pushing to r8.im

0.1.0

👷‍♀️ This new version of Cog includes significant changes from previous versions. If you encounter any problems using it, please [open an issue](https://github.com/replicate/cog/issues) and we'll help you out! :octocat:

What's changed?

It's all about the schema! `{...}`

Cog's [Python API](https://github.com/replicate/cog/blob/main/docs/python.md) has been updated to use the popular [Pydantic](https://pydantic-docs.helpmanual.io/) library under the hood. Pydantic makes use of Python's [type annotations](https://dev.to/dan_starner/using-pythons-type-annotations-4cfe) (a native feature of the Python language) to help validate your code and prevent runtime errors. But perhaps most importantly, Pydantic can convert a Python file into a JSON schema.

Cog now generates a JSON schema from the Predictor you've defined in your `predict.py` file, and uses another popular Python package called [FastAPI](https://fastapi.tiangolo.com/) to dynamically build an OpenAPI schema and HTTP web server that can be used as a JSON API to generate predictions from your model. And because it's using OpenAPI, this server also dynamically generates documentation specific to your model, and a Swagger UI interface for trying out the API.

With this new schema-focused design, the inputs and outputs you define for your model are converted into a portable, language-agnostic structured data format. This helps guide us toward a more **standardized way of defining model interfaces** and paves the way to better documentation, more automated tests, easier integrations across systems, and less reinventing the wheel.

Upgrading

First, [install Docker if you haven't already](https://docs.docker.com/get-docker/). Then run this in a terminal:

sh
sudo rm $(which cog) (if you have a previous version of cog installed)
sudo curl -o /usr/local/bin/cog -L https://github.com/replicate/cog/releases/latest/download/cog_`uname -s`_`uname -m`
sudo chmod +x /usr/local/bin/cog


Examples

To get a feel for the changes, check out the [replicate/cog-examples](https://github.com/replicate/cog-examples) repository which has been updated with examples supporting this new version:

- https://github.com/replicate/cog-examples/blob/main/blur/predict.py
- https://github.com/replicate/cog-examples/blob/main/hello-world/predict.py
- https://github.com/replicate/cog-examples/blob/main/resnet/predict.py

Upgrading from Cog 0.0.x to 0.1.x

Reference docs for Cog's new Python API can be found [here](https://github.com/replicate/cog/blob/cf94f63abd5d010bb14ec51c50c41c70d0f84055/docs/python.md).

In Cog versions up to 0.0.20, you described inputs using `cog.input` decorators on your `predict` method. For example:

py
cog.input("image", type=Path, help="Image to enlarge")
cog.input("scale", type=float, default=1.5, help="Factor to scale image by")
def predict(self, image, scale):
...


From Cog 0.1.0 onwards, we've started using [Pydantic](https://pydantic-docs.helpmanual.io/) to define input and output types. Rather than describing inputs using decorator annotations, you now describe them with Python's built-in type hinting. Here's how you'd define the same inputs now:

py
def predict(self,
image: Path = Input(description="Image to enlarge"),
scale: float = Input(description="Factor to scale image by", default=1.5)
) -> Path:
...


The parameters that `Input()` takes are pretty similar to those `cog.input()` used to take. Here are the differences:

- It no longer takes a `type` parameter; use a type hint instead.
- The `help` parameter has been renamed to `description`.
- The `options` parameter has been renamed to `choices`.
- The `min` option has been replaced with `ge` (greater than or equal to)
- The `max` option has been replaced with `le` (less than or equal to)

The other major difference is that you now need to define the output type of your model. That's the `-> Path` bit in the example above. That might be a simple type like `str`, `float` or `bool`. If you need to handle multiple outputs, check out the [new documentation for complex output objects](https://github.com/replicate/cog/blob/cf94f63abd5d010bb14ec51c50c41c70d0f84055/docs/python.md#outputbasemodel).

If you have any trouble using this new version of Cog, please [open an issue](https://github.com/replicate/cog/issues). :octocat:

Feedback

This new version of Cog includes a number of internal and user-facing changes from previous versions, so there could be some rough edges.

If you encounter any problems using it, please [open an issue](https://github.com/replicate/cog/issues) and we'll help you out! :octocat:

You can also chat with us on Discord at [discord.gg/replicate](https://discord.gg/replicate). 💬

Page 20 of 24

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.