-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first pass CI and small unit test (#2)
- Add pre-commit CI check - Updated some dependencies in pyproject.toml (incomplete) - Add test for habitat - Fixed a few things pre-commit flagged The pip install step currently takes ~30 min, which is too long. Pre-building a container would take this down to 3 min. --------- Co-authored-by: Naoki Yokoyama <nyokoyama@theaiinstitute.com>
- Loading branch information
1 parent
17e04fc
commit d6cd20e
Showing
12 changed files
with
141 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Pre-Commit | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: 3.9.16 | ||
- uses: pre-commit/action@v3.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright [2023] Boston Dynamics AI Institute, Inc. | ||
|
||
name: ZSOS - Main Build | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ['3.9.16'] | ||
os: [ubuntu-latest] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install package | ||
run: | | ||
sudo apt-get install -y libgl1-mesa-dev | ||
pip install -e .[dev] | ||
- name: Pytest | ||
run: | | ||
pytest test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
|
||
import torch | ||
from habitat_baselines.common.baseline_registry import baseline_registry # noqa | ||
|
||
from zsos import get_config | ||
|
||
|
||
def test_load_and_save_config(): | ||
if not os.path.exists("build"): | ||
os.makedirs("build") | ||
|
||
# Save a dummy state_dict using torch.save | ||
config = get_config("config/experiments/llm_objectnav_hm3d.yaml") | ||
dummy_dict = { | ||
"config": config, | ||
"extra_state": {"step": 0}, | ||
"state_dict": {}, | ||
} | ||
|
||
filename = "build/dummy_policy.pth" | ||
torch.save(dummy_dict, filename) | ||
|
||
# Get the file size of the output PDF | ||
file_size = os.path.getsize(filename) | ||
|
||
# Check the size is greater than 30 KB | ||
assert file_size > 30 * 1024, "Test failed - failed to create pth" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
|
||
import cv2 | ||
|
||
from zsos.utils.visualization import generate_text_image | ||
|
||
|
||
def test_visualization(): | ||
if not os.path.exists("build"): | ||
os.makedirs("build") | ||
|
||
width = 400 | ||
text = ( | ||
"This is a long text that needs to be drawn on an image with a specified " | ||
"width. The text should wrap around if it exceeds the given width." | ||
) | ||
|
||
result_image = generate_text_image(width, text) | ||
|
||
# Save the image to a file | ||
output_filename = "build/output_image.png" | ||
cv2.imwrite(output_filename, result_image) | ||
|
||
# Assert that the file exists | ||
assert os.path.exists(output_filename), "Output image file not found!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import frontier_exploration | ||
from habitat import get_config | ||
|
||
import zsos.obs_transformers.resize | ||
from zsos.policy import base_policy, llm_policy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters