Skip to content

Commit

Permalink
Merge branch 'main' into back_to_rlbench
Browse files Browse the repository at this point in the history
  • Loading branch information
beneisner authored Apr 25, 2024
2 parents f1ba963 + f823e2d commit 0b7b5d7
Show file tree
Hide file tree
Showing 17 changed files with 325 additions and 68 deletions.
112 changes: 112 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,115 @@
# Copied + modified from: https://gist.github.com/KernelA/04b4d7691f28e264f72e76cfd724d448
# Git
.git
.gitignore
.gitattributes
.gitmodules


# CI
.codeclimate.yml
.travis.yml
.taskcluster.yml

# Docker
docker-compose.yml
Dockerfile
.docker
.dockerignore

# Byte-compiled / optimized / DLL files
**/__pycache__/
**/*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Virtual environment
.env
.venv/
venv/

# PyCharm
.idea

# Python mode for VIM
.ropeproject
**/.ropeproject

# Vim swap files
**/*.swp

# VS Code
.vscode/

# Mypy
**/.mypy_cache/

# Pytest
**/.pytest_cache/

# Prevent any of these files from being included in the docker image.

artifacts/
bensnewlogs/
checkpoints/
data/
logs/
outputs/
results/
rollouts/
trained_models/
wandb/
wandb_artifacts/

third_party/ndf_robot/src/ndf_robot/data/
third_party/ndf_robot/src/ndf_robot/eval_data/
third_party/ndf_robot/src/ndf_robot/descriptions/
43 changes: 43 additions & 0 deletions .github/workflows/build-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# A github action that builds a container image for the project.

name: Build Container

on:
push:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

paths:
# This is the entire list of files that will trigger the workflow.
- Dockerfile
- pyproject.toml
- requirements-gpu.txt
- .github/workflows/build-container.yaml
- .github/workflows/compute-tag.yaml

jobs:
compute_tag:
uses: ./.github/workflows/compute-tag.yaml

docker:
runs-on: ubuntu-latest
needs: compute_tag
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
# This is the name of the image that will be pushed to Docker Hub. If the branch is main, the image will be tagged as latest. Else, it will be tagged as the branch name.
tags: ${{ secrets.DOCKERHUB_USERNAME }}/taxpose:${{ needs.compute_tag.outputs.image_tag }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/taxpose:${{ needs.compute_tag.outputs.image_tag }}
cache-to: type=inline
2 changes: 1 addition & 1 deletion .github/workflows/build-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run: mkdocs build

- name: Upload the built site.
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ !env.ACT }}
with:
name: site
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/compute-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Compute the docker tag for this branch

on:
workflow_call:
inputs:
# description: 'If true, the tag will be latest if the docker image tag does not exist'
latest_on_noexist:
required: false
type: string
default: 'false'
outputs:
image_tag:
description: 'The tag to use for the docker image'
value: ${{ jobs.compute_tag.outputs.image_tag }}


jobs:
compute_tag:
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.set_tag.outputs.tag }}
steps:
- id: set_tag
run: |
branch_name="${{ github.head_ref }}"
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "tag=latest" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
sanitized_branch_name="${branch_name//\//-}"
# If latest_on_noexist is true, set the tag to latest if the tag does not exist.
if [[ "${{ inputs.latest_on_noexist }}" == "true" ]]; then
# Check if the tag exists using docker manifest.
if ! docker manifest inspect beisner/taxpose:${sanitized_branch_name} > /dev/null 2>&1; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=${sanitized_branch_name}" >> $GITHUB_OUTPUT
fi
else
echo "tag=${sanitized_branch_name}" >> $GITHUB_OUTPUT
fi
else
sanitized_branch_name="${GITHUB_REF#refs/heads/}"
sanitized_branch_name="${sanitized_branch_name//\//-}"
echo "tag=${sanitized_branch_name}" >> $GITHUB_OUTPUT
fi
6 changes: 3 additions & 3 deletions .github/workflows/deploy-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download Site Artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: site
path: docs/site/

- name: Setup Pages
if: ${{ !env.ACT }}
uses: actions/configure-pages@v1
uses: actions/configure-pages@v5

