跳转到主要内容

自动从仓库构建cog.yaml

项目描述

Cogreqs

Cogreqs是一个实验性的cog init替代品,它智能地填充cog.yaml

安装

pip安装cogreqs

使用方法

在现有的Python仓库中运行以下命令

$ cogreqs --gpu .

Wrote cog.yaml
Wrote predict.py

cog.yaml可能现在包含类似的内容

# 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:

注意:Cogreqs输出的predict.py仅与Cog的future分支兼容。直到该分支合并到主分支,请从https://github.com/replicate/cog/releases/tag/v0.1.0-alpha安装Cog

您还可以将生成的cog.yaml内容输出到stdout

$ cogreqs --config-path=- --predict-path=/dev/null .

# Configuration for Cog ⚙
# Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md

build:
[...]

CLI参考

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)

它是如何工作的?

Cogreqs使用pipreqs从仓库中的Python文件中提取需求。然后,它对这些需求应用一系列启发式方法,以填充cog.yaml中的python_packagessystem_packages

例如,Cogreqs知道librosa需要ffmpeglibsndfile-dev系统包,因此如果librosa是Python需求之一,它将添加这些到system_packages中。

工作正在进行中!

该项目仍在开发中。如果您有关于启发式方法或其他功能的想法,请提交问题或pull request!

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装软件包的信息。

源代码分发

cogreqs-0.0.6.tar.gz (9.1 kB 查看哈希)

上传于 源代码

支持者