Skip to content

Commit

Permalink
Add test for ffmpeg in base images (#2122)
Browse files Browse the repository at this point in the history
* Add test for ffmpeg in base images

* Add predict.py to ffmpeg test

* Fix pip_freeze integration test
  • Loading branch information
8W9aG authored Jan 24, 2025
1 parent b7aa7c3 commit 60017a9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
build:
gpu: true
python_version: "3.9"
python_packages:
- "torch==2.5.1"
cuda: "12.4"
run:
- command: ffmpeg --help
predict: "predict.py:Predictor"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from cog import BasePredictor


class Predictor(BasePredictor):
def predict(self, s: str) -> str:
return "hello " + s
22 changes: 20 additions & 2 deletions test-integration/test_integration/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,17 @@ def test_pip_freeze(docker_image):
labels = image[0]["Config"]["Labels"]
pip_freeze = labels["run.cog.pip_freeze"]
pip_freeze = "\n".join(
[x for x in pip_freeze.split("\n") if not x.startswith("cog @")]
[
x
for x in pip_freeze.split("\n")
if not x.startswith("cog @")
and not x.startswith("fastapi")
and not x.startswith("starlette")
]
)
assert (
pip_freeze
== "anyio==4.4.0\nattrs==23.2.0\ncertifi==2024.8.30\ncharset-normalizer==3.3.2\nclick==8.1.7\nexceptiongroup==1.2.2\nfastapi==0.115.6\nh11==0.14.0\nhttptools==0.6.1\nidna==3.8\npydantic==1.10.18\npython-dotenv==1.0.1\nPyYAML==6.0.2\nrequests==2.32.3\nsniffio==1.3.1\nstarlette==0.41.3\nstructlog==24.4.0\ntyping_extensions==4.12.2\nurllib3==2.2.2\nuvicorn==0.30.6\nuvloop==0.20.0\nwatchfiles==0.24.0\nwebsockets==13.0.1\n"
== "anyio==4.4.0\nattrs==23.2.0\ncertifi==2024.8.30\ncharset-normalizer==3.3.2\nclick==8.1.7\nexceptiongroup==1.2.2\nh11==0.14.0\nhttptools==0.6.1\nidna==3.8\npydantic==1.10.18\npython-dotenv==1.0.1\nPyYAML==6.0.2\nrequests==2.32.3\nsniffio==1.3.1\nstructlog==24.4.0\ntyping_extensions==4.12.2\nurllib3==2.2.2\nuvicorn==0.30.6\nuvloop==0.20.0\nwatchfiles==0.24.0\nwebsockets==13.0.1\n"
)


Expand Down Expand Up @@ -434,3 +440,15 @@ def test_pydantic2(docker_image):
)

assert build_process.returncode == 0


def test_ffmpeg_base_image(docker_image):
project_dir = Path(__file__).parent / "fixtures/ffmpeg-package"

build_process = subprocess.run(
["cog", "build", "-t", docker_image],
cwd=project_dir,
capture_output=True,
)

assert build_process.returncode == 0

0 comments on commit 60017a9

Please sign in to comment.