Cogreqs
Cogreqs is an experimental drop-in replacement for cog init that intelligently populates cog.yaml.
Installation
pip install cogreqs
Usage
Run the following command in an existing Python repository:
$ cogreqs --gpu .
Wrote cog.yaml
Wrote predict.py
cog.yaml may now contain something like
# Configuration for Cog ⚙
# Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md
build:
# set to true if your model requires a GPU
gpu: true
# a list of ubuntu apt packages to install
system_packages:
- "ffmpeg"
- "libsndfile-dev"
# python version in the form '3.8' or '3.8.12'
python_version: "3.8"
# a list of packages in the format <package-name>==<version>
python_packages:
- "librosa==0.9.1"
- "numpy==1.22.2"
- "scipy==1.8.0"
- "torch==1.10.2"
# commands run after the environment is setup
run:
NOTE: Cogreqs outputs a predict.py that's only compatible with the future branch of Cog. Until that branch is merged into main, install Cog from https://github.com/replicate/cog/releases/tag/v0.1.0-alpha
You can also output the generated cog.yaml contents to stdout:
$ cogreqs --config-path=- --predict-path=/dev/null .
# Configuration for Cog ⚙
# Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md
build:
[...]
CLI reference
usage: cogreqs [-h] [-f] [-g] [--config-path CONFIG_PATH] [--predict-path PREDICT_PATH] folder
Generate cog.yaml and predict.py from an existing repository. This is an experimental alternative to
cog init
positional arguments:
folder Project folder
optional arguments:
-h, --help show this help message and exit
-f, --force-overwrite
Overwrite existing cog.yaml and predict.py
-g, --gpu Use GPU
--config-path CONFIG_PATH
Config file path (default cog.yaml)
--predict-path PREDICT_PATH
Predict file path (default predict.py)
How does it work?
Cogreqs uses pipreqs to extract requirements from Python files in a repository. It then applies a sequence of heuristics on those requirements to populate python_packages and system_packages in cog.yaml.
For example, cogreqs knows that librosa requires the ffmpeg and libsndfile-dev system packages so it will add those to system_packages if librosa is one of the python requirements.
Work in progress!
This project is very much work in progress. Please submit an issue or pull request if you have ideas for heuristics or other features!
Metadata
Release files for cogreqs 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cogreqs-0.0.6.tar.gz | 9.1 kB | Without provenance | Details for cogreqs-0.0.6.tar.gz |
Release files / cogreqs-0.0.6.tar.gz
| Download URL | cogreqs-0.0.6.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fee54a89fbebe63d29700e94ea2a44881e3a31d184f78f088ecce99daa4b8e00
|
|
BLAKE2b-256 checksum How to use checksums |
fd988050518a758910d64ec31787db30cb638c9ec6552e12ef389e28fa7e6902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Security for cogreqs 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.