- name: Upload Artifact to Pages
if: ${{ !env.ACT }}
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: docs/site/

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/merge-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@ on:
workflow_dispatch:

jobs:
compute_tag:
uses: ./.github/workflows/compute-tag.yaml
with:
latest_on_noexist: 'true'

test:
uses: ./.github/workflows/run-tests.yaml
needs: compute_tag
with:
install_string: .[develop]
# Get the image tag from the compute_tag job.
image_tag: ${{ needs.compute_tag.outputs.image_tag }}

build_site:
uses: ./.github/workflows/build-site.yaml
7 changes: 7 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ on:
workflow_dispatch:

jobs:
compute_tag:
uses: ./.github/workflows/compute-tag.yaml
with:
latest_on_noexist: 'true'
test:
uses: ./.github/workflows/run-tests.yaml
needs: compute_tag
with:
install_string: .[develop]
# Get the image tag from the compute_tag job.
image_tag: ${{ needs.compute_tag.outputs.image_tag }}
build_site:
uses: ./.github/workflows/build-site.yaml
deploy_site:
Expand Down
59 changes: 21 additions & 38 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,55 +1,39 @@
name: Run Tests

on:

workflow_call:
inputs:
install_string:
required: True
type: string
image_tag:
required: True
type: string
default: "latest"

jobs:
test:
runs-on: ubuntu-latest

container:
# Image tag is "latest" if the branch is main, else it is the branch name.
image: beisner/taxpose:${{ inputs.image_tag }}

defaults:
run:
working-directory: /opt/baeisner/code

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: 'true'
##############################################
# Skip caching if using a local runner.
- uses: actions/setup-python@v4
if: ${{ !env.ACT }}
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: "pyproject.toml"
- uses: actions/setup-python@v4
if: ${{ env.ACT }}
with:
python-version: '3.9'
##############################################

- name: Install specific pip.
run: pip install pip==23.0.0

- name: Install CPU version of torch.
run: pip install torch==1.11.0+cpu torchvision==0.12.0+cpu --extra-index-url https://download.pytorch.org/whl/cpu

- name: Install the torch-geometric.
run: pip install pyg_lib==0.1.0 torch_scatter==2.0.9 torch_sparse==0.6.15 torch_cluster==1.6.0 torch_spline_conv==1.2.1 -f https://data.pyg.org/whl/torch-1.11.0+cpu.html

- name: Install pytorch3d dependencies.
run: pip install fvcore iopath

- name: Install pytorch3d
run: pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py39_cu113_pyt1110/download.html
# run: pip install pytorch3d

- name: Install package
run: pip install "${{ inputs.install_string }}"

- name: Install ndf_robot
run: pip install -e third_party/ndf_robot
# Link the code from the default checkout directory to the correct directory.
# Use the github workspace variable to get the correct directory.
# Can't use the checkout action to checkout to a different directory, so we have to simlink.
- name: Move code to correct directory
run: rm -rf /opt/baeisner/code && ln -s $GITHUB_WORKSPACE /opt/baeisner/code

- name: Code Quality
run: python -m black taxpose/ tests/ --check
Expand All @@ -58,6 +42,5 @@ jobs:
run: python -m mypy taxpose/ tests/

# Run tests.
# # SKIPPING BECAUSE OF PYTORCH3D IMPORT ISSUES... Prebuilt Linux binaries demand torch CUDA.
# - name: Test with pytest
# run: python -m pytest
- name: Test with pytest
run: python -m pytest tests/
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ pre-commit install
## Run CI locally
To run the CI locally:

### [optional] Start the cache.

Download
https://github.com/sp-ricard-valverde/github-act-cache-server

Run
```
ACT_CACHE_AUTH_KEY=foo docker compose up --build
```

Also modify your .actrc.


### Run


Setup (make sure docker is installed):
```
brew install act
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,4 @@ ENTRYPOINT ["/opt/baeisner/entrypoint.sh"]

# Set up the entry point
CMD ["python", "-c", "import torch; print(torch.cuda.is_available())"]

Loading

0 comments on commit 0b7b5d7

Please sign in to comment.