Skip to content

Commit

Permalink
udpate tests + add platform before docker run
Browse files Browse the repository at this point in the history
  • Loading branch information
ejm714 committed Oct 29, 2024
1 parent 7e97ea1 commit 2280362
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 94 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CPU_OR_GPU ?= gpu
endif

BLOCK_INTERNET ?= true
PLATFORM_ARGS = --platform linux/amd64

TAG := ${CPU_OR_GPU}-latest
LOCAL_TAG := ${CPU_OR_GPU}-local
Expand Down Expand Up @@ -127,7 +128,7 @@ update-lockfile: runtime/pixi.lock
--tag pixi-lock:local
@echo Running lock container
docker run \
--platform linux/amd64 \
${PLATFORM_ARGS} \
--mount type=bind,source="$(shell pwd)"/runtime/pixi.toml,target=/tmp/pixi.toml \
--mount type=bind,source="$(shell pwd)"/runtime/pixi.lock,target=/tmp/pixi.lock \
--rm \
Expand All @@ -136,6 +137,7 @@ update-lockfile: runtime/pixi.lock
## Ensures that your locally built image can import all the Python packages successfully when it runs
test-container: _check_image _echo_image _submission_write_perms
docker run \
${PLATFORM_ARGS} \
${GPU_ARGS} \
${NETWORK_ARGS} \
${TTY_ARGS} \
Expand All @@ -147,6 +149,7 @@ test-container: _check_image _echo_image _submission_write_perms
## Open an interactive bash shell within the running container (with network access)
interact-container: _check_image _echo_image _submission_write_perms
docker run \
${PLATFORM_ARGS} \
${GPU_ARGS} \
${NETWORK_ARGS} \
--mount type=bind,source=${shell pwd}/data,target=/code_execution/data,readonly \
Expand Down Expand Up @@ -188,6 +191,7 @@ ifeq (,$(wildcard ./submission/submission.zip))
If you want to use the benchmark, you can run `make pack-example <benchmark name>` first)
endif
docker run \
${PLATFORM_ARGS} \
${TTY_ARGS} \
${GPU_ARGS} \
${NETWORK_ARGS} \
Expand Down
49 changes: 49 additions & 0 deletions runtime/pixi.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ environments:
linux-64:
- conda: https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2
- conda: https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-2_kmp_llvm.tar.bz2
- conda: https://conda.anaconda.org/conda-forge/noarch/accelerate-1.0.1-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/aiohappyeyeballs-2.4.3-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/aiohttp-3.10.10-py312h178313f_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/aiosignal-1.3.1-pyhd8ed1ab_0.tar.bz2
Expand Down Expand Up @@ -234,6 +235,7 @@ environments:
- conda: https://conda.anaconda.org/conda-forge/noarch/pluggy-1.5.0-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/pooch-1.8.2-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/propcache-0.2.0-py312h66e93f0_2.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/psutil-6.1.0-py312h66e93f0_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/pthread-stubs-0.4-hb9d3cd8_1002.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/pyarrow-18.0.0-py312h9cebb41_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/pyarrow-core-18.0.0-py312h01725c0_0_cpu.conda
Expand Down Expand Up @@ -323,6 +325,7 @@ environments:
linux-64:
- conda: https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2
- conda: https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-2_kmp_llvm.tar.bz2
- conda: https://conda.anaconda.org/conda-forge/noarch/accelerate-1.0.1-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/aiohappyeyeballs-2.4.3-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/aiohttp-3.10.10-py312h178313f_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/aiosignal-1.3.1-pyhd8ed1ab_0.tar.bz2
Expand Down Expand Up @@ -547,6 +550,7 @@ environments:
- conda: https://conda.anaconda.org/conda-forge/noarch/pluggy-1.5.0-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/pooch-1.8.2-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/propcache-0.2.0-py312h66e93f0_2.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/psutil-6.1.0-py312h66e93f0_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/pthread-stubs-0.4-hb9d3cd8_1002.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/pyarrow-18.0.0-py312h9cebb41_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/pyarrow-core-18.0.0-py312h01725c0_0_cpu.conda
Expand Down Expand Up @@ -637,6 +641,7 @@ environments:
linux-64:
- conda: https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2
- conda: https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-2_kmp_llvm.tar.bz2
- conda: https://conda.anaconda.org/conda-forge/noarch/accelerate-1.0.1-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/aiohappyeyeballs-2.4.3-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/aiohttp-3.10.10-py312h178313f_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/aiosignal-1.3.1-pyhd8ed1ab_0.tar.bz2
Expand Down Expand Up @@ -858,6 +863,7 @@ environments:
- conda: https://conda.anaconda.org/conda-forge/noarch/pluggy-1.5.0-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/noarch/pooch-1.8.2-pyhd8ed1ab_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/propcache-0.2.0-py312h66e93f0_2.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/psutil-6.1.0-py312h66e93f0_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/pthread-stubs-0.4-hb9d3cd8_1002.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/pyarrow-18.0.0-py312h9cebb41_0.conda
- conda: https://conda.anaconda.org/conda-forge/linux-64/pyarrow-core-18.0.0-py312h09cf70e_0_cuda.conda
Expand Down Expand Up @@ -967,6 +973,30 @@ packages:
purls: []
size: 5744
timestamp: 1650742457817
- kind: conda
name: accelerate
version: 1.0.1
build: pyhd8ed1ab_0
subdir: noarch
noarch: python
url: https://conda.anaconda.org/conda-forge/noarch/accelerate-1.0.1-pyhd8ed1ab_0.conda
sha256: 24e1592bd577d771e063fbdb3a17eaa80475253f315e82cdbfd05f9a23eb5d82
md5: 20218c491bf068aa51696734355498cb
depends:
- huggingface_hub >=0.21.0
- numpy >=1.17,<3.0.0
- packaging >=20.0
- psutil
- python >=3.8.0
- pytorch >=1.10.0
- pyyaml
- safetensors >=0.4.3
license: Apache-2.0
license_family: APACHE
purls:
- pkg:pypi/accelerate?source=hash-mapping
size: 218647
timestamp: 1728744809372
- kind: conda
name: aiohappyeyeballs
version: 2.4.3
Expand Down Expand Up @@ -5631,6 +5661,25 @@ packages:
- pkg:pypi/propcache?source=hash-mapping
size: 53498
timestamp: 1728545927816
- kind: conda
name: psutil
version: 6.1.0
build: py312h66e93f0_0
subdir: linux-64
url: https://conda.anaconda.org/conda-forge/linux-64/psutil-6.1.0-py312h66e93f0_0.conda
sha256: 0f309b435174e037d5cfe5ed26c1c5ad8152c68cfe61af17709ec31ec3d9f096
md5: 0524eb91d3d78d76d671c6e3cd7cee82
depends:
- __glibc >=2.17,<3.0.a0
- libgcc >=13
- python >=3.12,<3.13.0a0
- python_abi 3.12.* *_cp312
license: BSD-3-Clause
license_family: BSD
purls:
- pkg:pypi/psutil?source=hash-mapping
size: 488462
timestamp: 1729847159916
- kind: conda
name: pthread-stubs
version: '0.4'
Expand Down
1 change: 1 addition & 0 deletions runtime/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ platforms = ["linux-64"]

