Skip to content

Commit

Permalink
Mirror many updates from pose repo
Browse files Browse the repository at this point in the history
  • Loading branch information
isms committed Jan 18, 2024
1 parent 777d304 commit 8f66436
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build pull pack-benchmark pack-submission test-submission
.PHONY: build pull pack-benchmark pack-submission repack-submission repack-example test-submission

# ================================================================================================
# Settings
Expand Down Expand Up @@ -47,9 +47,8 @@ test-container: build _submission_write_perms
docker run \
${TTY_ARGS} \
--mount type=bind,source="$(shell pwd)"/runtime/tests,target=/tests,readonly \
--entrypoint /bin/bash \
${LOCAL_IMAGE} \
-c "conda run --no-capture-output -n condaenv python -m pytest tests"
pytest tests/test_packages.py

## Start your locally built container and open a bash shell within the running container; same as submission setup except has network access
interact-container: build _submission_write_perms
Expand Down Expand Up @@ -83,6 +82,9 @@ endif
mkdir -p submission/
cd submission_src; zip -r ../submission/submission.zip ./*

repack-submission: clean pack-submission

repack-example: clean pack-example

## Runs container using code from `submission/submission.zip` and data from `data/`
test-submission: _submission_write_perms
Expand All @@ -105,4 +107,5 @@ endif
## Delete temporary Python cache and bytecode files
clean:
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
find . -type d -name "__pycache__" -delete
rm -rf ./submission/*
4 changes: 3 additions & 1 deletion runtime/apt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ curl
libxml2
tzdata
wget
zip
zip
parallel
libgl1-mesa-glx
2 changes: 1 addition & 1 deletion runtime/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ main () {
popd

# test the submission
pytest tests/test_submission.py
pytest --no-header -vv tests/test_submission.py
}

main |& tee "/code_execution/submission/log.txt"
Expand Down
1 change: 1 addition & 0 deletions runtime/tests/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"sklearn",
"tensorflow",
"torch",
"cv2",
]


Expand Down
26 changes: 19 additions & 7 deletions runtime/tests/test_submission.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import os

from pathlib import Path

import pytest
import pandas as pd
from numpy.testing import assert_array_equal
from pandas._testing import assert_index_equal

SUBMISSION_PATH = Path("/code_execution/workdir/submission.csv")
CHECK_SUBMISSION = os.environ.get("CHECK_SUBMISSION", "false") == "true"
SUBMISSION_PATH = Path("/code_execution/submission/submission.csv")
SUBMISSION_FORMAT_PATH = Path("/code_execution/data/submission_format.csv")


@pytest.mark.skipif(not CHECK_SUBMISSION, reason="Not checking submission yet")
def test_submission_exists():
assert SUBMISSION_PATH.exists()
assert SUBMISSION_PATH.exists(), f"Expected submission at {SUBMISSION_PATH}"


def test_submission_matches_submission_format():
assert SUBMISSION_FORMAT_PATH.exists(), "Submission format not found"

submission = pd.read_csv(SUBMISSION_PATH)
fmt = pd.read_csv(SUBMISSION_FORMAT_PATH)

assert_array_equal(submission.columns, fmt.columns, err_msg="Columns not identical")
assert_index_equal(submission.index, fmt.index), "Index not identical"

for col in submission.columns:
assert submission[col].dtype == fmt[col].dtype, f"dtype for columns not equal"

0 comments on commit 8f66436

Please sign in to comment.