# conda package dependencies
[dependencies]
accelerate = "1.0.1"
einops = "0.8.0"
langchain = "0.3.*"
librosa = ">=0.10.2.post1,<0.11"
Expand Down
46 changes: 0 additions & 46 deletions runtime/tests/test_lockfile.py

This file was deleted.

50 changes: 3 additions & 47 deletions runtime/tests/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
import pytest

packages = [
"gensim",
"keras",
"numpy",
"pandas",
"scipy",
"spacy",
"sklearn",
"tensorflow",
"torch",
"torchaudio",
"transformers",
"whisper",
"speechbrain",
]


Expand Down Expand Up @@ -41,46 +40,3 @@ def test_allocate_torch():
assert torch.cuda.is_available()

torch.zeros(1).cuda()


@pytest.mark.skipif(not GPU_AVAILABLE, reason="No GPU available")
def test_allocate_tf():
import tensorflow as tf

assert tf.test.is_built_with_cuda()
assert (devices := tf.config.list_logical_devices("GPU"))

for device in devices:
with tf.device(device.name):
tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])


@pytest.mark.skipif(not GPU_AVAILABLE, reason="No GPU available")
def test_allocate_cupy():
import cupy as cp

cp.array([1, 2, 3, 4, 5, 6])


def test_spacy():
import spacy
from spacy.tokens import DocBin

if GPU_AVAILABLE:
spacy.require_gpu()

nlp = spacy.blank("en")
training_data = [
("Tokyo Tower is 333m tall.", [(0, 11, "BUILDING")]),
]

# the DocBin will store the example documents
db = DocBin()
for text, annotations in training_data:
doc = nlp(text)
ents = []
for start, end, label in annotations:
span = doc.char_span(start, end, label=label)
ents.append(span)
doc.ents = ents
db.add(doc)

0 comments on commit 2280362

Please sign in to comment.