Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .github/ISSUE_TEMPLATE/bug_report.md +32 -0
- .github/ISSUE_TEMPLATE/feature_request.md +20 -0
- .github/ISSUE_TEMPLATE/question.md +10 -0
- .github/workflows/build-push-containers.yml +166 -0
- .github/workflows/build-website.yml +93 -0
- .github/workflows/examples-as-test.yml +111 -0
- .github/workflows/profiling.yml +51 -0
- .github/workflows/publish-pypi.yml +38 -0
- .github/workflows/pull-sheets-bddl.yml +99 -0
- .github/workflows/pull-sheets.yml +44 -0
- .github/workflows/tests.yml +117 -0
- OmniGibson/docker/README.md +22 -0
- OmniGibson/docker/build_docker.sh +26 -0
- OmniGibson/docker/colab.Dockerfile +21 -0
- OmniGibson/docker/gh-actions/Dockerfile +120 -0
- OmniGibson/docker/gh-actions/app_token.sh +89 -0
- OmniGibson/docker/gh-actions/entrypoint.sh +203 -0
- OmniGibson/docker/gh-actions/install_actions.sh +13 -0
- OmniGibson/docker/gh-actions/token.sh +44 -0
- OmniGibson/docker/launch_vscode.sh +143 -0
- OmniGibson/docker/nginx.conf +24 -0
- OmniGibson/docker/prod.Dockerfile +82 -0
- OmniGibson/docker/push_docker.sh +6 -0
- OmniGibson/docker/run_docker.sh +76 -0
- OmniGibson/docker/safe_launch_vscode.sh +47 -0
- OmniGibson/docker/sbatch_example.sh +73 -0
- OmniGibson/docker/submission.Dockerfile +44 -0
- OmniGibson/docker/vscode.Dockerfile +48 -0
- OmniGibson/omnigibson.egg-info/PKG-INFO +126 -0
- OmniGibson/omnigibson.egg-info/SOURCES.txt +338 -0
- OmniGibson/omnigibson.egg-info/dependency_links.txt +1 -0
- OmniGibson/omnigibson.egg-info/not-zip-safe +1 -0
- OmniGibson/omnigibson.egg-info/requires.txt +62 -0
- OmniGibson/omnigibson.egg-info/top_level.txt +1 -0
- OmniGibson/omnigibson/__pycache__/__init__.cpython-310.pyc +0 -0
- OmniGibson/omnigibson/__pycache__/lazy.cpython-310.pyc +0 -0
- OmniGibson/omnigibson/__pycache__/macros.cpython-310.pyc +0 -0
- OmniGibson/omnigibson/__pycache__/simulator.cpython-310.pyc +0 -0
- OmniGibson/omnigibson/__pycache__/transition_rules.cpython-310.pyc +0 -0
- OmniGibson/omnigibson/learning/__init__.py +0 -0
- OmniGibson/omnigibson/learning/datas/__init__.py +8 -0
- OmniGibson/omnigibson/learning/datas/iterable_dataset.py +448 -0
- OmniGibson/omnigibson/learning/datas/lerobot_dataset.py +557 -0
- OmniGibson/omnigibson/learning/eval.py +490 -0
- OmniGibson/omnigibson/learning/policies.py +63 -0
- OmniGibson/omnigibson/learning/utils/__init__.py +0 -0
- OmniGibson/omnigibson/learning/utils/__pycache__/__init__.cpython-310.pyc +0 -0
- OmniGibson/omnigibson/learning/utils/__pycache__/obs_utils.cpython-310.pyc +0 -0
- OmniGibson/omnigibson/learning/utils/config_utils.py +110 -0
- OmniGibson/omnigibson/learning/utils/dataset_utils.py +791 -0
.github/ISSUE_TEMPLATE/bug_report.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: Bug report
|
| 3 |
+
about: Create a report to help us improve
|
| 4 |
+
title: ''
|
| 5 |
+
labels: bug
|
| 6 |
+
assignees: hang-yin
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
**Describe the bug**
|
| 11 |
+
A clear and concise description of what the bug is.
|
| 12 |
+
|
| 13 |
+
**To Reproduce**
|
| 14 |
+
Steps to reproduce the behavior:
|
| 15 |
+
1. Go to '...'
|
| 16 |
+
2. Click on '....'
|
| 17 |
+
3. Scroll down to '....'
|
| 18 |
+
4. See error
|
| 19 |
+
|
| 20 |
+
**Expected behavior**
|
| 21 |
+
A clear and concise description of what you expected to happen.
|
| 22 |
+
|
| 23 |
+
**Screenshots**
|
| 24 |
+
If applicable, add screenshots to help explain your problem.
|
| 25 |
+
|
| 26 |
+
**Desktop (please complete the following information):**
|
| 27 |
+
- OS: [e.g. Ubuntu 22.04]
|
| 28 |
+
- Isaac Sim Version [e.g. 4.1.0]
|
| 29 |
+
- OmniGibson Version [e.g. 1.1.0]
|
| 30 |
+
|
| 31 |
+
**Additional context**
|
| 32 |
+
Add any other context about the problem here.
|
.github/ISSUE_TEMPLATE/feature_request.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: Feature request
|
| 3 |
+
about: Suggest an idea for this project
|
| 4 |
+
title: ''
|
| 5 |
+
labels: enhancement
|
| 6 |
+
assignees: cgokmen
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
**Is your feature request related to a problem? Please describe.**
|
| 11 |
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
| 12 |
+
|
| 13 |
+
**Describe the solution you'd like**
|
| 14 |
+
A clear and concise description of what you want to happen.
|
| 15 |
+
|
| 16 |
+
**Describe alternatives you've considered**
|
| 17 |
+
A clear and concise description of any alternative solutions or features you've considered.
|
| 18 |
+
|
| 19 |
+
**Additional context**
|
| 20 |
+
Add any other context or screenshots about the feature request here.
|
.github/ISSUE_TEMPLATE/question.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: Question
|
| 3 |
+
about: PLEASE POST QUESTIONS IN THE DISCUSSIONS TAB
|
| 4 |
+
title: ''
|
| 5 |
+
labels: question
|
| 6 |
+
assignees: ''
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
**PLEASE POST QUESTIONS IN THE DISCUSSIONS TAB**
|
.github/workflows/build-push-containers.yml
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: build-push-containers
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
release:
|
| 5 |
+
types: [published]
|
| 6 |
+
push:
|
| 7 |
+
branches:
|
| 8 |
+
- 'main'
|
| 9 |
+
|
| 10 |
+
jobs:
|
| 11 |
+
docker:
|
| 12 |
+
runs-on: ubuntu-latest
|
| 13 |
+
steps:
|
| 14 |
+
-
|
| 15 |
+
name: Check disk space
|
| 16 |
+
run: df . -h
|
| 17 |
+
-
|
| 18 |
+
name: Free disk space
|
| 19 |
+
run: |
|
| 20 |
+
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
|
| 21 |
+
sudo rm -rf \
|
| 22 |
+
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
|
| 23 |
+
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
|
| 24 |
+
/usr/lib/jvm /opt/hostedtoolcache/CodeQL || true
|
| 25 |
+
echo "some directories deleted"
|
| 26 |
+
sudo apt install aptitude -y >/dev/null 2>&1
|
| 27 |
+
sudo aptitude purge aria2 ansible azure-cli shellcheck rpm xorriso zsync \
|
| 28 |
+
esl-erlang firefox gfortran-8 gfortran-9 google-chrome-stable \
|
| 29 |
+
google-cloud-sdk imagemagick \
|
| 30 |
+
libmagickcore-dev libmagickwand-dev libmagic-dev ant ant-optional kubectl \
|
| 31 |
+
mercurial apt-transport-https mono-complete libmysqlclient \
|
| 32 |
+
unixodbc-dev yarn chrpath libssl-dev libxft-dev \
|
| 33 |
+
libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev \
|
| 34 |
+
snmp pollinate libpq-dev postgresql-client powershell ruby-full \
|
| 35 |
+
sphinxsearch subversion mongodb-org azure-cli microsoft-edge-stable \
|
| 36 |
+
-y -f >/dev/null 2>&1
|
| 37 |
+
sudo aptitude purge google-cloud-sdk -f -y >/dev/null 2>&1
|
| 38 |
+
sudo aptitude purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true
|
| 39 |
+
sudo apt purge microsoft-edge-stable -f -y >/dev/null 2>&1 || true
|
| 40 |
+
sudo aptitude purge '~n ^mysql' -f -y >/dev/null 2>&1
|
| 41 |
+
sudo aptitude purge '~n ^php' -f -y >/dev/null 2>&1
|
| 42 |
+
sudo aptitude purge '~n ^dotnet' -f -y >/dev/null 2>&1
|
| 43 |
+
sudo apt-get autoremove -y >/dev/null 2>&1
|
| 44 |
+
sudo apt-get autoclean -y >/dev/null 2>&1
|
| 45 |
+
echo "some packages purged"
|
| 46 |
+
-
|
| 47 |
+
name: Check disk space
|
| 48 |
+
run: |
|
| 49 |
+
df . -h
|
| 50 |
+
-
|
| 51 |
+
name: Checkout
|
| 52 |
+
uses: actions/checkout@v4
|
| 53 |
+
-
|
| 54 |
+
name: Set up Docker Buildx
|
| 55 |
+
uses: docker/setup-buildx-action@v3
|
| 56 |
+
-
|
| 57 |
+
name: Login to NVCR
|
| 58 |
+
uses: docker/login-action@v3
|
| 59 |
+
with:
|
| 60 |
+
registry: nvcr.io
|
| 61 |
+
username: ${{ secrets.NVCR_USERNAME }}
|
| 62 |
+
password: ${{ secrets.NVCR_PASSWORD }}
|
| 63 |
+
-
|
| 64 |
+
name: Login to Docker Hub
|
| 65 |
+
uses: docker/login-action@v3
|
| 66 |
+
with:
|
| 67 |
+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
| 68 |
+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
| 69 |
+
-
|
| 70 |
+
name: Metadata for prod Image
|
| 71 |
+
id: meta-prod
|
| 72 |
+
uses: docker/metadata-action@v5
|
| 73 |
+
with:
|
| 74 |
+
images: |
|
| 75 |
+
stanfordvl/omnigibson
|
| 76 |
+
tags: |
|
| 77 |
+
type=ref,event=branch
|
| 78 |
+
type=semver,pattern={{version}}
|
| 79 |
+
-
|
| 80 |
+
name: Metadata for dev Image
|
| 81 |
+
id: meta-dev
|
| 82 |
+
uses: docker/metadata-action@v5
|
| 83 |
+
with:
|
| 84 |
+
images: |
|
| 85 |
+
stanfordvl/omnigibson-dev
|
| 86 |
+
tags: |
|
| 87 |
+
type=ref,event=branch
|
| 88 |
+
type=semver,pattern={{version}}
|
| 89 |
+
-
|
| 90 |
+
name: Metadata for vscode Image
|
| 91 |
+
id: meta-vscode
|
| 92 |
+
uses: docker/metadata-action@v5
|
| 93 |
+
with:
|
| 94 |
+
images: |
|
| 95 |
+
stanfordvl/omnigibson-vscode
|
| 96 |
+
tags: |
|
| 97 |
+
type=ref,event=branch
|
| 98 |
+
type=semver,pattern={{version}}
|
| 99 |
+
-
|
| 100 |
+
name: Metadata for actions Image
|
| 101 |
+
id: meta-actions
|
| 102 |
+
uses: docker/metadata-action@v5
|
| 103 |
+
with:
|
| 104 |
+
images: |
|
| 105 |
+
stanfordvl/omnigibson-gha
|
| 106 |
+
tags: |
|
| 107 |
+
# We only push to the latest tag for the actions image
|
| 108 |
+
type=raw,value=latest
|
| 109 |
+
-
|
| 110 |
+
name: Build and push prod image
|
| 111 |
+
id: build-prod
|
| 112 |
+
uses: docker/build-push-action@v5
|
| 113 |
+
with:
|
| 114 |
+
context: OmniGibson/
|
| 115 |
+
push: true
|
| 116 |
+
tags: ${{ steps.meta-prod.outputs.tags }}
|
| 117 |
+
labels: ${{ steps.meta-prod.outputs.labels }}
|
| 118 |
+
file: OmniGibson/docker/prod.Dockerfile
|
| 119 |
+
cache-from: type=registry,ref=stanfordvl/omnigibson:build-cache
|
| 120 |
+
cache-to: type=registry,ref=stanfordvl/omnigibson:build-cache,mode=max
|
| 121 |
+
|
| 122 |
+
-
|
| 123 |
+
name: Build and push dev image
|
| 124 |
+
id: build-dev
|
| 125 |
+
uses: docker/build-push-action@v5
|
| 126 |
+
with:
|
| 127 |
+
context: OmniGibson/
|
| 128 |
+
build-args: "DEV_MODE=1"
|
| 129 |
+
push: true
|
| 130 |
+
tags: ${{ steps.meta-dev.outputs.tags }}
|
| 131 |
+
labels: ${{ steps.meta-dev.outputs.labels }}
|
| 132 |
+
file: OmniGibson/docker/prod.Dockerfile
|
| 133 |
+
cache-from: type=registry,ref=stanfordvl/omnigibson:build-cache # OK to share cache here.
|
| 134 |
+
cache-to: type=registry,ref=stanfordvl/omnigibson:build-cache,mode=max
|
| 135 |
+
|
| 136 |
+
- name: Update vscode image Dockerfile with prod image tag
|
| 137 |
+
run: |
|
| 138 |
+
sed -i "s/omnigibson:latest/omnigibson@${{ steps.build-prod.outputs.digest }}/g" OmniGibson/docker/vscode.Dockerfile && cat OmniGibson/docker/vscode.Dockerfile
|
| 139 |
+
-
|
| 140 |
+
name: Build and push vscode image
|
| 141 |
+
id: build-vscode
|
| 142 |
+
uses: docker/build-push-action@v5
|
| 143 |
+
with:
|
| 144 |
+
context: OmniGibson/
|
| 145 |
+
push: true
|
| 146 |
+
tags: ${{ steps.meta-vscode.outputs.tags }}
|
| 147 |
+
labels: ${{ steps.meta-vscode.outputs.labels }}
|
| 148 |
+
file: OmniGibson/docker/vscode.Dockerfile
|
| 149 |
+
cache-from: type=registry,ref=stanfordvl/omnigibson:build-cache # OK to share cache here.
|
| 150 |
+
cache-to: type=registry,ref=stanfordvl/omnigibson:build-cache,mode=max
|
| 151 |
+
|
| 152 |
+
- name: Update actions image Dockerfile with dev image tag
|
| 153 |
+
run: |
|
| 154 |
+
sed -i "s/omnigibson-dev:latest/omnigibson-dev@${{ steps.build-dev.outputs.digest }}/g" OmniGibson/docker/gh-actions/Dockerfile && cat OmniGibson/docker/gh-actions/Dockerfile
|
| 155 |
+
-
|
| 156 |
+
name: Build and push actions image
|
| 157 |
+
id: build-actions
|
| 158 |
+
uses: docker/build-push-action@v5
|
| 159 |
+
with:
|
| 160 |
+
context: OmniGibson/docker/gh-actions
|
| 161 |
+
push: true
|
| 162 |
+
tags: ${{ steps.meta-actions.outputs.tags }}
|
| 163 |
+
labels: ${{ steps.meta-actions.outputs.labels }}
|
| 164 |
+
file: OmniGibson/docker/gh-actions/Dockerfile
|
| 165 |
+
cache-from: type=registry,ref=stanfordvl/omnigibson:build-cache # OK to share cache here.
|
| 166 |
+
cache-to: type=registry,ref=stanfordvl/omnigibson:build-cache,mode=max
|
.github/workflows/build-website.yml
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Build and deploy BEHAVIOR website
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
schedule:
|
| 5 |
+
- cron: "0 10 * * *" # Every day at 10am
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
push:
|
| 8 |
+
branches:
|
| 9 |
+
- main
|
| 10 |
+
|
| 11 |
+
permissions:
|
| 12 |
+
contents: read
|
| 13 |
+
pages: write
|
| 14 |
+
id-token: write
|
| 15 |
+
|
| 16 |
+
concurrency:
|
| 17 |
+
group: "pages"
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
jobs:
|
| 21 |
+
build:
|
| 22 |
+
runs-on: [self-hosted, linux]
|
| 23 |
+
|
| 24 |
+
defaults:
|
| 25 |
+
run:
|
| 26 |
+
shell: micromamba run -n omnigibson /bin/bash -leo pipefail {0}
|
| 27 |
+
|
| 28 |
+
steps:
|
| 29 |
+
- name: Fix home
|
| 30 |
+
run: echo "HOME=/root" >> $GITHUB_ENV
|
| 31 |
+
|
| 32 |
+
- name: Checkout source
|
| 33 |
+
uses: actions/checkout@v4
|
| 34 |
+
|
| 35 |
+
- name: Install BDDL
|
| 36 |
+
working-directory: bddl
|
| 37 |
+
run: pip install -e .
|
| 38 |
+
|
| 39 |
+
- name: Install
|
| 40 |
+
working-directory: OmniGibson
|
| 41 |
+
run: pip install -e .[dev]
|
| 42 |
+
|
| 43 |
+
- name: Build docs
|
| 44 |
+
run: mkdocs build # TODO: Shouldn't we copy over the src directory here?
|
| 45 |
+
|
| 46 |
+
# # See if we need to rebuild the whole thing
|
| 47 |
+
# - name: Get BDDL hash
|
| 48 |
+
# id: bddl-hash
|
| 49 |
+
# working-directory: bddl
|
| 50 |
+
# run: echo hash=$(git rev-parse HEAD) >> "$GITHUB_OUTPUT"
|
| 51 |
+
|
| 52 |
+
# - name: Get knowledgebase hash
|
| 53 |
+
# id: website-hash
|
| 54 |
+
# working-directory: knowledgebase
|
| 55 |
+
# run: echo hash=$(git rev-parse HEAD) >> "$GITHUB_OUTPUT"
|
| 56 |
+
|
| 57 |
+
# - name: Check cache for overall data
|
| 58 |
+
# id: cache-knowledgebase
|
| 59 |
+
# uses: actions/cache@v3
|
| 60 |
+
# with:
|
| 61 |
+
# key: knowledgebase-${{ steps.website-hash.outputs.hash }}-${{ steps.bddl-hash.outputs.hash }}
|
| 62 |
+
# path: README.md
|
| 63 |
+
# lookup-only: true
|
| 64 |
+
|
| 65 |
+
# - if: ${{ steps.cache-knowledgebase.outputs.cache-hit != 'true' }}
|
| 66 |
+
- name: Install other dependencies
|
| 67 |
+
working-directory: knowledgebase
|
| 68 |
+
run: pip install -r requirements.txt
|
| 69 |
+
|
| 70 |
+
# - if: ${{ steps.cache-knowledgebase.outputs.cache-hit != 'true' }}
|
| 71 |
+
- name: Generate static knowledgebase site
|
| 72 |
+
working-directory: knowledgebase
|
| 73 |
+
run: python build_static_site.py
|
| 74 |
+
|
| 75 |
+
- name: Move knowledgebase to combined site
|
| 76 |
+
run: cp -R knowledgebase/build/knowledgebase site
|
| 77 |
+
|
| 78 |
+
- name: Upload pages artifact
|
| 79 |
+
uses: actions/upload-pages-artifact@v3
|
| 80 |
+
with:
|
| 81 |
+
path: site/
|
| 82 |
+
|
| 83 |
+
# Deploy on github pages
|
| 84 |
+
deploy:
|
| 85 |
+
environment:
|
| 86 |
+
name: github-pages
|
| 87 |
+
url: ${{ steps.deployment.outputs.page_url }}
|
| 88 |
+
runs-on: ubuntu-latest
|
| 89 |
+
needs: build
|
| 90 |
+
steps:
|
| 91 |
+
- name: Deploy to GitHub Pages
|
| 92 |
+
id: deployment
|
| 93 |
+
uses: actions/deploy-pages@v4
|
.github/workflows/examples-as-test.yml
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Examples as Tests
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
schedule:
|
| 5 |
+
# * is a special character in YAML so you have to quote this string
|
| 6 |
+
# Format: minute hour day-of-month month day-of-week(starts on sunday)
|
| 7 |
+
# Scheduled for 2 am, everyday
|
| 8 |
+
- cron: '0 10 * * *'
|
| 9 |
+
workflow_dispatch:
|
| 10 |
+
|
| 11 |
+
concurrency:
|
| 12 |
+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
|
| 13 |
+
cancel-in-progress: true
|
| 14 |
+
|
| 15 |
+
jobs:
|
| 16 |
+
generate_example_tests:
|
| 17 |
+
name: Generate Example Tests
|
| 18 |
+
runs-on: [self-hosted, linux, gpu, dataset-enabled]
|
| 19 |
+
defaults:
|
| 20 |
+
run:
|
| 21 |
+
shell: micromamba run -n omnigibson /bin/bash -leo pipefail {0}
|
| 22 |
+
steps:
|
| 23 |
+
- name: Checkout source
|
| 24 |
+
uses: actions/checkout@v4
|
| 25 |
+
with:
|
| 26 |
+
submodules: true
|
| 27 |
+
|
| 28 |
+
- name: Install
|
| 29 |
+
run: pip install -e .[dev,primitives]
|
| 30 |
+
|
| 31 |
+
- name: Generate example tests
|
| 32 |
+
run: python tests/create_tests_of_examples.py
|
| 33 |
+
|
| 34 |
+
- name: Get list of generated tests
|
| 35 |
+
id: get-test-list
|
| 36 |
+
run: |
|
| 37 |
+
echo "example_tests=$(cat tests/example_tests.json)" >> $GITHUB_OUTPUT
|
| 38 |
+
|
| 39 |
+
outputs:
|
| 40 |
+
example_tests: ${{ steps.get-test-list.outputs.example_tests }}
|
| 41 |
+
|
| 42 |
+
run_test:
|
| 43 |
+
name: Run Example Tests
|
| 44 |
+
needs: [generate_example_tests]
|
| 45 |
+
runs-on: [self-hosted, linux, gpu, dataset-enabled]
|
| 46 |
+
|
| 47 |
+
strategy:
|
| 48 |
+
matrix:
|
| 49 |
+
test_file:
|
| 50 |
+
- ${{ needs.generate_example_tests.outputs.example_tests != '' && fromJson(needs.generate_example_tests.outputs.example_tests) }}
|
| 51 |
+
fail-fast: true
|
| 52 |
+
|
| 53 |
+
defaults:
|
| 54 |
+
run:
|
| 55 |
+
shell: micromamba run -n omnigibson /bin/bash -leo pipefail {0}
|
| 56 |
+
|
| 57 |
+
steps:
|
| 58 |
+
- name: Check for generated tests
|
| 59 |
+
if: ${{ needs.generate_example_tests.outputs.example_tests == '' }}
|
| 60 |
+
run: |
|
| 61 |
+
echo "No tests were generated. Failing the job."
|
| 62 |
+
exit 1
|
| 63 |
+
|
| 64 |
+
- name: Fix home
|
| 65 |
+
run: echo "HOME=/root" >> $GITHUB_ENV
|
| 66 |
+
|
| 67 |
+
- name: Checkout source
|
| 68 |
+
uses: actions/checkout@v4
|
| 69 |
+
with:
|
| 70 |
+
submodules: true
|
| 71 |
+
|
| 72 |
+
- name: Install
|
| 73 |
+
run: pip install -e .[dev,primitives]
|
| 74 |
+
|
| 75 |
+
- name: Run tests
|
| 76 |
+
run: pytest -s tests/tests_of_examples/${{ matrix.test_file }}.py --junitxml=${{ matrix.test_file }}.xml && cp ${{ matrix.test_file }}.xml ${GITHUB_WORKSPACE}/
|
| 77 |
+
|
| 78 |
+
- name: Deploy artifact
|
| 79 |
+
uses: actions/upload-artifact@v4
|
| 80 |
+
with:
|
| 81 |
+
name: ${{ github.run_id }}-tests-${{ matrix.test_file }}
|
| 82 |
+
path: ${{ matrix.test_file }}.xml
|
| 83 |
+
|
| 84 |
+
- name: Fail on failure or error
|
| 85 |
+
run: grep -Eq "<failure|error" ${{ matrix.test_file }}.xml; if [ $? -eq 0 ]; then exit 1; else exit 0; fi
|
| 86 |
+
|
| 87 |
+
upload_report:
|
| 88 |
+
name: Compile Example Test Report
|
| 89 |
+
runs-on: [self-hosted, linux]
|
| 90 |
+
defaults:
|
| 91 |
+
run:
|
| 92 |
+
shell: micromamba run -n omnigibson /bin/bash -leo pipefail {0}
|
| 93 |
+
needs: [run_test]
|
| 94 |
+
steps:
|
| 95 |
+
- name: Pull reports
|
| 96 |
+
uses: actions/download-artifact@v4
|
| 97 |
+
with:
|
| 98 |
+
merge-multiple: True
|
| 99 |
+
- name: Example Test Report0
|
| 100 |
+
uses: dorny/test-reporter@v1
|
| 101 |
+
with:
|
| 102 |
+
name: Example Test Results
|
| 103 |
+
path: "*_test.xml"
|
| 104 |
+
reporter: java-junit
|
| 105 |
+
fail-on-error: 'true'
|
| 106 |
+
fail-on-empty: 'true'
|
| 107 |
+
|
| 108 |
+
# - name: Upload coverage to Codecov
|
| 109 |
+
# uses: codecov/codecov-action@v2.1.0
|
| 110 |
+
# with:
|
| 111 |
+
# token: ${{ secrets.CODECOV_TOKEN }}
|
.github/workflows/profiling.yml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Profiling
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
push:
|
| 6 |
+
branches:
|
| 7 |
+
- og-develop
|
| 8 |
+
|
| 9 |
+
permissions:
|
| 10 |
+
# deployments permission to deploy GitHub pages website
|
| 11 |
+
deployments: write
|
| 12 |
+
# contents permission to update profiling contents in gh-pages branch
|
| 13 |
+
contents: write
|
| 14 |
+
|
| 15 |
+
concurrency:
|
| 16 |
+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
|
| 17 |
+
cancel-in-progress: true
|
| 18 |
+
|
| 19 |
+
jobs:
|
| 20 |
+
profiling:
|
| 21 |
+
name: Speed Profiling
|
| 22 |
+
runs-on: [self-hosted, linux, gpu, dataset-enabled]
|
| 23 |
+
|
| 24 |
+
defaults:
|
| 25 |
+
run:
|
| 26 |
+
shell: micromamba run -n omnigibson /bin/bash -leo pipefail {0}
|
| 27 |
+
|
| 28 |
+
steps:
|
| 29 |
+
- name: Fix home
|
| 30 |
+
run: echo "HOME=/root" >> $GITHUB_ENV
|
| 31 |
+
|
| 32 |
+
- name: Checkout source
|
| 33 |
+
uses: actions/checkout@v4
|
| 34 |
+
|
| 35 |
+
- name: Install
|
| 36 |
+
run: pip install -e .[dev,primitives]
|
| 37 |
+
|
| 38 |
+
- name: Run performance benchmark
|
| 39 |
+
run: bash scripts/profiling.sh
|
| 40 |
+
|
| 41 |
+
- name: Store benchmark result
|
| 42 |
+
uses: benchmark-action/github-action-benchmark@v1
|
| 43 |
+
with:
|
| 44 |
+
tool: 'customSmallerIsBetter'
|
| 45 |
+
output-file-path: output.json
|
| 46 |
+
benchmark-data-dir-path: profiling
|
| 47 |
+
fail-on-alert: false
|
| 48 |
+
alert-threshold: '200%'
|
| 49 |
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
| 50 |
+
comment-on-alert: false
|
| 51 |
+
auto-push: true
|
.github/workflows/publish-pypi.yml
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This workflow will upload a Python Package using Twine when a release is created
|
| 2 |
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
| 3 |
+
|
| 4 |
+
# This workflow uses actions that are not certified by GitHub.
|
| 5 |
+
# They are provided by a third-party and are governed by
|
| 6 |
+
# separate terms of service, privacy policy, and support
|
| 7 |
+
# documentation.
|
| 8 |
+
|
| 9 |
+
name: Upload Python Package
|
| 10 |
+
|
| 11 |
+
on:
|
| 12 |
+
release:
|
| 13 |
+
types: [published]
|
| 14 |
+
|
| 15 |
+
jobs:
|
| 16 |
+
pypi-publish:
|
| 17 |
+
name: Upload release to PyPI
|
| 18 |
+
runs-on: ubuntu-latest
|
| 19 |
+
environment:
|
| 20 |
+
name: pypi
|
| 21 |
+
url: https://pypi.org/p/omnigibson
|
| 22 |
+
permissions:
|
| 23 |
+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
| 24 |
+
contents: read
|
| 25 |
+
steps:
|
| 26 |
+
- uses: actions/checkout@v4
|
| 27 |
+
- name: Set up Python
|
| 28 |
+
uses: actions/setup-python@v3
|
| 29 |
+
with:
|
| 30 |
+
python-version: '3.x'
|
| 31 |
+
- name: Install dependencies
|
| 32 |
+
run: |
|
| 33 |
+
python -m pip install --upgrade pip
|
| 34 |
+
pip install setuptools wheel twine
|
| 35 |
+
- name: Build package
|
| 36 |
+
run: python setup.py sdist
|
| 37 |
+
- name: Publish package distributions to PyPI
|
| 38 |
+
uses: pypa/gh-action-pypi-publish@v1.10.2
|
.github/workflows/pull-sheets-bddl.yml
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync bddl Google Sheets data
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
schedule:
|
| 5 |
+
- cron: "0 9 * * *" # Every day at 9am
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
# push:
|
| 8 |
+
# branches:
|
| 9 |
+
# - main
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
pull-sheets:
|
| 13 |
+
name: Sync Google Sheets data
|
| 14 |
+
runs-on: ubuntu-latest
|
| 15 |
+
|
| 16 |
+
steps:
|
| 17 |
+
- name: Checkout code
|
| 18 |
+
uses: actions/checkout@v3
|
| 19 |
+
|
| 20 |
+
- name: Setup python
|
| 21 |
+
uses: actions/setup-python@v2
|
| 22 |
+
with:
|
| 23 |
+
python-version: "3.10"
|
| 24 |
+
architecture: x64
|
| 25 |
+
|
| 26 |
+
- name: Authenticate on Google Cloud
|
| 27 |
+
uses: 'google-github-actions/auth@v1'
|
| 28 |
+
with:
|
| 29 |
+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
| 30 |
+
|
| 31 |
+
- uses: webfactory/ssh-agent@v0.9.0
|
| 32 |
+
with:
|
| 33 |
+
ssh-private-key: ${{ secrets.SHEETS_DEPLOY_KEY }}
|
| 34 |
+
|
| 35 |
+
# See if we need to re-pull any asset_pipeline data from DVC.
|
| 36 |
+
- name: Check cache for pipeline data
|
| 37 |
+
id: cache-pipeline
|
| 38 |
+
uses: actions/cache@v3
|
| 39 |
+
with:
|
| 40 |
+
key: asset_pipeline-${{ hashFiles('asset_pipeline/dvc.lock') }}
|
| 41 |
+
path: |
|
| 42 |
+
asset_pipeline/artifacts/pipeline/combined_room_object_list.json
|
| 43 |
+
asset_pipeline/artifacts/pipeline/object_inventory.json
|
| 44 |
+
|
| 45 |
+
- if: ${{ steps.cache-pipeline.outputs.cache-hit != 'true' }}
|
| 46 |
+
name: Install dvc
|
| 47 |
+
run: pip install dvc[gs]
|
| 48 |
+
|
| 49 |
+
- if: ${{ steps.cache-pipeline.outputs.cache-hit != 'true' }}
|
| 50 |
+
name: Pull dvc data
|
| 51 |
+
working-directory: asset_pipeline
|
| 52 |
+
run: dvc pull combined_room_object_list object_inventory
|
| 53 |
+
|
| 54 |
+
- if: ${{ steps.cache-pipeline.outputs.cache-hit != 'true' }}
|
| 55 |
+
name: Unprotect data
|
| 56 |
+
working-directory: asset_pipeline
|
| 57 |
+
run: dvc unprotect artifacts/pipeline/combined_room_object_list.json artifacts/pipeline/object_inventory.json
|
| 58 |
+
|
| 59 |
+
- name: Copy over pipeline files
|
| 60 |
+
run: cp asset_pipeline/artifacts/pipeline/{combined_room_object_list,object_inventory}.json bddl/bddl/generated_data
|
| 61 |
+
|
| 62 |
+
- name: Combine complaint files from asset_pipeline
|
| 63 |
+
run: |
|
| 64 |
+
python3 -c "
|
| 65 |
+
import glob, json
|
| 66 |
+
files = glob.glob('asset_pipeline/cad/*/*/complaints.json')
|
| 67 |
+
combined = []
|
| 68 |
+
for file in files:
|
| 69 |
+
with open(file) as f:
|
| 70 |
+
combined.extend(json.load(f))
|
| 71 |
+
combined.sort(key=lambda x: (x['object'], x['type'], x['additional_info'], x['complaint'], x['processed']))
|
| 72 |
+
with open('bddl/bddl/generated_data/complaints.json', 'w') as f:
|
| 73 |
+
json.dump(combined, f, indent=2)
|
| 74 |
+
"
|
| 75 |
+
|
| 76 |
+
- name: Install BDDL
|
| 77 |
+
working-directory: bddl
|
| 78 |
+
run: pip install -e .
|
| 79 |
+
|
| 80 |
+
- name: Install dev requirements
|
| 81 |
+
working-directory: bddl
|
| 82 |
+
run: pip install -r requirements-dev.txt
|
| 83 |
+
|
| 84 |
+
- name: Refresh sheets data
|
| 85 |
+
working-directory: bddl
|
| 86 |
+
run: python -m bddl.data_generation.pull_sheets
|
| 87 |
+
|
| 88 |
+
- name: Refresh derivative data
|
| 89 |
+
working-directory: bddl
|
| 90 |
+
run: python -m bddl.data_generation.generate_datafiles
|
| 91 |
+
|
| 92 |
+
# We want to check if the knowledgebase imports correctly, and if not, we want to NOT do the pull
|
| 93 |
+
# because it will result in a permamently broken knowledgebase that blocks sampling and website.
|
| 94 |
+
- name: Test if knowledgebase loads OK
|
| 95 |
+
run: python -c "from bddl.knowledge_base import *"
|
| 96 |
+
|
| 97 |
+
- uses: stefanzweifel/git-auto-commit-action@v4
|
| 98 |
+
with:
|
| 99 |
+
commit_message: "Sync bddl Google Sheets data"
|
.github/workflows/pull-sheets.yml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync asset pipeline Google Sheets data
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
schedule:
|
| 5 |
+
- cron: "0 10 * * *" # Every day at 10am
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
# push:
|
| 8 |
+
# branches:
|
| 9 |
+
# - main
|
| 10 |
+
|
| 11 |
+
jobs:
|
| 12 |
+
pull-sheets:
|
| 13 |
+
name: Sync Google Sheets data
|
| 14 |
+
runs-on: ubuntu-latest
|
| 15 |
+
|
| 16 |
+
steps:
|
| 17 |
+
- name: Checkout code
|
| 18 |
+
uses: actions/checkout@v3
|
| 19 |
+
|
| 20 |
+
- name: Setup python
|
| 21 |
+
uses: actions/setup-python@v2
|
| 22 |
+
with:
|
| 23 |
+
python-version: "3.8"
|
| 24 |
+
architecture: x64
|
| 25 |
+
|
| 26 |
+
- name: Install requirements
|
| 27 |
+
run: pip install gspread pandas
|
| 28 |
+
|
| 29 |
+
- name: Authenticate on Google Cloud
|
| 30 |
+
uses: 'google-github-actions/auth@v1'
|
| 31 |
+
with:
|
| 32 |
+
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
| 33 |
+
|
| 34 |
+
- uses: webfactory/ssh-agent@v0.9.0
|
| 35 |
+
with:
|
| 36 |
+
ssh-private-key: ${{ secrets.SHEETS_DEPLOY_KEY }}
|
| 37 |
+
|
| 38 |
+
- name: Refresh sheets data
|
| 39 |
+
run: python -m b1k_pipeline.sync_sheets
|
| 40 |
+
working-directory: asset_pipeline
|
| 41 |
+
|
| 42 |
+
- uses: stefanzweifel/git-auto-commit-action@v4
|
| 43 |
+
with:
|
| 44 |
+
commit_message: "Sync Google Sheets data"
|
.github/workflows/tests.yml
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Tests
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
push:
|
| 6 |
+
branches:
|
| 7 |
+
- main
|
| 8 |
+
|
| 9 |
+
concurrency:
|
| 10 |
+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
|
| 11 |
+
cancel-in-progress: true
|
| 12 |
+
|
| 13 |
+
jobs:
|
| 14 |
+
run_test:
|
| 15 |
+
name: Run Tests
|
| 16 |
+
runs-on: [self-hosted, linux, gpu, dataset-enabled]
|
| 17 |
+
|
| 18 |
+
strategy:
|
| 19 |
+
fail-fast: false
|
| 20 |
+
matrix:
|
| 21 |
+
test_file:
|
| 22 |
+
- test_controllers
|
| 23 |
+
- test_curobo
|
| 24 |
+
- test_data_collection
|
| 25 |
+
- test_dump_load_states
|
| 26 |
+
- test_envs
|
| 27 |
+
- test_multiple_envs
|
| 28 |
+
- test_object_removal
|
| 29 |
+
- test_object_states
|
| 30 |
+
- test_primitives
|
| 31 |
+
- test_robot_states_flatcache
|
| 32 |
+
- test_robot_states_no_flatcache
|
| 33 |
+
- test_robot_teleoperation
|
| 34 |
+
- test_scene_graph
|
| 35 |
+
- test_sensors
|
| 36 |
+
- test_symbolic_primitives
|
| 37 |
+
- test_systems
|
| 38 |
+
- test_transform_utils
|
| 39 |
+
- test_transition_rules
|
| 40 |
+
|
| 41 |
+
defaults:
|
| 42 |
+
run:
|
| 43 |
+
shell: micromamba run -n omnigibson /bin/bash -leo pipefail {0}
|
| 44 |
+
working-directory: ${{ github.workspace }}/OmniGibson
|
| 45 |
+
|
| 46 |
+
steps:
|
| 47 |
+
- name: Checkout source
|
| 48 |
+
uses: actions/checkout@v4
|
| 49 |
+
with:
|
| 50 |
+
submodules: true
|
| 51 |
+
|
| 52 |
+
- name: Install BDDL
|
| 53 |
+
run: pip install -e .
|
| 54 |
+
working-directory: ${{ github.workspace }}/bddl
|
| 55 |
+
|
| 56 |
+
- name: Install OmniGibson
|
| 57 |
+
run: pip install -e .[dev,primitives,eval] --no-build-isolation
|
| 58 |
+
|
| 59 |
+
- name: Print env
|
| 60 |
+
run: printenv
|
| 61 |
+
|
| 62 |
+
- name: Run tests
|
| 63 |
+
run: pytest -s tests/${{ matrix.test_file }}.py --junitxml=${{ matrix.test_file }}.xml
|
| 64 |
+
continue-on-error: true
|
| 65 |
+
|
| 66 |
+
- name: Deploy artifact
|
| 67 |
+
uses: actions/upload-artifact@v4
|
| 68 |
+
with:
|
| 69 |
+
name: ${{ github.run_id }}-tests-${{ matrix.test_file }}
|
| 70 |
+
path: OmniGibson/${{ matrix.test_file }}.xml
|
| 71 |
+
|
| 72 |
+
- name: Check for failures, errors, or missing XML
|
| 73 |
+
run: |
|
| 74 |
+
if [ ! -f ${{ matrix.test_file }}.xml ]; then
|
| 75 |
+
echo "Error: XML file not found, probably due to segfault"
|
| 76 |
+
exit 1
|
| 77 |
+
elif grep -Eq 'failures="[1-9][0-9]*"|errors="[1-9][0-9]*"' ${{ matrix.test_file }}.xml; then
|
| 78 |
+
echo "Error: Test failures or errors found"
|
| 79 |
+
exit 1
|
| 80 |
+
else
|
| 81 |
+
echo "All tests passed successfully"
|
| 82 |
+
exit 0
|
| 83 |
+
fi
|
| 84 |
+
|
| 85 |
+
upload_report:
|
| 86 |
+
name: Compile Report
|
| 87 |
+
runs-on: ubuntu-latest
|
| 88 |
+
defaults:
|
| 89 |
+
run:
|
| 90 |
+
shell: micromamba run -n omnigibson /bin/bash -leo pipefail {0}
|
| 91 |
+
needs: [run_test]
|
| 92 |
+
if: always()
|
| 93 |
+
steps:
|
| 94 |
+
- name: Checkout source
|
| 95 |
+
uses: actions/checkout@v2
|
| 96 |
+
with:
|
| 97 |
+
submodules: true
|
| 98 |
+
path: behavior1k-src
|
| 99 |
+
- name: Pull reports
|
| 100 |
+
uses: actions/download-artifact@v4
|
| 101 |
+
with:
|
| 102 |
+
path: behavior1k-src/OmniGibson
|
| 103 |
+
merge-multiple: true
|
| 104 |
+
- name: Test Report0
|
| 105 |
+
uses: dorny/test-reporter@v1
|
| 106 |
+
with:
|
| 107 |
+
name: Test Results
|
| 108 |
+
working-directory: behavior1k-src/OmniGibson
|
| 109 |
+
path: test_*.xml
|
| 110 |
+
reporter: java-junit
|
| 111 |
+
fail-on-error: 'false'
|
| 112 |
+
fail-on-empty: 'false'
|
| 113 |
+
|
| 114 |
+
# - name: Upload coverage to Codecov
|
| 115 |
+
# uses: codecov/codecov-action@v2.1.0
|
| 116 |
+
# with:
|
| 117 |
+
# token: ${{ secrets.CODECOV_TOKEN }}
|
OmniGibson/docker/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Requirements
|
| 2 |
+
|
| 3 |
+
- Modern Linux distribution (Ubuntu 20.04, Fedora 36, etc.)
|
| 4 |
+
- RTX capable Nvidia graphics card (20 series or newer,)
|
| 5 |
+
- Up-to-date NVIDIA drivers
|
| 6 |
+
|
| 7 |
+
# Usage
|
| 8 |
+
|
| 9 |
+
**The below instructions concern the usage of OmniGibson containers with self-built images. Please see the BEHAVIOR-1K docs for instructions on how to pull and run a cloud image.**
|
| 10 |
+
|
| 11 |
+
1. Set up the NVIDIA Docker Runtime and login to the NVIDIA Container Registry
|
| 12 |
+
See [here](https://www.pugetsystems.com/labs/hpc/how-to-setup-nvidia-docker-and-ngc-registry-on-your-workstation-part-4-accessing-the-ngc-registry-1115/) for details.
|
| 13 |
+
|
| 14 |
+
2. Build the container. **From the OmniGibson root**, run: `./docker/build_docker.sh`
|
| 15 |
+
|
| 16 |
+
3. Run the container
|
| 17 |
+
* To get a shell inside a container with GUI: `sudo ./docker/run_docker_gui.sh`
|
| 18 |
+
* To get a jupyter notebook: `sudo ./docker/run_docker_notebook.sh`
|
| 19 |
+
* To get access to a shell inside a headless container `sudo ./docker/run_docker.sh`
|
| 20 |
+
|
| 21 |
+
# Development
|
| 22 |
+
To push a Docker container, run: `sudo ./docker/push_docker.sh`
|
OmniGibson/docker/build_docker.sh
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -e -o pipefail
|
| 3 |
+
|
| 4 |
+
docker build \
|
| 5 |
+
-t stanfordvl/omnigibson:latest \
|
| 6 |
+
-t stanfordvl/omnigibson:$(sed -ne "s/.*version= *['\"]\([^'\"]*\)['\"] *.*/\1/p" setup.py) \
|
| 7 |
+
-f docker/prod.Dockerfile \
|
| 8 |
+
.
|
| 9 |
+
|
| 10 |
+
# Pass the DEV_MODE=1 arg to the docker build command to build the development image
|
| 11 |
+
docker build \
|
| 12 |
+
-t stanfordvl/omnigibson-dev:latest \
|
| 13 |
+
-t stanfordvl/omnigibson-dev:$(sed -ne "s/.*version= *['\"]\([^'\"]*\)['\"] *.*/\1/p" setup.py) \
|
| 14 |
+
-f docker/prod.Dockerfile \
|
| 15 |
+
--build-arg DEV_MODE=1 \
|
| 16 |
+
.
|
| 17 |
+
|
| 18 |
+
docker build \
|
| 19 |
+
-t stanfordvl/omnigibson-vscode:latest \
|
| 20 |
+
-f docker/vscode.Dockerfile \
|
| 21 |
+
.
|
| 22 |
+
|
| 23 |
+
docker build \
|
| 24 |
+
-t stanfordvl/omnigibson-colab:latest \
|
| 25 |
+
-f docker/colab.Dockerfile \
|
| 26 |
+
.
|
OmniGibson/docker/colab.Dockerfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM stanfordvl/omnigibson:colab-docker
|
| 2 |
+
|
| 3 |
+
# environment settings
|
| 4 |
+
ARG DEBIAN_FRONTEND="noninteractive"
|
| 5 |
+
ENV OMNIGIBSON_HEADLESS="1"
|
| 6 |
+
ENV OMNIGIBSON_REMOTE_STREAMING="webrtc"
|
| 7 |
+
|
| 8 |
+
# Fix the JS file to allow for remote streaming on the same port (80)
|
| 9 |
+
RUN sed -i "s/49100/80/g" /isaac-sim/extscache/omni.services.streamclient.webrtc-1.3.8/web/js/kit-player.js && \
|
| 10 |
+
sed -i -E 's/IsValidIPv4=.*test\(e\)/IsValidIPv4=function(e){return true/g' /isaac-sim/extscache/omni.services.streamclient.webrtc-1.3.8/web/js/kit-player.js
|
| 11 |
+
|
| 12 |
+
# Install nginx
|
| 13 |
+
RUN apt-get update && apt-get install -y nginx && apt-get clean
|
| 14 |
+
|
| 15 |
+
# Download the demo dataset and the assets
|
| 16 |
+
RUN python -m omnigibson.utils.asset_utils --download_omnigibson_robot_assets --download_behavior_1k_assets --accept_license
|
| 17 |
+
|
| 18 |
+
# Add the nginx configuration file
|
| 19 |
+
ADD docker/nginx.conf /etc/nginx/sites-available/default
|
| 20 |
+
|
| 21 |
+
CMD nginx && python -m omnigibson.examples.robots.robot_control_example --quickstart
|
OmniGibson/docker/gh-actions/Dockerfile
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM stanfordvl/omnigibson-dev:og-develop
|
| 2 |
+
|
| 3 |
+
ARG DUMB_INIT_VERSION="1.2.2"
|
| 4 |
+
ARG GIT_CORE_PPA_KEY="A1715D88E1DF1F24"
|
| 5 |
+
|
| 6 |
+
ENV GIT_LFS_VERSION="3.2.0"
|
| 7 |
+
ENV LANG=en_US.UTF-8
|
| 8 |
+
ENV LANGUAGE=en_US.UTF-8
|
| 9 |
+
ENV LC_ALL=en_US.UTF-8
|
| 10 |
+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
| 11 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 12 |
+
# hadolint ignore=SC2086,DL3015,DL3008,DL3013,SC2015
|
| 13 |
+
RUN echo en_US.UTF-8 UTF-8 >> /etc/locale.gen \
|
| 14 |
+
&& apt-get update \
|
| 15 |
+
&& apt-get install -y --no-install-recommends gnupg \
|
| 16 |
+
&& ( \
|
| 17 |
+
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${GIT_CORE_PPA_KEY} \
|
| 18 |
+
|| apt-key adv --keyserver pgp.mit.edu --recv-keys ${GIT_CORE_PPA_KEY} \
|
| 19 |
+
|| apt-key adv --keyserver keyserver.pgp.com --recv-keys ${GIT_CORE_PPA_KEY} \
|
| 20 |
+
) \
|
| 21 |
+
&& apt-get update \
|
| 22 |
+
&& apt-get install -y --no-install-recommends \
|
| 23 |
+
gnupg \
|
| 24 |
+
lsb-release \
|
| 25 |
+
curl \
|
| 26 |
+
tar \
|
| 27 |
+
unzip \
|
| 28 |
+
zip \
|
| 29 |
+
apt-transport-https \
|
| 30 |
+
ca-certificates \
|
| 31 |
+
sudo \
|
| 32 |
+
gpg-agent \
|
| 33 |
+
software-properties-common \
|
| 34 |
+
build-essential \
|
| 35 |
+
zlib1g-dev \
|
| 36 |
+
zstd \
|
| 37 |
+
gettext \
|
| 38 |
+
libcurl4-openssl-dev \
|
| 39 |
+
inetutils-ping \
|
| 40 |
+
jq \
|
| 41 |
+
wget \
|
| 42 |
+
dirmngr \
|
| 43 |
+
openssh-client \
|
| 44 |
+
locales \
|
| 45 |
+
python3-pip \
|
| 46 |
+
python3-setuptools \
|
| 47 |
+
python3-venv \
|
| 48 |
+
python3 \
|
| 49 |
+
dumb-init \
|
| 50 |
+
nodejs \
|
| 51 |
+
rsync \
|
| 52 |
+
libpq-dev \
|
| 53 |
+
gosu \
|
| 54 |
+
pkg-config \
|
| 55 |
+
graphviz \
|
| 56 |
+
&& DPKG_ARCH="$(dpkg --print-architecture)" \
|
| 57 |
+
&& LSB_RELEASE_CODENAME="$(lsb_release --codename | cut -f2)" \
|
| 58 |
+
&& sed -e 's/Defaults.*env_reset/Defaults env_keep = "HTTP_PROXY HTTPS_PROXY NO_PROXY FTP_PROXY http_proxy https_proxy no_proxy ftp_proxy"/' -i /etc/sudoers \
|
| 59 |
+
&& echo deb http://ppa.launchpad.net/git-core/ppa/ubuntu $([[ $(grep -E '^ID=' /etc/os-release | sed 's/.*=//g') == "ubuntu" ]] && (grep VERSION_CODENAME /etc/os-release | sed 's/.*=//g') || echo bionic) main>/etc/apt/sources.list.d/git-core.list \
|
| 60 |
+
&& apt-get update \
|
| 61 |
+
&& ( apt-get install -y --no-install-recommends git || apt-get install -t stable -y --no-install-recommends git || apt-get install -y --no-install-recommends git=1:2.33.1-0ppa1~ubuntu18.04.1 git-man=1:2.33.1-0ppa1~ubuntu18.04.1 ) \
|
| 62 |
+
&& ( [[ $(apt-cache search -n liblttng-ust0 | awk '{print $1}') == "liblttng-ust0" ]] && apt-get install -y --no-install-recommends liblttng-ust0 || : ) \
|
| 63 |
+
&& ( [[ $(apt-cache search -n liblttng-ust1 | awk '{print $1}') == "liblttng-ust1" ]] && apt-get install -y --no-install-recommends liblttng-ust1 || : ) \
|
| 64 |
+
&& ( ( curl "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o "awscliv2.zip" && unzip awscliv2.zip -d /tmp/ && /tmp/aws/install && rm awscliv2.zip) || pip3 install --no-cache-dir awscli ) \
|
| 65 |
+
&& ( curl -s "https://github.com/git-lfs/git-lfs/releases/download/v${GIT_LFS_VERSION}/git-lfs-linux-${DPKG_ARCH}-v${GIT_LFS_VERSION}.tar.gz" -L -o /tmp/lfs.tar.gz && tar -xzf /tmp/lfs.tar.gz -C /tmp && /tmp/git-lfs-${GIT_LFS_VERSION}/install.sh && rm -rf /tmp/lfs.tar.gz /tmp/git-lfs-${GIT_LFS_VERSION}) \
|
| 66 |
+
&& distro=$(lsb_release -is | awk '{print tolower($0)}') \
|
| 67 |
+
&& VERSION_ID=$(lsb_release -r | cut -f2) \
|
| 68 |
+
&& echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel-kubic-libcontainers-stable.list \
|
| 69 |
+
&& curl -Ls https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_$VERSION_ID/Release.key | apt-key add - \
|
| 70 |
+
&& apt-get update \
|
| 71 |
+
&& apt-get install buildah podman fuse-overlayfs -y \
|
| 72 |
+
&& sed -i 's/^\[machine\]$/#\[machine\]/' /usr/share/containers/containers.conf \
|
| 73 |
+
# && sed -i 's/#mount_program/mount_program/g' /etc/containers/storage.conf \
|
| 74 |
+
&& mkdir -p /etc/apt/keyrings \
|
| 75 |
+
&& ( curl -fsSL https://download.docker.com/linux/${distro}/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg ) \
|
| 76 |
+
&& version=$(lsb_release -cs | sed 's/trixie\|n\/a/bookworm/g') \
|
| 77 |
+
&& ( echo "deb [arch=${DPKG_ARCH} signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/${distro} ${version} stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null ) \
|
| 78 |
+
&& apt-get update \
|
| 79 |
+
&& apt-get install -y docker-ce docker-ce-cli docker-buildx-plugin containerd.io docker-compose-plugin --no-install-recommends --allow-unauthenticated \
|
| 80 |
+
&& echo -e '#!/bin/sh\ndocker compose --compatibility "$@"' > /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose \
|
| 81 |
+
&& ( [[ "${LSB_RELEASE_CODENAME}" == "focal" ]] && ( echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/ /" | tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list && curl -L "https://build.opensuse.org/projects/devel:kubic/public_key" | apt-key add -; echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/ /" | tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list && curl -L "https://build.opensuse.org/projects/devel:kubic/public_key" | apt-key add - && apt-get update) || : ) \
|
| 82 |
+
&& ( [[ "${LSB_RELEASE_CODENAME}" == "focal" || "${LSB_RELEASE_CODENAME}" == "jammy" || "${LSB_RELEASE_CODENAME}" == "sid" || "${LSB_RELEASE_CODENAME}" == "bullseye" ]] && apt-get install -y --no-install-recommends podman buildah skopeo || : ) \
|
| 83 |
+
&& ( [[ "${LSB_RELEASE_CODENAME}" == "jammy" ]] && echo "Ubuntu Jammy is marked as beta. Please see https://github.com/actions/virtual-environments/issues/5490" || : ) \
|
| 84 |
+
&& GH_CLI_VERSION=$(curl -sL -H "Accept: application/vnd.github+json" https://api.github.com/repos/cli/cli/releases/latest | jq -r '.tag_name' | sed 's/^v//g') \
|
| 85 |
+
&& GH_CLI_DOWNLOAD_URL=$(curl -sL -H "Accept: application/vnd.github+json" https://api.github.com/repos/cli/cli/releases/latest | jq ".assets[] | select(.name == \"gh_${GH_CLI_VERSION}_linux_${DPKG_ARCH}.deb\")" | jq -r '.browser_download_url') \
|
| 86 |
+
&& curl -sSLo /tmp/ghcli.deb ${GH_CLI_DOWNLOAD_URL} && apt-get -y install /tmp/ghcli.deb && rm /tmp/ghcli.deb \
|
| 87 |
+
&& YQ_VERSION=$(curl -sL -H "Accept: application/vnd.github+json" https://api.github.com/repos/mikefarah/yq/releases/latest | jq -r '.tag_name' | sed 's/^v//g') \
|
| 88 |
+
&& YQ_DOWNLOAD_URL=$(curl -sL -H "Accept: application/vnd.github+json" https://api.github.com/repos/mikefarah/yq/releases/latest | jq ".assets[] | select(.name == \"yq_linux_${DPKG_ARCH}.tar.gz\")" | jq -r '.browser_download_url') \
|
| 89 |
+
&& ( curl -s ${YQ_DOWNLOAD_URL} -L -o /tmp/yq.tar.gz && tar -xzf /tmp/yq.tar.gz -C /tmp && mv /tmp/yq_linux_${DPKG_ARCH} /usr/local/bin/yq) \
|
| 90 |
+
&& rm -rf /var/lib/apt/lists/* \
|
| 91 |
+
&& rm -rf /tmp/* \
|
| 92 |
+
&& groupadd -g 121 runner \
|
| 93 |
+
&& useradd -mr -d /home/runner -u 1001 -g 121 runner \
|
| 94 |
+
&& usermod -aG sudo runner \
|
| 95 |
+
&& usermod -aG docker runner \
|
| 96 |
+
&& echo '%sudo ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers \
|
| 97 |
+
&& ( [[ -f /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list ]] && rm /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list || : )
|
| 98 |
+
|
| 99 |
+
ENV AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
|
| 100 |
+
RUN mkdir -p /opt/hostedtoolcache
|
| 101 |
+
|
| 102 |
+
ARG GH_RUNNER_VERSION="2.320.0"
|
| 103 |
+
|
| 104 |
+
ARG TARGETPLATFORM
|
| 105 |
+
|
| 106 |
+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
| 107 |
+
|
| 108 |
+
WORKDIR /actions-runner
|
| 109 |
+
COPY install_actions.sh /actions-runner
|
| 110 |
+
|
| 111 |
+
RUN chmod +x /actions-runner/install_actions.sh \
|
| 112 |
+
&& /actions-runner/install_actions.sh ${GH_RUNNER_VERSION} ${TARGETPLATFORM} \
|
| 113 |
+
&& rm /actions-runner/install_actions.sh \
|
| 114 |
+
&& chown runner /_work /actions-runner /opt/hostedtoolcache
|
| 115 |
+
|
| 116 |
+
COPY token.sh entrypoint.sh app_token.sh /
|
| 117 |
+
RUN chmod +x /token.sh /entrypoint.sh /app_token.sh
|
| 118 |
+
|
| 119 |
+
ENTRYPOINT ["/entrypoint.sh"]
|
| 120 |
+
CMD ["./bin/Runner.Listener", "run", "--startuptype", "service"]
|
OmniGibson/docker/gh-actions/app_token.sh
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
#
|
| 3 |
+
# Request an ACCESS_TOKEN to be used by a GitHub APP
|
| 4 |
+
# Environment variable that need to be set up:
|
| 5 |
+
# * APP_ID, the GitHub's app ID
|
| 6 |
+
# * APP_PRIVATE_KEY, the content of GitHub app's private key in PEM format.
|
| 7 |
+
# * APP_LOGIN, the login name used to install GitHub's app
|
| 8 |
+
#
|
| 9 |
+
# https://github.com/orgs/community/discussions/24743#discussioncomment-3245300
|
| 10 |
+
#
|
| 11 |
+
|
| 12 |
+
set -o pipefail
|
| 13 |
+
|
| 14 |
+
_GITHUB_HOST=${GITHUB_HOST:="github.com"}
|
| 15 |
+
|
| 16 |
+
# If URL is not github.com then use the enterprise api endpoint
|
| 17 |
+
if [[ ${GITHUB_HOST} = "github.com" ]]; then
|
| 18 |
+
URI="https://api.${_GITHUB_HOST}"
|
| 19 |
+
else
|
| 20 |
+
URI="https://${_GITHUB_HOST}/api/v3"
|
| 21 |
+
fi
|
| 22 |
+
|
| 23 |
+
API_VERSION=v3
|
| 24 |
+
API_HEADER="Accept: application/vnd.github.${API_VERSION}+json"
|
| 25 |
+
CONTENT_LENGTH_HEADER="Content-Length: 0"
|
| 26 |
+
APP_INSTALLATIONS_URI="${URI}/app/installations"
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
# JWT parameters based off
|
| 30 |
+
# https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app
|
| 31 |
+
#
|
| 32 |
+
# JWT token issuance and expiration parameters
|
| 33 |
+
JWT_IAT_DRIFT=60
|
| 34 |
+
JWT_EXP_DELTA=600
|
| 35 |
+
|
| 36 |
+
JWT_JOSE_HEADER='{
|
| 37 |
+
"alg": "RS256",
|
| 38 |
+
"typ": "JWT"
|
| 39 |
+
}'
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
build_jwt_payload() {
|
| 43 |
+
now=$(date +%s)
|
| 44 |
+
iat=$((now - JWT_IAT_DRIFT))
|
| 45 |
+
jq -c \
|
| 46 |
+
--arg iat_str "${iat}" \
|
| 47 |
+
--arg exp_delta_str "${JWT_EXP_DELTA}" \
|
| 48 |
+
--arg app_id_str "${APP_ID}" \
|
| 49 |
+
'
|
| 50 |
+
($iat_str | tonumber) as $iat
|
| 51 |
+
| ($exp_delta_str | tonumber) as $exp_delta
|
| 52 |
+
| ($app_id_str | tonumber) as $app_id
|
| 53 |
+
| .iat = $iat
|
| 54 |
+
| .exp = ($iat + $exp_delta)
|
| 55 |
+
| .iss = $app_id
|
| 56 |
+
' <<< "{}" | tr -d '\n'
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
base64url() {
|
| 60 |
+
base64 | tr '+/' '-_' | tr -d '=\n'
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
rs256_sign() {
|
| 64 |
+
openssl dgst -binary -sha256 -sign <(echo "$1")
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
request_access_token() {
|
| 68 |
+
jwt_payload=$(build_jwt_payload)
|
| 69 |
+
encoded_jwt_parts=$(base64url <<<"${JWT_JOSE_HEADER}").$(base64url <<<"${jwt_payload}")
|
| 70 |
+
encoded_mac=$(echo -n "${encoded_jwt_parts}" | rs256_sign "${APP_PRIVATE_KEY}" | base64url)
|
| 71 |
+
generated_jwt="${encoded_jwt_parts}.${encoded_mac}"
|
| 72 |
+
|
| 73 |
+
auth_header="Authorization: Bearer ${generated_jwt}"
|
| 74 |
+
|
| 75 |
+
app_installations_response=$(curl -sX GET \
|
| 76 |
+
-H "${auth_header}" \
|
| 77 |
+
-H "${API_HEADER}" \
|
| 78 |
+
"${APP_INSTALLATIONS_URI}" \
|
| 79 |
+
)
|
| 80 |
+
access_token_url=$(echo "${app_installations_response}" | jq --raw-output '.[] | select (.account.login == "'"${APP_LOGIN}"'" and .app_id == '"${APP_ID}"') .access_tokens_url')
|
| 81 |
+
curl -sX POST \
|
| 82 |
+
-H "${CONTENT_LENGTH_HEADER}" \
|
| 83 |
+
-H "${auth_header}" \
|
| 84 |
+
-H "${API_HEADER}" \
|
| 85 |
+
"${access_token_url}" | \
|
| 86 |
+
jq --raw-output .token
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
request_access_token
|
OmniGibson/docker/gh-actions/entrypoint.sh
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/dumb-init /bin/bash
|
| 2 |
+
# shellcheck shell=bash
|
| 3 |
+
|
| 4 |
+
export RUNNER_ALLOW_RUNASROOT=1
|
| 5 |
+
export PATH=${PATH}:/actions-runner
|
| 6 |
+
|
| 7 |
+
# Un-export these, so that they must be passed explicitly to the environment of
|
| 8 |
+
# any command that needs them. This may help prevent leaks.
|
| 9 |
+
export -n ACCESS_TOKEN
|
| 10 |
+
export -n RUNNER_TOKEN
|
| 11 |
+
export -n APP_ID
|
| 12 |
+
export -n APP_PRIVATE_KEY
|
| 13 |
+
|
| 14 |
+
deregister_runner() {
|
| 15 |
+
echo "Caught SIGTERM. Deregistering runner"
|
| 16 |
+
if [[ -n "${ACCESS_TOKEN}" ]]; then
|
| 17 |
+
_TOKEN=$(ACCESS_TOKEN="${ACCESS_TOKEN}" bash /token.sh)
|
| 18 |
+
RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
|
| 19 |
+
fi
|
| 20 |
+
./config.sh remove --token "${RUNNER_TOKEN}"
|
| 21 |
+
exit
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
_DISABLE_AUTOMATIC_DEREGISTRATION=${DISABLE_AUTOMATIC_DEREGISTRATION:-false}
|
| 25 |
+
|
| 26 |
+
_RANDOM_RUNNER_SUFFIX=${RANDOM_RUNNER_SUFFIX:="true"}
|
| 27 |
+
|
| 28 |
+
_RUNNER_NAME=${RUNNER_NAME:-${RUNNER_NAME_PREFIX:-github-runner}-$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo '')}
|
| 29 |
+
if [[ ${RANDOM_RUNNER_SUFFIX} != "true" ]]; then
|
| 30 |
+
# In some cases this file does not exist
|
| 31 |
+
if [[ -f "/etc/hostname" ]]; then
|
| 32 |
+
# in some cases it can also be empty
|
| 33 |
+
if [[ $(stat --printf="%s" /etc/hostname) -ne 0 ]]; then
|
| 34 |
+
_RUNNER_NAME=${RUNNER_NAME:-${RUNNER_NAME_PREFIX:-github-runner}-$(cat /etc/hostname)}
|
| 35 |
+
echo "RANDOM_RUNNER_SUFFIX is ${RANDOM_RUNNER_SUFFIX}. /etc/hostname exists and has content. Setting runner name to ${_RUNNER_NAME}"
|
| 36 |
+
else
|
| 37 |
+
echo "RANDOM_RUNNER_SUFFIX is ${RANDOM_RUNNER_SUFFIX} ./etc/hostname exists but is empty. Not using /etc/hostname."
|
| 38 |
+
fi
|
| 39 |
+
else
|
| 40 |
+
echo "RANDOM_RUNNER_SUFFIX is ${RANDOM_RUNNER_SUFFIX} but /etc/hostname does not exist. Not using /etc/hostname."
|
| 41 |
+
fi
|
| 42 |
+
fi
|
| 43 |
+
|
| 44 |
+
_RUNNER_WORKDIR=${RUNNER_WORKDIR:-/_work/${_RUNNER_NAME}}
|
| 45 |
+
_LABELS=${LABELS:-default}
|
| 46 |
+
_RUNNER_GROUP=${RUNNER_GROUP:-Default}
|
| 47 |
+
_GITHUB_HOST=${GITHUB_HOST:="github.com"}
|
| 48 |
+
_RUN_AS_ROOT=${RUN_AS_ROOT:="true"}
|
| 49 |
+
_START_DOCKER_SERVICE=${START_DOCKER_SERVICE:="false"}
|
| 50 |
+
|
| 51 |
+
# ensure backwards compatibility
|
| 52 |
+
if [[ -z ${RUNNER_SCOPE} ]]; then
|
| 53 |
+
if [[ ${ORG_RUNNER} == "true" ]]; then
|
| 54 |
+
echo 'ORG_RUNNER is now deprecated. Please use RUNNER_SCOPE="org" instead.'
|
| 55 |
+
export RUNNER_SCOPE="org"
|
| 56 |
+
else
|
| 57 |
+
export RUNNER_SCOPE="repo"
|
| 58 |
+
fi
|
| 59 |
+
fi
|
| 60 |
+
|
| 61 |
+
RUNNER_SCOPE="${RUNNER_SCOPE,,}" # to lowercase
|
| 62 |
+
|
| 63 |
+
case ${RUNNER_SCOPE} in
|
| 64 |
+
org*)
|
| 65 |
+
[[ -z ${ORG_NAME} ]] && ( echo "ORG_NAME required for org runners"; exit 1 )
|
| 66 |
+
_SHORT_URL="https://${_GITHUB_HOST}/${ORG_NAME}"
|
| 67 |
+
RUNNER_SCOPE="org"
|
| 68 |
+
if [[ -n "${APP_ID}" ]] && [[ -z "${APP_LOGIN}" ]]; then
|
| 69 |
+
APP_LOGIN=${ORG_NAME}
|
| 70 |
+
fi
|
| 71 |
+
;;
|
| 72 |
+
|
| 73 |
+
ent*)
|
| 74 |
+
[[ -z ${ENTERPRISE_NAME} ]] && ( echo "ENTERPRISE_NAME required for enterprise runners"; exit 1 )
|
| 75 |
+
_SHORT_URL="https://${_GITHUB_HOST}/enterprises/${ENTERPRISE_NAME}"
|
| 76 |
+
RUNNER_SCOPE="enterprise"
|
| 77 |
+
;;
|
| 78 |
+
|
| 79 |
+
*)
|
| 80 |
+
[[ -z ${REPO_URL} ]] && ( echo "REPO_URL required for repo runners"; exit 1 )
|
| 81 |
+
_SHORT_URL=${REPO_URL}
|
| 82 |
+
RUNNER_SCOPE="repo"
|
| 83 |
+
if [[ -n "${APP_ID}" ]] && [[ -z "${APP_LOGIN}" ]]; then
|
| 84 |
+
APP_LOGIN=${REPO_URL%/*}
|
| 85 |
+
APP_LOGIN=${APP_LOGIN##*/}
|
| 86 |
+
fi
|
| 87 |
+
;;
|
| 88 |
+
esac
|
| 89 |
+
|
| 90 |
+
configure_runner() {
|
| 91 |
+
ARGS=()
|
| 92 |
+
if [[ -n "${APP_ID}" ]] && [[ -n "${APP_PRIVATE_KEY}" ]] && [[ -n "${APP_LOGIN}" ]]; then
|
| 93 |
+
if [[ -n "${ACCESS_TOKEN}" ]] || [[ -n "${RUNNER_TOKEN}" ]]; then
|
| 94 |
+
echo "ERROR: ACCESS_TOKEN or RUNNER_TOKEN provided but are mutually exclusive with APP_ID, APP_PRIVATE_KEY and APP_LOGIN." >&2
|
| 95 |
+
exit 1
|
| 96 |
+
fi
|
| 97 |
+
echo "Obtaining access token for app_id ${APP_ID} and login ${APP_LOGIN}"
|
| 98 |
+
nl="
|
| 99 |
+
"
|
| 100 |
+
ACCESS_TOKEN=$(APP_ID="${APP_ID}" APP_PRIVATE_KEY="${APP_PRIVATE_KEY//\\n/${nl}}" APP_LOGIN="${APP_LOGIN}" bash /app_token.sh)
|
| 101 |
+
elif [[ -n "${APP_ID}" ]] || [[ -n "${APP_PRIVATE_KEY}" ]] || [[ -n "${APP_LOGIN}" ]]; then
|
| 102 |
+
echo "ERROR: All of APP_ID, APP_PRIVATE_KEY and APP_LOGIN must be specified." >&2
|
| 103 |
+
exit 1
|
| 104 |
+
fi
|
| 105 |
+
|
| 106 |
+
if [[ -n "${ACCESS_TOKEN}" ]]; then
|
| 107 |
+
echo "Obtaining the token of the runner"
|
| 108 |
+
_TOKEN=$(ACCESS_TOKEN="${ACCESS_TOKEN}" bash /token.sh)
|
| 109 |
+
RUNNER_TOKEN=$(echo "${_TOKEN}" | jq -r .token)
|
| 110 |
+
fi
|
| 111 |
+
|
| 112 |
+
# shellcheck disable=SC2153
|
| 113 |
+
if [ -n "${EPHEMERAL}" ]; then
|
| 114 |
+
echo "Ephemeral option is enabled"
|
| 115 |
+
ARGS+=("--ephemeral")
|
| 116 |
+
fi
|
| 117 |
+
|
| 118 |
+
if [ -n "${DISABLE_AUTO_UPDATE}" ]; then
|
| 119 |
+
echo "Disable auto update option is enabled"
|
| 120 |
+
ARGS+=("--disableupdate")
|
| 121 |
+
fi
|
| 122 |
+
|
| 123 |
+
if [ -n "${NO_DEFAULT_LABELS}" ]; then
|
| 124 |
+
echo "Disable adding the default self-hosted, platform, and architecture labels"
|
| 125 |
+
ARGS+=("--no-default-labels")
|
| 126 |
+
fi
|
| 127 |
+
|
| 128 |
+
echo "Configuring"
|
| 129 |
+
./config.sh \
|
| 130 |
+
--url "${_SHORT_URL}" \
|
| 131 |
+
--token "${RUNNER_TOKEN}" \
|
| 132 |
+
--name "${_RUNNER_NAME}" \
|
| 133 |
+
--work "${_RUNNER_WORKDIR}" \
|
| 134 |
+
--labels "${_LABELS}" \
|
| 135 |
+
--runnergroup "${_RUNNER_GROUP}" \
|
| 136 |
+
--unattended \
|
| 137 |
+
--replace \
|
| 138 |
+
"${ARGS[@]}"
|
| 139 |
+
|
| 140 |
+
[[ ! -d "${_RUNNER_WORKDIR}" ]] && mkdir "${_RUNNER_WORKDIR}"
|
| 141 |
+
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
# Opt into runner reusage because a value was given
|
| 146 |
+
if [[ -n "${CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]]; then
|
| 147 |
+
echo "Runner reusage is enabled"
|
| 148 |
+
|
| 149 |
+
# directory exists, copy the data
|
| 150 |
+
if [[ -d "${CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]]; then
|
| 151 |
+
echo "Copying previous data"
|
| 152 |
+
cp -p -r "${CONFIGURED_ACTIONS_RUNNER_FILES_DIR}/." "/actions-runner"
|
| 153 |
+
fi
|
| 154 |
+
|
| 155 |
+
if [ -f "/actions-runner/.runner" ]; then
|
| 156 |
+
echo "The runner has already been configured"
|
| 157 |
+
else
|
| 158 |
+
configure_runner
|
| 159 |
+
fi
|
| 160 |
+
else
|
| 161 |
+
echo "Runner reusage is disabled"
|
| 162 |
+
configure_runner
|
| 163 |
+
fi
|
| 164 |
+
|
| 165 |
+
if [[ -n "${CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]]; then
|
| 166 |
+
echo "Reusage is enabled. Storing data to ${CONFIGURED_ACTIONS_RUNNER_FILES_DIR}"
|
| 167 |
+
# Quoting (even with double-quotes) the regexp brokes the copying
|
| 168 |
+
cp -p -r "/actions-runner/_diag" "/actions-runner/svc.sh" /actions-runner/.[^.]* "${CONFIGURED_ACTIONS_RUNNER_FILES_DIR}"
|
| 169 |
+
fi
|
| 170 |
+
|
| 171 |
+
if [[ ${_DISABLE_AUTOMATIC_DEREGISTRATION} == "false" ]]; then
|
| 172 |
+
trap deregister_runner SIGINT SIGQUIT SIGTERM INT TERM QUIT
|
| 173 |
+
fi
|
| 174 |
+
|
| 175 |
+
# Start docker service if needed (e.g. for docker-in-docker)
|
| 176 |
+
if [[ ${_START_DOCKER_SERVICE} == "true" ]]; then
|
| 177 |
+
echo "Starting docker service"
|
| 178 |
+
_PREFIX=""
|
| 179 |
+
[[ ${_RUN_AS_ROOT} != "true" ]] && _PREFIX="sudo"
|
| 180 |
+
${_PREFIX} service docker start
|
| 181 |
+
fi
|
| 182 |
+
|
| 183 |
+
# Container's command (CMD) execution as runner user
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
if [[ ${_RUN_AS_ROOT} == "true" ]]; then
|
| 187 |
+
if [[ $(id -u) -eq 0 ]]; then
|
| 188 |
+
"$@"
|
| 189 |
+
else
|
| 190 |
+
echo "ERROR: RUN_AS_ROOT env var is set to true but the user has been overridden and is not running as root, but UID '$(id -u)'"
|
| 191 |
+
exit 1
|
| 192 |
+
fi
|
| 193 |
+
else
|
| 194 |
+
if [[ $(id -u) -eq 0 ]]; then
|
| 195 |
+
[[ -n "${CONFIGURED_ACTIONS_RUNNER_FILES_DIR}" ]] && chown -R runner "${CONFIGURED_ACTIONS_RUNNER_FILES_DIR}"
|
| 196 |
+
chown -R runner "${_RUNNER_WORKDIR}" /actions-runner
|
| 197 |
+
# The toolcache is not recursively chowned to avoid recursing over prepulated tooling in derived docker images
|
| 198 |
+
chown runner /opt/hostedtoolcache/
|
| 199 |
+
/usr/sbin/gosu runner "$@"
|
| 200 |
+
else
|
| 201 |
+
"$@"
|
| 202 |
+
fi
|
| 203 |
+
fi
|
OmniGibson/docker/gh-actions/install_actions.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash -ex
|
| 2 |
+
GH_RUNNER_VERSION=$1
|
| 3 |
+
TARGETPLATFORM=$2
|
| 4 |
+
|
| 5 |
+
export TARGET_ARCH="x64"
|
| 6 |
+
if [[ $TARGETPLATFORM == "linux/arm64" ]]; then
|
| 7 |
+
export TARGET_ARCH="arm64"
|
| 8 |
+
fi
|
| 9 |
+
curl -L "https://github.com/actions/runner/releases/download/v${GH_RUNNER_VERSION}/actions-runner-linux-${TARGET_ARCH}-${GH_RUNNER_VERSION}.tar.gz" > actions.tar.gz
|
| 10 |
+
tar -zxf actions.tar.gz
|
| 11 |
+
rm -f actions.tar.gz
|
| 12 |
+
./bin/installdependencies.sh
|
| 13 |
+
mkdir /_work
|
OmniGibson/docker/gh-actions/token.sh
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
_GITHUB_HOST=${GITHUB_HOST:="github.com"}
|
| 4 |
+
|
| 5 |
+
# If URL is not github.com then use the enterprise api endpoint
|
| 6 |
+
if [[ ${GITHUB_HOST} = "github.com" ]]; then
|
| 7 |
+
URI="https://api.${_GITHUB_HOST}"
|
| 8 |
+
else
|
| 9 |
+
URI="https://${_GITHUB_HOST}/api/v3"
|
| 10 |
+
fi
|
| 11 |
+
|
| 12 |
+
API_VERSION=v3
|
| 13 |
+
API_HEADER="Accept: application/vnd.github.${API_VERSION}+json"
|
| 14 |
+
AUTH_HEADER="Authorization: token ${ACCESS_TOKEN}"
|
| 15 |
+
CONTENT_LENGTH_HEADER="Content-Length: 0"
|
| 16 |
+
|
| 17 |
+
case ${RUNNER_SCOPE} in
|
| 18 |
+
org*)
|
| 19 |
+
_FULL_URL="${URI}/orgs/${ORG_NAME}/actions/runners/registration-token"
|
| 20 |
+
;;
|
| 21 |
+
|
| 22 |
+
ent*)
|
| 23 |
+
_FULL_URL="${URI}/enterprises/${ENTERPRISE_NAME}/actions/runners/registration-token"
|
| 24 |
+
;;
|
| 25 |
+
|
| 26 |
+
*)
|
| 27 |
+
_PROTO="https://"
|
| 28 |
+
# shellcheck disable=SC2116
|
| 29 |
+
_URL="$(echo "${REPO_URL/${_PROTO}/}")"
|
| 30 |
+
_PATH="$(echo "${_URL}" | grep / | cut -d/ -f2-)"
|
| 31 |
+
_ACCOUNT="$(echo "${_PATH}" | cut -d/ -f1)"
|
| 32 |
+
_REPO="$(echo "${_PATH}" | cut -d/ -f2)"
|
| 33 |
+
_FULL_URL="${URI}/repos/${_ACCOUNT}/${_REPO}/actions/runners/registration-token"
|
| 34 |
+
;;
|
| 35 |
+
esac
|
| 36 |
+
|
| 37 |
+
RUNNER_TOKEN="$(curl -XPOST -fsSL \
|
| 38 |
+
-H "${CONTENT_LENGTH_HEADER}" \
|
| 39 |
+
-H "${AUTH_HEADER}" \
|
| 40 |
+
-H "${API_HEADER}" \
|
| 41 |
+
"${_FULL_URL}" \
|
| 42 |
+
| jq -r '.token')"
|
| 43 |
+
|
| 44 |
+
echo "{\"token\": \"${RUNNER_TOKEN}\", \"full_url\": \"${_FULL_URL}\"}"
|
OmniGibson/docker/launch_vscode.sh
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
#SBATCH --job-name=omnigibson-vscode
|
| 3 |
+
#SBATCH --account=cvgl
|
| 4 |
+
#SBATCH --partition=svl --qos=normal
|
| 5 |
+
#SBATCH --nodes=1
|
| 6 |
+
#SBATCH --cpus-per-task=8
|
| 7 |
+
#SBATCH --mem=30G
|
| 8 |
+
#SBATCH --gres=gpu:2080ti:1
|
| 9 |
+
|
| 10 |
+
set -e -o pipefail
|
| 11 |
+
|
| 12 |
+
# Get the username
|
| 13 |
+
USERNAME=$(whoami)
|
| 14 |
+
|
| 15 |
+
# Define the base directory
|
| 16 |
+
BASE_DIR="/cvgl2/u/$USERNAME"
|
| 17 |
+
|
| 18 |
+
# Step 1: Check if the user's directory exists
|
| 19 |
+
if [ ! -d "$BASE_DIR" ]; then
|
| 20 |
+
echo "Error: Directory $BASE_DIR does not exist. Please ask for a directory to be created."
|
| 21 |
+
exit 1
|
| 22 |
+
fi
|
| 23 |
+
|
| 24 |
+
# cd into the base directory
|
| 25 |
+
cd $BASE_DIR
|
| 26 |
+
|
| 27 |
+
# Define the vscode-config directory
|
| 28 |
+
VSCODE_CONFIG_DIR="$BASE_DIR/vscode-config"
|
| 29 |
+
|
| 30 |
+
# Step 2: Check if the vscode-config directory exists, if not create it
|
| 31 |
+
if [ ! -d "$VSCODE_CONFIG_DIR" ]; then
|
| 32 |
+
mkdir "$VSCODE_CONFIG_DIR" || { echo "Error creating $VSCODE_CONFIG_DIR"; exit 1; }
|
| 33 |
+
fi
|
| 34 |
+
|
| 35 |
+
# Define the extensions and data directories
|
| 36 |
+
EXTENSIONS_DIR="$VSCODE_CONFIG_DIR/extensions"
|
| 37 |
+
DATA_DIR="$VSCODE_CONFIG_DIR/data"
|
| 38 |
+
|
| 39 |
+
# Step 3: Check and create the extensions and data directories
|
| 40 |
+
if [ ! -d "$EXTENSIONS_DIR" ]; then
|
| 41 |
+
mkdir "$EXTENSIONS_DIR" || { echo "Error creating $EXTENSIONS_DIR"; exit 1; }
|
| 42 |
+
fi
|
| 43 |
+
|
| 44 |
+
if [ ! -d "$DATA_DIR" ]; then
|
| 45 |
+
mkdir "$DATA_DIR" || { echo "Error creating $DATA_DIR"; exit 1; }
|
| 46 |
+
fi
|
| 47 |
+
|
| 48 |
+
# Step 4: Clone OmniGibson if necessary
|
| 49 |
+
if [ ! -d "$BASE_DIR/OmniGibson" ]; then
|
| 50 |
+
git clone https://github.com/StanfordVL/OmniGibson.git $BASE_DIR/OmniGibson
|
| 51 |
+
cd $BASE_DIR/OmniGibson
|
| 52 |
+
git pull
|
| 53 |
+
git checkout vscode-docker # TODO: Change this to og-develop before vscode-docker is merged
|
| 54 |
+
cd $BASE_DIR
|
| 55 |
+
fi
|
| 56 |
+
|
| 57 |
+
# Step 5: Find three free ports
|
| 58 |
+
WEBRTC_PORT=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1])')
|
| 59 |
+
HTTP_PORT=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1])')
|
| 60 |
+
VSCODE_PORT=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1])')
|
| 61 |
+
|
| 62 |
+
# Ensure that the two ports are different
|
| 63 |
+
while [ "$HTTP_PORT" -eq "$WEBRTC_PORT" ]; do
|
| 64 |
+
HTTP_PORT=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1])')
|
| 65 |
+
done
|
| 66 |
+
|
| 67 |
+
# Ensure that the three ports are different
|
| 68 |
+
while [ "$VSCODE_PORT" -eq "$WEBRTC_PORT" ] || [ "$VSCODE_PORT" -eq "$HTTP_PORT" ]; do
|
| 69 |
+
VSCODE_PORT=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1])')
|
| 70 |
+
done
|
| 71 |
+
|
| 72 |
+
# Print HTTP link to access webrtc and vscode
|
| 73 |
+
FQDN_HOSTNAME=$(hostname -i) # $(curl "https://checkip.amazonaws.com")
|
| 74 |
+
echo "[OMNIGIBSON-VSCODE] Launching remote OmniGibson environment..."
|
| 75 |
+
echo "[OMNIGIBSON-VSCODE] To access vscode, go to http://${FQDN_HOSTNAME}:${VSCODE_PORT}"
|
| 76 |
+
echo "[OMNIGIBSON-VSCODE] To access webrtc, go to http://${FQDN_HOSTNAME}:${HTTP_PORT}/streaming/webrtc-client"
|
| 77 |
+
echo ""
|
| 78 |
+
|
| 79 |
+
# Step 6: Create the container
|
| 80 |
+
IMAGE_PATH="/cvgl/group/Gibson/og-docker/omnigibson-vscode.sqsh"
|
| 81 |
+
GPU_ID=$(nvidia-smi -L | grep -oP '(?<=GPU-)[a-fA-F0-9\-]+' | head -n 1)
|
| 82 |
+
ISAAC_CACHE_PATH="/scr-ssd/${SLURM_JOB_USER}/isaac_cache_${GPU_ID}"
|
| 83 |
+
|
| 84 |
+
# Define env kwargs to pass
|
| 85 |
+
declare -A ENVS=(
|
| 86 |
+
[NVIDIA_DRIVER_CAPABILITIES]=all
|
| 87 |
+
[NVIDIA_VISIBLE_DEVICES]=0
|
| 88 |
+
[DISPLAY]=""
|
| 89 |
+
[OMNIGIBSON_REMOTE_STREAMING]="webrtc"
|
| 90 |
+
[OMNIGIBSON_HTTP_PORT]=${HTTP_PORT}
|
| 91 |
+
[OMNIGIBSON_WEBRTC_PORT]=${WEBRTC_PORT}
|
| 92 |
+
[OMNIGIBSON_VSCODE_PORT]=${VSCODE_PORT}
|
| 93 |
+
[PASSWORD]=${USERNAME}
|
| 94 |
+
)
|
| 95 |
+
for env_var in "${!ENVS[@]}"; do
|
| 96 |
+
# Add to env kwargs we'll pass to enroot command later
|
| 97 |
+
ENV_KWARGS="${ENV_KWARGS} --env ${env_var}=${ENVS[${env_var}]}"
|
| 98 |
+
done
|
| 99 |
+
|
| 100 |
+
# Define mounts to create (maps local directory to container directory)
|
| 101 |
+
declare -A MOUNTS=(
|
| 102 |
+
[/scr-ssd/og-data-0-2-1]=/data
|
| 103 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/kit/cache/Kit]=/isaac-sim/kit/cache/Kit
|
| 104 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/cache/ov]=/root/.cache/ov
|
| 105 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/cache/pip]=/root/.cache/pip
|
| 106 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/cache/glcache]=/root/.cache/nvidia/GLCache
|
| 107 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/cache/computecache]=/root/.nv/ComputeCache
|
| 108 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/logs]=/root/.nvidia-omniverse/logs
|
| 109 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/config]=/root/.nvidia-omniverse/config
|
| 110 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/data]=/root/.local/share/ov/data
|
| 111 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/documents]=/root/Documents
|
| 112 |
+
[${BASE_DIR}/OmniGibson]=/omnigibson-src
|
| 113 |
+
[${VSCODE_CONFIG_DIR}]=/vscode-config
|
| 114 |
+
)
|
| 115 |
+
|
| 116 |
+
MOUNT_KWARGS=""
|
| 117 |
+
for mount in "${!MOUNTS[@]}"; do
|
| 118 |
+
# Verify mount path in local directory exists, otherwise, create it
|
| 119 |
+
if [ ! -e "$mount" ]; then
|
| 120 |
+
mkdir -p ${mount}
|
| 121 |
+
fi
|
| 122 |
+
# Add to mount kwargs we'll pass to enroot command later
|
| 123 |
+
MOUNT_KWARGS="${MOUNT_KWARGS} --mount ${mount}:${MOUNTS[${mount}]}"
|
| 124 |
+
done
|
| 125 |
+
|
| 126 |
+
# Create the image, even if it exists.
|
| 127 |
+
CONTAINER_NAME=omnigibson_${GPU_ID}
|
| 128 |
+
enroot create --force --name ${CONTAINER_NAME} ${IMAGE_PATH}
|
| 129 |
+
|
| 130 |
+
# Remove leading space in string
|
| 131 |
+
ENV_KWARGS="${ENV_KWARGS:1}"
|
| 132 |
+
MOUNT_KWARGS="${MOUNT_KWARGS:1}"
|
| 133 |
+
|
| 134 |
+
# Step 7: Launch the container
|
| 135 |
+
ENROOT_MOUNT_HOME=no enroot start \
|
| 136 |
+
--root \
|
| 137 |
+
--rw \
|
| 138 |
+
${ENV_KWARGS} \
|
| 139 |
+
${MOUNT_KWARGS} \
|
| 140 |
+
${CONTAINER_NAME}
|
| 141 |
+
|
| 142 |
+
# Clean up the image if possible.
|
| 143 |
+
enroot remove -f ${CONTAINER_NAME}
|
OmniGibson/docker/nginx.conf
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
map $http_upgrade $connection_upgrade {
|
| 2 |
+
default upgrade;
|
| 3 |
+
'' close;
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
server {
|
| 7 |
+
listen 8123;
|
| 8 |
+
|
| 9 |
+
location /streaming/ {
|
| 10 |
+
proxy_pass http://127.0.0.1:8211/streaming/;
|
| 11 |
+
proxy_http_version 1.1;
|
| 12 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 13 |
+
proxy_set_header Connection $connection_upgrade;
|
| 14 |
+
proxy_set_header Host $host;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
location / {
|
| 18 |
+
proxy_pass http://127.0.0.1:49100/;
|
| 19 |
+
proxy_http_version 1.1;
|
| 20 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 21 |
+
proxy_set_header Connection $connection_upgrade;
|
| 22 |
+
proxy_set_header Host $host;
|
| 23 |
+
}
|
| 24 |
+
}
|
OmniGibson/docker/prod.Dockerfile
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM nvcr.io/nvidia/isaac-sim:4.5.0
|
| 2 |
+
|
| 3 |
+
# Set up all the prerequisites.
|
| 4 |
+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
| 5 |
+
curl git wget \
|
| 6 |
+
g++ cmake pkg-config libeigen3-dev wget libyaml-cpp-dev castxml pypy3 \
|
| 7 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
+
|
| 9 |
+
RUN rm -rf /isaac-sim/exts/omni.isaac.ml_archive/pip_prebundle/gym*
|
| 10 |
+
RUN rm -rf /isaac-sim/exts/omni.isaac.ml_archive/pip_prebundle/torch*
|
| 11 |
+
RUN rm -rf /isaac-sim/exts/omni.isaac.ml_archive/pip_prebundle/functorch*
|
| 12 |
+
RUN rm -rf /isaac-sim/kit/extscore/omni.kit.pip_archive/pip_prebundle/numpy*
|
| 13 |
+
RUN /isaac-sim/python.sh -m pip install click~=8.1.3
|
| 14 |
+
|
| 15 |
+
# Mount the data directory
|
| 16 |
+
VOLUME ["/data"]
|
| 17 |
+
ENV OMNIGIBSON_DATA_PATH /data
|
| 18 |
+
|
| 19 |
+
# Install Mamba (light conda alternative)
|
| 20 |
+
RUN curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj -C / bin/micromamba
|
| 21 |
+
ENV MAMBA_ROOT_PREFIX /micromamba
|
| 22 |
+
RUN micromamba create -n omnigibson -c conda-forge python=3.10
|
| 23 |
+
RUN micromamba shell init --shell=bash
|
| 24 |
+
|
| 25 |
+
# Install torch
|
| 26 |
+
RUN micromamba run -n omnigibson micromamba install \
|
| 27 |
+
pytorch torchvision pytorch-cuda=11.8 \
|
| 28 |
+
-c pytorch -c nvidia -c conda-forge
|
| 29 |
+
|
| 30 |
+
# Install curobo. This can normally be installed when OmniGibson is pip
|
| 31 |
+
# installed, but we need to install it beforehand here so that it doesn't
|
| 32 |
+
# have to happen on every time a CI action is run (otherwise it's just
|
| 33 |
+
# very slow).
|
| 34 |
+
# This also allows us to uninstall the cuda toolkit after curobo is built
|
| 35 |
+
# to save space (meaning curobo will not be able to be rebuilt at runtime).
|
| 36 |
+
# Here we also compile this such that it is compatible with GPU architectures
|
| 37 |
+
# Turing, Ampere, and Ada; which correspond to 20, 30, and 40 series GPUs.
|
| 38 |
+
# We also suppress the output of the installation to avoid the log limit.
|
| 39 |
+
RUN wget --no-verbose -O /cuda-keyring.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
|
| 40 |
+
dpkg -i /cuda-keyring.deb && rm /cuda-keyring.deb && apt-get update && \
|
| 41 |
+
DEBIAN_FRONTEND=noninteractive apt-get install -y cuda-toolkit-11-8 && \
|
| 42 |
+
TORCH_CUDA_ARCH_LIST='7.5;8.0;8.6+PTX' PATH=/usr/local/cuda-11.8/bin:$PATH LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH \
|
| 43 |
+
micromamba run -n omnigibson pip install \
|
| 44 |
+
git+https://github.com/StanfordVL/curobo@cbaf7d32436160956dad190a9465360fad6aba73#egg=nvidia_curobo \
|
| 45 |
+
--no-build-isolation > /dev/null && \
|
| 46 |
+
apt-get remove -y cuda-toolkit-11-8 && apt-get autoremove -y && apt-get autoclean -y && rm -rf /var/lib/apt/lists/*
|
| 47 |
+
|
| 48 |
+
# Make sure isaac gets properly sourced every time omnigibson gets called
|
| 49 |
+
ARG CONDA_ACT_FILE="/micromamba/envs/omnigibson/etc/conda/activate.d/env_vars.sh"
|
| 50 |
+
RUN mkdir -p "/micromamba/envs/omnigibson/etc/conda/activate.d"
|
| 51 |
+
RUN touch $CONDA_ACT_FILE
|
| 52 |
+
|
| 53 |
+
RUN echo '#!/bin/sh' > $CONDA_ACT_FILE
|
| 54 |
+
RUN echo "source /isaac-sim/setup_conda_env.sh" >> $CONDA_ACT_FILE
|
| 55 |
+
|
| 56 |
+
RUN echo "micromamba activate omnigibson" >> /root/.bashrc
|
| 57 |
+
|
| 58 |
+
# Copy over omnigibson source
|
| 59 |
+
ADD . /omnigibson-src
|
| 60 |
+
WORKDIR /omnigibson-src
|
| 61 |
+
|
| 62 |
+
# Set the shell
|
| 63 |
+
SHELL ["micromamba", "run", "-n", "omnigibson", "/bin/bash", "--login", "-c"]
|
| 64 |
+
|
| 65 |
+
# Optionally install OmniGibson (e.g. unless the DEV_MODE flag is set) or
|
| 66 |
+
# remove the OmniGibson source code if we are in dev mode and change the workdir
|
| 67 |
+
ARG DEV_MODE
|
| 68 |
+
ENV DEV_MODE=${DEV_MODE}
|
| 69 |
+
ARG WORKDIR_PATH=/omnigibson-src
|
| 70 |
+
RUN if [ "$DEV_MODE" != "1" ]; then \
|
| 71 |
+
echo "OMNIGIBSON_NO_OMNIVERSE=1 python omnigibson/download_datasets.py" >> /root/.bashrc; \
|
| 72 |
+
micromamba run -n omnigibson pip install -e .[dev,primitives]; \
|
| 73 |
+
else \
|
| 74 |
+
WORKDIR_PATH=/; \
|
| 75 |
+
cd / && rm -rf /omnigibson-src; \
|
| 76 |
+
fi
|
| 77 |
+
|
| 78 |
+
# Reset the WORKDIR based on whether or not we are in dev mode
|
| 79 |
+
WORKDIR ${WORKDIR_PATH}
|
| 80 |
+
|
| 81 |
+
ENTRYPOINT ["micromamba", "run", "-n", "omnigibson"]
|
| 82 |
+
CMD ["/bin/bash"]
|
OmniGibson/docker/push_docker.sh
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -e -o pipefail
|
| 3 |
+
|
| 4 |
+
docker push stanfordvl/omnigibson:latest
|
| 5 |
+
docker push stanfordvl/omnigibson:$(sed -ne "s/.*version= *['\"]\([^'\"]*\)['\"] *.*/\1/p" setup.py)
|
| 6 |
+
docker push stanfordvl/omnigibson-dev:latest
|
OmniGibson/docker/run_docker.sh
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -e -o pipefail
|
| 3 |
+
|
| 4 |
+
BYellow='\033[1;33m'
|
| 5 |
+
Color_Off='\033[0m'
|
| 6 |
+
|
| 7 |
+
# Parse the command line arguments.
|
| 8 |
+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
| 9 |
+
DEFAULT_DATA_DIR="$SCRIPT_DIR/omnigibson_data"
|
| 10 |
+
DATA_PATH=$DEFAULT_DATA_DIR
|
| 11 |
+
GUI=true
|
| 12 |
+
|
| 13 |
+
# Parse command line arguments
|
| 14 |
+
while [[ $# -gt 0 ]]
|
| 15 |
+
do
|
| 16 |
+
key="$1"
|
| 17 |
+
|
| 18 |
+
case $key in
|
| 19 |
+
-h|--headless)
|
| 20 |
+
GUI=false
|
| 21 |
+
shift
|
| 22 |
+
;;
|
| 23 |
+
*)
|
| 24 |
+
DATA_PATH="$1"
|
| 25 |
+
shift
|
| 26 |
+
;;
|
| 27 |
+
esac
|
| 28 |
+
done
|
| 29 |
+
|
| 30 |
+
echo -e "${BYellow}IMPORTANT: Saving OmniGibson assets at ${DATA_PATH}."
|
| 31 |
+
echo -e "You can change this path by providing your desired path as an argument"
|
| 32 |
+
echo -e "to the run_docker script you are using. Also note that Docker containers"
|
| 33 |
+
echo -e "are incompatible with AFS/NFS drives, so please make sure that this path"
|
| 34 |
+
echo -e "points to a local filesystem. ${Color_Off}"
|
| 35 |
+
echo ""
|
| 36 |
+
|
| 37 |
+
echo "The NVIDIA Omniverse License Agreement (EULA) must be accepted before"
|
| 38 |
+
echo "Omniverse Kit can start. The license terms for this product can be viewed at"
|
| 39 |
+
echo "https://docs.omniverse.nvidia.com/app_isaacsim/common/NVIDIA_Omniverse_License_Agreement.html"
|
| 40 |
+
|
| 41 |
+
while true; do
|
| 42 |
+
read -p "Do you accept the Omniverse EULA? [y/n] " yn
|
| 43 |
+
case $yn in
|
| 44 |
+
[Yy]* ) break;;
|
| 45 |
+
[Nn]* ) exit;;
|
| 46 |
+
* ) echo "Please answer yes or no.";;
|
| 47 |
+
esac
|
| 48 |
+
done
|
| 49 |
+
|
| 50 |
+
docker pull stanfordvl/omnigibson:latest
|
| 51 |
+
DOCKER_DISPLAY=""
|
| 52 |
+
OMNIGIBSON_HEADLESS=1
|
| 53 |
+
if [ "$GUI" = true ] ; then
|
| 54 |
+
xhost +local:root
|
| 55 |
+
DOCKER_DISPLAY=$DISPLAY
|
| 56 |
+
OMNIGIBSON_HEADLESS=0
|
| 57 |
+
fi
|
| 58 |
+
docker run \
|
| 59 |
+
--gpus all \
|
| 60 |
+
--privileged \
|
| 61 |
+
-e DISPLAY=${DOCKER_DISPLAY} \
|
| 62 |
+
-e OMNIGIBSON_HEADLESS=${OMNIGIBSON_HEADLESS} \
|
| 63 |
+
-v $DATA_PATH/datasets:/data \
|
| 64 |
+
-v $DATA_PATH/isaac-sim/cache/kit:/isaac-sim/kit/cache/Kit:rw \
|
| 65 |
+
-v $DATA_PATH/isaac-sim/cache/ov:/root/.cache/ov:rw \
|
| 66 |
+
-v $DATA_PATH/isaac-sim/cache/pip:/root/.cache/pip:rw \
|
| 67 |
+
-v $DATA_PATH/isaac-sim/cache/glcache:/root/.cache/nvidia/GLCache:rw \
|
| 68 |
+
-v $DATA_PATH/isaac-sim/cache/computecache:/root/.nv/ComputeCache:rw \
|
| 69 |
+
-v $DATA_PATH/isaac-sim/logs:/root/.nvidia-omniverse/logs:rw \
|
| 70 |
+
-v $DATA_PATH/isaac-sim/config:/root/.nvidia-omniverse/config:rw \
|
| 71 |
+
-v $DATA_PATH/isaac-sim/data:/root/.local/share/ov/data:rw \
|
| 72 |
+
-v $DATA_PATH/isaac-sim/documents:/root/Documents:rw \
|
| 73 |
+
--network=host --rm -it stanfordvl/omnigibson:latest
|
| 74 |
+
if [ "$GUI" = true ] ; then
|
| 75 |
+
xhost -local:root
|
| 76 |
+
fi
|
OmniGibson/docker/safe_launch_vscode.sh
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -e -o pipefail
|
| 3 |
+
|
| 4 |
+
# Get the user's currently running vscode job count
|
| 5 |
+
USERNAME=$(whoami)
|
| 6 |
+
CURRENTLY_RUNNING_JOBS=$(squeue -u $USERNAME -o "%j:%i" | grep omnigibson-vscode || true)
|
| 7 |
+
|
| 8 |
+
if [ -z "$CURRENTLY_RUNNING_JOBS" ]; then
|
| 9 |
+
# Queue a new job for the user
|
| 10 |
+
echo "Starting new job"
|
| 11 |
+
sbatch /cvgl/group/Gibson/og-docker/launch_vscode.sh
|
| 12 |
+
|
| 13 |
+
# Wait for the file to show up
|
| 14 |
+
while ! (squeue -u $USERNAME -o "%j:%i" | grep -q omnigibson-vscode); do
|
| 15 |
+
echo "Waiting for the job to launch."
|
| 16 |
+
sleep 3
|
| 17 |
+
done
|
| 18 |
+
fi
|
| 19 |
+
|
| 20 |
+
# Get the job id
|
| 21 |
+
LAUNCHED_JOB_ID=$(squeue -u $USERNAME -o "%j:%i" | grep -m 1 omnigibson-vscode | sed "s/.*://g" | tr -d '\n')
|
| 22 |
+
echo "Job ID: $LAUNCHED_JOB_ID"
|
| 23 |
+
|
| 24 |
+
# Check that the output file exists
|
| 25 |
+
OUTPUT_FILE="slurm-${LAUNCHED_JOB_ID}.out"
|
| 26 |
+
while [ ! -f "$OUTPUT_FILE" ]; do
|
| 27 |
+
echo "Waiting for the job to start outputting."
|
| 28 |
+
sleep 3
|
| 29 |
+
done
|
| 30 |
+
|
| 31 |
+
# Wait for the output file to contain the string OMNIGIBSON-VSCODE exactly 3 times
|
| 32 |
+
while [ "$(grep -c "OMNIGIBSON-VSCODE" "$OUTPUT_FILE" || true)" -lt 3 ]; do
|
| 33 |
+
echo "Waiting for the job to allocate ports."
|
| 34 |
+
sleep 3
|
| 35 |
+
done
|
| 36 |
+
# echo "Ports allocated successfully."
|
| 37 |
+
|
| 38 |
+
# Wait for the output file to contain the string "HTTP server listening"
|
| 39 |
+
# while ! grep -q "HTTP server listening" "$OUTPUT_FILE"; do
|
| 40 |
+
# echo "Waiting for the job to start the HTTP server."
|
| 41 |
+
# sleep 3
|
| 42 |
+
# done
|
| 43 |
+
# echo "HTTP server started successfully."
|
| 44 |
+
# echo ""
|
| 45 |
+
|
| 46 |
+
# Echo the OMNIGIBSON-VSCODE lines
|
| 47 |
+
grep "OMNIGIBSON-VSCODE" "$OUTPUT_FILE"
|
OmniGibson/docker/sbatch_example.sh
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
#SBATCH --account=cvgl
|
| 3 |
+
#SBATCH --partition=svl --qos=normal
|
| 4 |
+
#SBATCH --nodes=1
|
| 5 |
+
#SBATCH --cpus-per-task=8
|
| 6 |
+
#SBATCH --mem=30G
|
| 7 |
+
#SBATCH --gres=gpu:2080ti:1
|
| 8 |
+
|
| 9 |
+
set -e -o pipefail
|
| 10 |
+
|
| 11 |
+
IMAGE_PATH="/cvgl2/u/cgokmen/omnigibson.sqsh"
|
| 12 |
+
GPU_ID=$(nvidia-smi -L | grep -oP '(?<=GPU-)[a-fA-F0-9\-]+' | head -n 1)
|
| 13 |
+
ISAAC_CACHE_PATH="/scr-ssd/${SLURM_JOB_USER}/isaac_cache_${GPU_ID}"
|
| 14 |
+
|
| 15 |
+
# Define env kwargs to pass
|
| 16 |
+
declare -A ENVS=(
|
| 17 |
+
[NVIDIA_DRIVER_CAPABILITIES]=all
|
| 18 |
+
[NVIDIA_VISIBLE_DEVICES]=0
|
| 19 |
+
[DISPLAY]=""
|
| 20 |
+
[OMNIGIBSON_HEADLESS]=1
|
| 21 |
+
)
|
| 22 |
+
for env_var in "${!ENVS[@]}"; do
|
| 23 |
+
# Add to env kwargs we'll pass to enroot command later
|
| 24 |
+
ENV_KWARGS="${ENV_KWARGS} --env ${env_var}=${ENVS[${env_var}]}"
|
| 25 |
+
done
|
| 26 |
+
|
| 27 |
+
# Define mounts to create (maps local directory to container directory)
|
| 28 |
+
declare -A MOUNTS=(
|
| 29 |
+
[/scr-ssd/og-data-0-2-1]=/data
|
| 30 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/kit/cache/Kit]=/isaac-sim/kit/cache/Kit
|
| 31 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/cache/ov]=/root/.cache/ov
|
| 32 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/cache/pip]=/root/.cache/pip
|
| 33 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/cache/glcache]=/root/.cache/nvidia/GLCache
|
| 34 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/cache/computecache]=/root/.nv/ComputeCache
|
| 35 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/logs]=/root/.nvidia-omniverse/logs
|
| 36 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/config]=/root/.nvidia-omniverse/config
|
| 37 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/data]=/root/.local/share/ov/data
|
| 38 |
+
[${ISAAC_CACHE_PATH}/isaac-sim/documents]=/root/Documents
|
| 39 |
+
# Feel free to include lines like the below to mount a workspace or a custom OG version
|
| 40 |
+
# [/cvgl2/u/cgokmen/OmniGibson]=/omnigibson-src
|
| 41 |
+
# [/cvgl2/u/cgokmen/my-project]=/my-project
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
MOUNT_KWARGS=""
|
| 45 |
+
for mount in "${!MOUNTS[@]}"; do
|
| 46 |
+
# Verify mount path in local directory exists, otherwise, create it
|
| 47 |
+
if [ ! -e "$mount" ]; then
|
| 48 |
+
mkdir -p ${mount}
|
| 49 |
+
fi
|
| 50 |
+
# Add to mount kwargs we'll pass to enroot command later
|
| 51 |
+
MOUNT_KWARGS="${MOUNT_KWARGS} --mount ${mount}:${MOUNTS[${mount}]}"
|
| 52 |
+
done
|
| 53 |
+
|
| 54 |
+
# Create the image if it doesn't already exist
|
| 55 |
+
CONTAINER_NAME=omnigibson_${GPU_ID}
|
| 56 |
+
enroot create --force --name ${CONTAINER_NAME} ${IMAGE_PATH}
|
| 57 |
+
|
| 58 |
+
# Remove leading space in string
|
| 59 |
+
ENV_KWARGS="${ENV_KWARGS:1}"
|
| 60 |
+
MOUNT_KWARGS="${MOUNT_KWARGS:1}"
|
| 61 |
+
|
| 62 |
+
# The last line here is the command you want to run inside the container.
|
| 63 |
+
# Here I'm running some unit tests.
|
| 64 |
+
ENROOT_MOUNT_HOME=no enroot start \
|
| 65 |
+
--root \
|
| 66 |
+
--rw \
|
| 67 |
+
${ENV_KWARGS} \
|
| 68 |
+
${MOUNT_KWARGS} \
|
| 69 |
+
${CONTAINER_NAME} \
|
| 70 |
+
micromamba run -n omnigibson /bin/bash --login -c "source /isaac-sim/setup_conda_env.sh && pytest tests/test_object_states.py"
|
| 71 |
+
|
| 72 |
+
# Clean up the image if possible.
|
| 73 |
+
enroot remove -f ${CONTAINER_NAME}
|
OmniGibson/docker/submission.Dockerfile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM continuumio/miniconda3
|
| 2 |
+
|
| 3 |
+
# Set working directory
|
| 4 |
+
WORKDIR /workspace
|
| 5 |
+
|
| 6 |
+
# Install system dependencies including build tools
|
| 7 |
+
RUN apt-get update && apt-get install -y \
|
| 8 |
+
build-essential \
|
| 9 |
+
gcc \
|
| 10 |
+
g++ \
|
| 11 |
+
make \
|
| 12 |
+
libgl1-mesa-glx \
|
| 13 |
+
libglib2.0-0 \
|
| 14 |
+
libsm6 \
|
| 15 |
+
libxext6 \
|
| 16 |
+
libxrender-dev \
|
| 17 |
+
libgomp1 \
|
| 18 |
+
libgcc-s1 \
|
| 19 |
+
libudev-dev \
|
| 20 |
+
libinput-dev \
|
| 21 |
+
linux-libc-dev \
|
| 22 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 23 |
+
|
| 24 |
+
# Create and activate a new conda environment
|
| 25 |
+
RUN conda create -n behavior python=3.10 -y -c conda-forge
|
| 26 |
+
SHELL ["conda", "run", "-n", "behavior", "/bin/bash", "-c"]
|
| 27 |
+
|
| 28 |
+
# Install additional packages
|
| 29 |
+
RUN pip install "numpy<2" "setuptools<=79"
|
| 30 |
+
RUN pip install torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu124
|
| 31 |
+
|
| 32 |
+
# Copy over omnigibson source
|
| 33 |
+
ADD . /b1k-src
|
| 34 |
+
WORKDIR /b1k-src
|
| 35 |
+
|
| 36 |
+
# Install bddl (editable)
|
| 37 |
+
RUN pip install -e bddl
|
| 38 |
+
# Install omnigibson (editable)
|
| 39 |
+
RUN pip install -e OmniGibson[eval]
|
| 40 |
+
|
| 41 |
+
ENV PATH=/opt/conda/envs/behavior/bin:$PATH
|
| 42 |
+
ENV CONDA_DEFAULT_ENV=behavior
|
| 43 |
+
|
| 44 |
+
CMD ["python", "-u", "-c", "from omnigibson.learning.utils.network_utils import WebsocketPolicyServer; from omnigibson.learning.policies import LocalPolicy; server = WebsocketPolicyServer(LocalPolicy(action_dim=23)); server.serve_forever()"]
|
OmniGibson/docker/vscode.Dockerfile
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM stanfordvl/omnigibson:latest
|
| 2 |
+
|
| 3 |
+
# environment settings
|
| 4 |
+
ARG DEBIAN_FRONTEND="noninteractive"
|
| 5 |
+
ENV OMNIGIBSON_REMOTE_STREAMING="webrtc"
|
| 6 |
+
|
| 7 |
+
RUN \
|
| 8 |
+
echo "**** install runtime dependencies ****" && \
|
| 9 |
+
apt-get update && \
|
| 10 |
+
apt-get install -y \
|
| 11 |
+
git \
|
| 12 |
+
jq \
|
| 13 |
+
libatomic1 \
|
| 14 |
+
nano \
|
| 15 |
+
net-tools \
|
| 16 |
+
netcat \
|
| 17 |
+
sudo && \
|
| 18 |
+
echo "**** install code-server ****" && \
|
| 19 |
+
if [ -z ${CODE_RELEASE+x} ]; then \
|
| 20 |
+
CODE_RELEASE=$(curl -sX GET https://api.github.com/repos/coder/code-server/releases/latest \
|
| 21 |
+
| awk '/tag_name/{print $4;exit}' FS='[""]' | sed 's|^v||'); \
|
| 22 |
+
fi && \
|
| 23 |
+
mkdir -p /app/code-server && \
|
| 24 |
+
curl -o \
|
| 25 |
+
/tmp/code-server.tar.gz -L \
|
| 26 |
+
"https://github.com/coder/code-server/releases/download/v${CODE_RELEASE}/code-server-${CODE_RELEASE}-linux-amd64.tar.gz" && \
|
| 27 |
+
tar xf /tmp/code-server.tar.gz -C \
|
| 28 |
+
/app/code-server --strip-components=1 && \
|
| 29 |
+
echo "**** clean up ****" && \
|
| 30 |
+
apt-get clean && \
|
| 31 |
+
rm -rf \
|
| 32 |
+
/config/* \
|
| 33 |
+
/tmp/* \
|
| 34 |
+
/var/lib/apt/lists/* \
|
| 35 |
+
/var/tmp/*
|
| 36 |
+
|
| 37 |
+
# Remove the omnigibson source code
|
| 38 |
+
RUN rm -rf /omnigibson-src
|
| 39 |
+
|
| 40 |
+
# run command
|
| 41 |
+
CMD sed -i "s/49100/${OMNIGIBSON_WEBRTC_PORT}/g" /isaac-sim/extscache/omni.services.streamclient.webrtc-1.3.8/web/js/kit-player.js && \
|
| 42 |
+
/app/code-server/bin/code-server \
|
| 43 |
+
--bind-addr 0.0.0.0:${OMNIGIBSON_VSCODE_PORT} \
|
| 44 |
+
--user-data-dir /vscode-config/data \
|
| 45 |
+
--extensions-dir /vscode-config/extensions \
|
| 46 |
+
--disable-telemetry \
|
| 47 |
+
--auth password \
|
| 48 |
+
/omnigibson-src
|
OmniGibson/omnigibson.egg-info/PKG-INFO
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: omnigibson
|
| 3 |
+
Version: 3.7.1
|
| 4 |
+
Home-page: https://github.com/StanfordVL/BEHAVIOR-1K
|
| 5 |
+
Author: Stanford University
|
| 6 |
+
Requires-Python: >=3
|
| 7 |
+
Description-Content-Type: text/markdown
|
| 8 |
+
License-File: LICENSE
|
| 9 |
+
Requires-Dist: huggingface-hub[cli]>=0.34.4
|
| 10 |
+
Requires-Dist: gymnasium>=0.28.1
|
| 11 |
+
Requires-Dist: numpy<2.0.0,>=1.23.5
|
| 12 |
+
Requires-Dist: scipy>=1.10.1
|
| 13 |
+
Requires-Dist: GitPython>=3.1.40
|
| 14 |
+
Requires-Dist: transforms3d>=0.4.1
|
| 15 |
+
Requires-Dist: networkx>=3.2.1
|
| 16 |
+
Requires-Dist: PyYAML>=6.0.1
|
| 17 |
+
Requires-Dist: addict>=2.4.0
|
| 18 |
+
Requires-Dist: ipython>=8.20.0
|
| 19 |
+
Requires-Dist: future>=0.18.3
|
| 20 |
+
Requires-Dist: trimesh>=4.0.8
|
| 21 |
+
Requires-Dist: h5py>=3.10.0
|
| 22 |
+
Requires-Dist: cryptography>=41.0.7
|
| 23 |
+
Requires-Dist: bddl~=3.7.0
|
| 24 |
+
Requires-Dist: opencv-python>=4.8.1
|
| 25 |
+
Requires-Dist: nest_asyncio>=1.5.6
|
| 26 |
+
Requires-Dist: imageio>=2.33.1
|
| 27 |
+
Requires-Dist: imageio-ffmpeg>=0.4.9
|
| 28 |
+
Requires-Dist: termcolor>=2.4.0
|
| 29 |
+
Requires-Dist: progressbar>=2.5
|
| 30 |
+
Requires-Dist: pymeshlab~=2022.2
|
| 31 |
+
Requires-Dist: click>=8.1.3
|
| 32 |
+
Requires-Dist: aenum>=3.1.15
|
| 33 |
+
Requires-Dist: rtree>=1.2.0
|
| 34 |
+
Requires-Dist: graphviz>=0.20
|
| 35 |
+
Requires-Dist: matplotlib>=3.0.0
|
| 36 |
+
Requires-Dist: lxml>=5.2.2
|
| 37 |
+
Requires-Dist: numba>=0.59.1
|
| 38 |
+
Requires-Dist: cffi~=1.17.1
|
| 39 |
+
Requires-Dist: pillow~=11.0.0
|
| 40 |
+
Provides-Extra: dev
|
| 41 |
+
Requires-Dist: pytest>=6.2.3; extra == "dev"
|
| 42 |
+
Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
|
| 43 |
+
Requires-Dist: pytest_rerunfailures; extra == "dev"
|
| 44 |
+
Requires-Dist: mkdocs; extra == "dev"
|
| 45 |
+
Requires-Dist: mkdocs-autorefs; extra == "dev"
|
| 46 |
+
Requires-Dist: mkdocs-gen-files; extra == "dev"
|
| 47 |
+
Requires-Dist: mkdocs-material; extra == "dev"
|
| 48 |
+
Requires-Dist: mkdocs-material-extensions; extra == "dev"
|
| 49 |
+
Requires-Dist: mkdocstrings[python]; extra == "dev"
|
| 50 |
+
Requires-Dist: mkdocs-section-index; extra == "dev"
|
| 51 |
+
Requires-Dist: mkdocs-literate-nav; extra == "dev"
|
| 52 |
+
Requires-Dist: mkdocs-redirects; extra == "dev"
|
| 53 |
+
Requires-Dist: mkdocs-include-markdown-plugin; extra == "dev"
|
| 54 |
+
Requires-Dist: telemoma~=0.3.0; extra == "dev"
|
| 55 |
+
Requires-Dist: gspread>=6.2.1; extra == "dev"
|
| 56 |
+
Provides-Extra: primitives
|
| 57 |
+
Requires-Dist: ninja~=1.13.0; extra == "primitives"
|
| 58 |
+
Requires-Dist: nvidia-curobo@ git+https://github.com/StanfordVL/curobo@cbaf7d32436160956dad190a9465360fad6aba73 ; extra == "primitives"
|
| 59 |
+
Requires-Dist: ompl@ https://storage.googleapis.com/gibson_scenes/ompl-1.6.0-cp310-cp310-manylinux_2_28_x86_64.whl ; extra == "primitives"
|
| 60 |
+
Provides-Extra: eval
|
| 61 |
+
Requires-Dist: dm_tree>=0.1.9; extra == "eval"
|
| 62 |
+
Requires-Dist: hydra-core>=1.3.2; extra == "eval"
|
| 63 |
+
Requires-Dist: websockets>=15.0.1; extra == "eval"
|
| 64 |
+
Requires-Dist: msgpack>=1.1.0; extra == "eval"
|
| 65 |
+
Requires-Dist: lerobot@ git+https://github.com/huggingface/lerobot@577cd10974b84bea1f06b6472eb9e5e74e07f77a ; extra == "eval"
|
| 66 |
+
Requires-Dist: gspread>=6.2.1; extra == "eval"
|
| 67 |
+
Requires-Dist: open3d>=0.19.0; extra == "eval"
|
| 68 |
+
Dynamic: author
|
| 69 |
+
Dynamic: description
|
| 70 |
+
Dynamic: description-content-type
|
| 71 |
+
Dynamic: home-page
|
| 72 |
+
Dynamic: license-file
|
| 73 |
+
Dynamic: provides-extra
|
| 74 |
+
Dynamic: requires-dist
|
| 75 |
+
Dynamic: requires-python
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
[](https://github.com/StanfordVL/OmniGibson/actions/workflows/tests.yml)
|
| 79 |
+
[](https://hub.docker.com/r/stanfordvl/omnigibson)
|
| 80 |
+
[](https://stanfordvl.github.io/OmniGibson/profiling/)
|
| 81 |
+
|
| 82 |
+
-------
|
| 83 |
+
|
| 84 |
+
### Need support? Join our Discord!
|
| 85 |
+
|
| 86 |
+
-------
|
| 87 |
+
|
| 88 |
+
### Latest Updates
|
| 89 |
+
- [10/01/24] **v1.1.0**: Major improvements, stability fixes, pip installation, and much more! [[release notes]](https://github.com/StanfordVL/OmniGibson/releases/tag/v1.1.0)
|
| 90 |
+
|
| 91 |
+
- [03/17/24] **v1.0.0**: First full release with 1,004 pre-sampled tasks, all 50 scenes, and many new objects! [[release notes]](https://github.com/StanfordVL/OmniGibson/releases/tag/v1.0.0)
|
| 92 |
+
|
| 93 |
+
- [08/04/23] **v0.2.0**: More assets! 600 pre-sampled tasks, 7 new scenes, and many new objects 📈 [[release notes]](https://github.com/StanfordVL/OmniGibson/releases/tag/v0.2.0)
|
| 94 |
+
|
| 95 |
+
- [04/10/23] **v0.1.0**: Significantly improved stability, performance, and ease of installation :wrench: [[release notes]](https://github.com/StanfordVL/OmniGibson/releases/tag/v0.1.0)
|
| 96 |
+
|
| 97 |
+
-------
|
| 98 |
+
|
| 99 |
+
**`OmniGibson`** is a platform for accelerating Embodied AI research built upon NVIDIA's [Omniverse](https://www.nvidia.com/en-us/omniverse/) platform, featuring:
|
| 100 |
+
|
| 101 |
+
* 📸 Photorealistic Visuals and 📐 Physical Realism
|
| 102 |
+
* 🌊 Fluid and 👕 Soft Body Support
|
| 103 |
+
* 🏔️ Large-Scale, High-Quality Scenes and 🎾 Objects
|
| 104 |
+
* 🌡️ Dynamic Kinematic and Semantic Object States
|
| 105 |
+
* 🤖 Mobile Manipulator Robots with Modular ⚙️ Controllers
|
| 106 |
+
* 🌎 OpenAI Gym Interface
|
| 107 |
+
|
| 108 |
+
Check out [**`OmniGibson`**'s documentation](https://behavior.stanford.edu/omnigibson/getting_started/installation.html) to get started!
|
| 109 |
+
|
| 110 |
+
### Citation
|
| 111 |
+
If you use **`OmniGibson`** or its assets and models, please cite:
|
| 112 |
+
|
| 113 |
+
```
|
| 114 |
+
@inproceedings{
|
| 115 |
+
li2022behavior,
|
| 116 |
+
title={{BEHAVIOR}-1K: A Benchmark for Embodied {AI} with 1,000 Everyday Activities and Realistic Simulation},
|
| 117 |
+
author={Chengshu Li and Ruohan Zhang and Josiah Wong and Cem Gokmen and Sanjana Srivastava and Roberto Mart{\'\i}n-Mart{\'\i}n and Chen Wang and Gabrael Levine and Michael Lingelbach and Jiankai Sun and Mona Anvari and Minjune Hwang and Manasi Sharma and Arman Aydin and Dhruva Bansal and Samuel Hunter and Kyu-Young Kim and Alan Lou and Caleb R Matthews and Ivan Villa-Renteria and Jerry Huayang Tang and Claire Tang and Fei Xia and Silvio Savarese and Hyowon Gweon and Karen Liu and Jiajun Wu and Li Fei-Fei},
|
| 118 |
+
booktitle={6th Annual Conference on Robot Learning},
|
| 119 |
+
year={2022},
|
| 120 |
+
url={https://openreview.net/forum?id=_8DoIe8G3t}
|
| 121 |
+
}
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
### Profiling
|
| 125 |
+
Click on the plot to access our profiling page with more examples.
|
| 126 |
+
|
OmniGibson/omnigibson.egg-info/SOURCES.txt
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
LICENSE
|
| 2 |
+
MANIFEST.in
|
| 3 |
+
README.md
|
| 4 |
+
pyproject.toml
|
| 5 |
+
setup.py
|
| 6 |
+
omnigibson/.gitignore
|
| 7 |
+
omnigibson/__init__.py
|
| 8 |
+
omnigibson/kit_file_changes.patch
|
| 9 |
+
omnigibson/lazy.py
|
| 10 |
+
omnigibson/macros.py
|
| 11 |
+
omnigibson/omnigibson_4_5_0.kit
|
| 12 |
+
omnigibson/simulator.py
|
| 13 |
+
omnigibson/transition_rules.py
|
| 14 |
+
omnigibson.egg-info/PKG-INFO
|
| 15 |
+
omnigibson.egg-info/SOURCES.txt
|
| 16 |
+
omnigibson.egg-info/dependency_links.txt
|
| 17 |
+
omnigibson.egg-info/not-zip-safe
|
| 18 |
+
omnigibson.egg-info/requires.txt
|
| 19 |
+
omnigibson.egg-info/top_level.txt
|
| 20 |
+
omnigibson/action_primitives/action_primitive_set_base.py
|
| 21 |
+
omnigibson/action_primitives/curobo.py
|
| 22 |
+
omnigibson/action_primitives/starter_semantic_action_primitives.py
|
| 23 |
+
omnigibson/action_primitives/symbolic_semantic_action_primitives.py
|
| 24 |
+
omnigibson/configs/avg_category_specs.json
|
| 25 |
+
omnigibson/configs/default_cfg.yaml
|
| 26 |
+
omnigibson/configs/franka_vector_env.yaml
|
| 27 |
+
omnigibson/configs/r1_primitives.yaml
|
| 28 |
+
omnigibson/configs/r1pro_behavior.yaml
|
| 29 |
+
omnigibson/configs/tiago_primitives.yaml
|
| 30 |
+
omnigibson/configs/turtlebot_nav.yaml
|
| 31 |
+
omnigibson/configs/controllers/dd.yaml
|
| 32 |
+
omnigibson/configs/controllers/ik.yaml
|
| 33 |
+
omnigibson/configs/controllers/joint.yaml
|
| 34 |
+
omnigibson/configs/controllers/multi_finger_gripper.yaml
|
| 35 |
+
omnigibson/configs/controllers/null_gripper.yaml
|
| 36 |
+
omnigibson/configs/robots/fetch.yaml
|
| 37 |
+
omnigibson/configs/robots/freight.yaml
|
| 38 |
+
omnigibson/configs/robots/husky.yaml
|
| 39 |
+
omnigibson/configs/robots/locobot.yaml
|
| 40 |
+
omnigibson/configs/robots/turtlebot.yaml
|
| 41 |
+
omnigibson/configs/sensors/scan.yaml
|
| 42 |
+
omnigibson/configs/sensors/vision.yaml
|
| 43 |
+
omnigibson/controllers/__init__.py
|
| 44 |
+
omnigibson/controllers/controller_base.py
|
| 45 |
+
omnigibson/controllers/dd_controller.py
|
| 46 |
+
omnigibson/controllers/holonomic_base_joint_controller.py
|
| 47 |
+
omnigibson/controllers/ik_controller.py
|
| 48 |
+
omnigibson/controllers/joint_controller.py
|
| 49 |
+
omnigibson/controllers/multi_finger_gripper_controller.py
|
| 50 |
+
omnigibson/controllers/null_joint_controller.py
|
| 51 |
+
omnigibson/controllers/osc_controller.py
|
| 52 |
+
omnigibson/envs/__init__.py
|
| 53 |
+
omnigibson/envs/data_wrapper.py
|
| 54 |
+
omnigibson/envs/env_base.py
|
| 55 |
+
omnigibson/envs/env_wrapper.py
|
| 56 |
+
omnigibson/envs/metrics_wrapper.py
|
| 57 |
+
omnigibson/envs/sb3_vec_env.py
|
| 58 |
+
omnigibson/envs/vec_env_base.py
|
| 59 |
+
omnigibson/examples/__init__.py
|
| 60 |
+
omnigibson/examples/action_primitives/__init__.py
|
| 61 |
+
omnigibson/examples/action_primitives/rs_int_example.py
|
| 62 |
+
omnigibson/examples/action_primitives/solve_simple_task.py
|
| 63 |
+
omnigibson/examples/action_primitives/wip_solve_behavior_task.py
|
| 64 |
+
omnigibson/examples/environments/__init__.py
|
| 65 |
+
omnigibson/examples/environments/behavior_env_demo.py
|
| 66 |
+
omnigibson/examples/environments/navigation_env_demo.py
|
| 67 |
+
omnigibson/examples/environments/vector_env_demo.py
|
| 68 |
+
omnigibson/examples/learning/__init__.py
|
| 69 |
+
omnigibson/examples/learning/navigation_policy_demo.py
|
| 70 |
+
omnigibson/examples/object_states/__init__.py
|
| 71 |
+
omnigibson/examples/object_states/attachment_demo.py
|
| 72 |
+
omnigibson/examples/object_states/dicing_demo.py
|
| 73 |
+
omnigibson/examples/object_states/folded_unfolded_state_demo.py
|
| 74 |
+
omnigibson/examples/object_states/heat_source_or_sink_demo.py
|
| 75 |
+
omnigibson/examples/object_states/heated_state_demo.py
|
| 76 |
+
omnigibson/examples/object_states/object_state_texture_demo.py
|
| 77 |
+
omnigibson/examples/object_states/onfire_demo.py
|
| 78 |
+
omnigibson/examples/object_states/overlaid_demo.py
|
| 79 |
+
omnigibson/examples/object_states/particle_applier_remover_demo.py
|
| 80 |
+
omnigibson/examples/object_states/particle_source_sink_demo.py
|
| 81 |
+
omnigibson/examples/object_states/sample_kinematics_demo.py
|
| 82 |
+
omnigibson/examples/object_states/slicing_demo.py
|
| 83 |
+
omnigibson/examples/object_states/temperature_demo.py
|
| 84 |
+
omnigibson/examples/objects/__init__.py
|
| 85 |
+
omnigibson/examples/objects/draw_bounding_box.py
|
| 86 |
+
omnigibson/examples/objects/highlight_objects.py
|
| 87 |
+
omnigibson/examples/objects/import_custom_object.py
|
| 88 |
+
omnigibson/examples/objects/load_object_selector.py
|
| 89 |
+
omnigibson/examples/objects/view_cloth_configurations.py
|
| 90 |
+
omnigibson/examples/objects/visualize_object.py
|
| 91 |
+
omnigibson/examples/robots/__init__.py
|
| 92 |
+
omnigibson/examples/robots/all_robots_visualizer.py
|
| 93 |
+
omnigibson/examples/robots/curobo_example.py
|
| 94 |
+
omnigibson/examples/robots/grasping_mode_example.py
|
| 95 |
+
omnigibson/examples/robots/import_custom_robot.py
|
| 96 |
+
omnigibson/examples/robots/robot_control_example.py
|
| 97 |
+
omnigibson/examples/scenes/__init__.py
|
| 98 |
+
omnigibson/examples/scenes/scene_selector.py
|
| 99 |
+
omnigibson/examples/scenes/scene_tour_demo.py
|
| 100 |
+
omnigibson/examples/scenes/traversability_map_example.py
|
| 101 |
+
omnigibson/examples/simulator/__init__.py
|
| 102 |
+
omnigibson/examples/simulator/sim_save_load_example.py
|
| 103 |
+
omnigibson/examples/teleoperation/__init__.py
|
| 104 |
+
omnigibson/examples/teleoperation/robot_teleoperate_demo.py
|
| 105 |
+
omnigibson/examples/teleoperation/vr_robot_control_demo.py
|
| 106 |
+
omnigibson/examples/teleoperation/vr_scene_tour_demo.py
|
| 107 |
+
omnigibson/learning/__init__.py
|
| 108 |
+
omnigibson/learning/eval.py
|
| 109 |
+
omnigibson/learning/policies.py
|
| 110 |
+
omnigibson/learning/configs/base_config.yaml
|
| 111 |
+
omnigibson/learning/configs/policy/local.yaml
|
| 112 |
+
omnigibson/learning/configs/policy/websocket.yaml
|
| 113 |
+
omnigibson/learning/configs/robot/a1.yaml
|
| 114 |
+
omnigibson/learning/configs/robot/r1pro.yaml
|
| 115 |
+
omnigibson/learning/configs/task/behavior.yaml
|
| 116 |
+
omnigibson/learning/datas/__init__.py
|
| 117 |
+
omnigibson/learning/datas/iterable_dataset.py
|
| 118 |
+
omnigibson/learning/datas/lerobot_dataset.py
|
| 119 |
+
omnigibson/learning/utils/__init__.py
|
| 120 |
+
omnigibson/learning/utils/array_tensor_utils.py
|
| 121 |
+
omnigibson/learning/utils/config_utils.py
|
| 122 |
+
omnigibson/learning/utils/dataset_utils.py
|
| 123 |
+
omnigibson/learning/utils/eval_utils.py
|
| 124 |
+
omnigibson/learning/utils/lerobot_utils.py
|
| 125 |
+
omnigibson/learning/utils/network_utils.py
|
| 126 |
+
omnigibson/learning/utils/obs_utils.py
|
| 127 |
+
omnigibson/learning/utils/score_utils.py
|
| 128 |
+
omnigibson/learning/wrappers/__init__.py
|
| 129 |
+
omnigibson/learning/wrappers/default_wrapper.py
|
| 130 |
+
omnigibson/learning/wrappers/heavy_robot_wrapper.py
|
| 131 |
+
omnigibson/learning/wrappers/rgb_low_res_wrapper.py
|
| 132 |
+
omnigibson/learning/wrappers/rich_obs_wrapper.py
|
| 133 |
+
omnigibson/maps/__init__.py
|
| 134 |
+
omnigibson/maps/map_base.py
|
| 135 |
+
omnigibson/maps/segmentation_map.py
|
| 136 |
+
omnigibson/maps/traversable_map.py
|
| 137 |
+
omnigibson/materials/omnigibson_vray_mtl.mdl
|
| 138 |
+
omnigibson/materials/vray_maps.mdl
|
| 139 |
+
omnigibson/materials/vray_materials.mdl
|
| 140 |
+
omnigibson/metrics/__init__.py
|
| 141 |
+
omnigibson/metrics/agent_metric.py
|
| 142 |
+
omnigibson/metrics/metric_base.py
|
| 143 |
+
omnigibson/metrics/task_metric.py
|
| 144 |
+
omnigibson/object_states/__init__.py
|
| 145 |
+
omnigibson/object_states/aabb.py
|
| 146 |
+
omnigibson/object_states/adjacency.py
|
| 147 |
+
omnigibson/object_states/attached_to.py
|
| 148 |
+
omnigibson/object_states/burnt.py
|
| 149 |
+
omnigibson/object_states/cloth_mixin.py
|
| 150 |
+
omnigibson/object_states/contact_bodies.py
|
| 151 |
+
omnigibson/object_states/contact_particles.py
|
| 152 |
+
omnigibson/object_states/contact_subscribed_state_mixin.py
|
| 153 |
+
omnigibson/object_states/contains.py
|
| 154 |
+
omnigibson/object_states/cooked.py
|
| 155 |
+
omnigibson/object_states/covered.py
|
| 156 |
+
omnigibson/object_states/draped.py
|
| 157 |
+
omnigibson/object_states/factory.py
|
| 158 |
+
omnigibson/object_states/filled.py
|
| 159 |
+
omnigibson/object_states/folded.py
|
| 160 |
+
omnigibson/object_states/frozen.py
|
| 161 |
+
omnigibson/object_states/heat_source_or_sink.py
|
| 162 |
+
omnigibson/object_states/heated.py
|
| 163 |
+
omnigibson/object_states/inside.py
|
| 164 |
+
omnigibson/object_states/joint_break_subscribed_state_mixin.py
|
| 165 |
+
omnigibson/object_states/joint_state.py
|
| 166 |
+
omnigibson/object_states/kinematics_mixin.py
|
| 167 |
+
omnigibson/object_states/link_based_state_mixin.py
|
| 168 |
+
omnigibson/object_states/max_temperature.py
|
| 169 |
+
omnigibson/object_states/next_to.py
|
| 170 |
+
omnigibson/object_states/object_state_base.py
|
| 171 |
+
omnigibson/object_states/on_fire.py
|
| 172 |
+
omnigibson/object_states/on_top.py
|
| 173 |
+
omnigibson/object_states/open_state.py
|
| 174 |
+
omnigibson/object_states/overlaid.py
|
| 175 |
+
omnigibson/object_states/particle.py
|
| 176 |
+
omnigibson/object_states/particle_modifier.py
|
| 177 |
+
omnigibson/object_states/particle_source_or_sink.py
|
| 178 |
+
omnigibson/object_states/pose.py
|
| 179 |
+
omnigibson/object_states/robot_related_states.py
|
| 180 |
+
omnigibson/object_states/saturated.py
|
| 181 |
+
omnigibson/object_states/sliceable.py
|
| 182 |
+
omnigibson/object_states/slicer_active.py
|
| 183 |
+
omnigibson/object_states/temperature.py
|
| 184 |
+
omnigibson/object_states/tensorized_value_state.py
|
| 185 |
+
omnigibson/object_states/toggle.py
|
| 186 |
+
omnigibson/object_states/touching.py
|
| 187 |
+
omnigibson/object_states/under.py
|
| 188 |
+
omnigibson/object_states/update_state_mixin.py
|
| 189 |
+
omnigibson/objects/__init__.py
|
| 190 |
+
omnigibson/objects/controllable_object.py
|
| 191 |
+
omnigibson/objects/dataset_object.py
|
| 192 |
+
omnigibson/objects/light_object.py
|
| 193 |
+
omnigibson/objects/object_base.py
|
| 194 |
+
omnigibson/objects/primitive_object.py
|
| 195 |
+
omnigibson/objects/stateful_object.py
|
| 196 |
+
omnigibson/objects/usd_object.py
|
| 197 |
+
omnigibson/prims/__init__.py
|
| 198 |
+
omnigibson/prims/cloth_prim.py
|
| 199 |
+
omnigibson/prims/entity_prim.py
|
| 200 |
+
omnigibson/prims/geom_prim.py
|
| 201 |
+
omnigibson/prims/joint_prim.py
|
| 202 |
+
omnigibson/prims/material_prim.py
|
| 203 |
+
omnigibson/prims/prim_base.py
|
| 204 |
+
omnigibson/prims/rigid_dynamic_prim.py
|
| 205 |
+
omnigibson/prims/rigid_kinematic_prim.py
|
| 206 |
+
omnigibson/prims/rigid_prim.py
|
| 207 |
+
omnigibson/prims/xform_prim.py
|
| 208 |
+
omnigibson/reward_functions/__init__.py
|
| 209 |
+
omnigibson/reward_functions/collision_reward.py
|
| 210 |
+
omnigibson/reward_functions/grasp_reward.py
|
| 211 |
+
omnigibson/reward_functions/point_goal_reward.py
|
| 212 |
+
omnigibson/reward_functions/potential_reward.py
|
| 213 |
+
omnigibson/reward_functions/reaching_goal_reward.py
|
| 214 |
+
omnigibson/reward_functions/reward_function_base.py
|
| 215 |
+
omnigibson/robots/__init__.py
|
| 216 |
+
omnigibson/robots/a1.py
|
| 217 |
+
omnigibson/robots/active_camera_robot.py
|
| 218 |
+
omnigibson/robots/articulated_trunk_robot.py
|
| 219 |
+
omnigibson/robots/behavior_robot.py
|
| 220 |
+
omnigibson/robots/fetch.py
|
| 221 |
+
omnigibson/robots/franka.py
|
| 222 |
+
omnigibson/robots/franka_mounted.py
|
| 223 |
+
omnigibson/robots/freight.py
|
| 224 |
+
omnigibson/robots/holonomic_base_robot.py
|
| 225 |
+
omnigibson/robots/husky.py
|
| 226 |
+
omnigibson/robots/locobot.py
|
| 227 |
+
omnigibson/robots/locomotion_robot.py
|
| 228 |
+
omnigibson/robots/manipulation_robot.py
|
| 229 |
+
omnigibson/robots/mobile_manipulation_robot.py
|
| 230 |
+
omnigibson/robots/r1.py
|
| 231 |
+
omnigibson/robots/r1pro.py
|
| 232 |
+
omnigibson/robots/robot_base.py
|
| 233 |
+
omnigibson/robots/stretch.py
|
| 234 |
+
omnigibson/robots/tiago.py
|
| 235 |
+
omnigibson/robots/turtlebot.py
|
| 236 |
+
omnigibson/robots/two_wheel_robot.py
|
| 237 |
+
omnigibson/robots/untucked_arm_pose_robot.py
|
| 238 |
+
omnigibson/robots/vx300s.py
|
| 239 |
+
omnigibson/sampling/autogenerate_task_custom_list_template.py
|
| 240 |
+
omnigibson/sampling/chengshu_task_custom_lists.json
|
| 241 |
+
omnigibson/sampling/create_stable_scene.py
|
| 242 |
+
omnigibson/sampling/cremebrule_1_sample.sh
|
| 243 |
+
omnigibson/sampling/cremebrule_2_postprocess.sh
|
| 244 |
+
omnigibson/sampling/cremebrule_3_multiply.sh
|
| 245 |
+
omnigibson/sampling/cremebrule_task_custom_lists.json
|
| 246 |
+
omnigibson/sampling/hang_task_custom_lists.json
|
| 247 |
+
omnigibson/sampling/multiply_b1k_tasks.py
|
| 248 |
+
omnigibson/sampling/postprocess_sampled_task.py
|
| 249 |
+
omnigibson/sampling/sample_b1k_tasks.py
|
| 250 |
+
omnigibson/sampling/task_custom_lists.json
|
| 251 |
+
omnigibson/sampling/utils.py
|
| 252 |
+
omnigibson/scene_graphs/__init__.py
|
| 253 |
+
omnigibson/scene_graphs/graph_builder.py
|
| 254 |
+
omnigibson/scenes/__init__.py
|
| 255 |
+
omnigibson/scenes/interactive_traversable_scene.py
|
| 256 |
+
omnigibson/scenes/scene_base.py
|
| 257 |
+
omnigibson/scenes/static_traversable_scene.py
|
| 258 |
+
omnigibson/scenes/traversable_scene.py
|
| 259 |
+
omnigibson/sensors/__init__.py
|
| 260 |
+
omnigibson/sensors/dropout_sensor_noise.py
|
| 261 |
+
omnigibson/sensors/scan_sensor.py
|
| 262 |
+
omnigibson/sensors/sensor_base.py
|
| 263 |
+
omnigibson/sensors/sensor_noise_base.py
|
| 264 |
+
omnigibson/sensors/vision_sensor.py
|
| 265 |
+
omnigibson/systems/__init__.py
|
| 266 |
+
omnigibson/systems/macro_particle_system.py
|
| 267 |
+
omnigibson/systems/micro_particle_system.py
|
| 268 |
+
omnigibson/systems/system_base.py
|
| 269 |
+
omnigibson/tasks/__init__.py
|
| 270 |
+
omnigibson/tasks/behavior_task.py
|
| 271 |
+
omnigibson/tasks/dummy_task.py
|
| 272 |
+
omnigibson/tasks/grasp_task.py
|
| 273 |
+
omnigibson/tasks/point_navigation_task.py
|
| 274 |
+
omnigibson/tasks/point_reaching_task.py
|
| 275 |
+
omnigibson/tasks/task_base.py
|
| 276 |
+
omnigibson/termination_conditions/__init__.py
|
| 277 |
+
omnigibson/termination_conditions/falling.py
|
| 278 |
+
omnigibson/termination_conditions/grasp_goal.py
|
| 279 |
+
omnigibson/termination_conditions/max_collision.py
|
| 280 |
+
omnigibson/termination_conditions/point_goal.py
|
| 281 |
+
omnigibson/termination_conditions/predicate_goal.py
|
| 282 |
+
omnigibson/termination_conditions/reaching_goal.py
|
| 283 |
+
omnigibson/termination_conditions/termination_condition_base.py
|
| 284 |
+
omnigibson/termination_conditions/timeout.py
|
| 285 |
+
omnigibson/utils/__init__.py
|
| 286 |
+
omnigibson/utils/asset_conversion_utils.py
|
| 287 |
+
omnigibson/utils/asset_utils.py
|
| 288 |
+
omnigibson/utils/backend_utils.py
|
| 289 |
+
omnigibson/utils/bddl_utils.py
|
| 290 |
+
omnigibson/utils/coacd_runner.py
|
| 291 |
+
omnigibson/utils/config_utils.py
|
| 292 |
+
omnigibson/utils/constants.py
|
| 293 |
+
omnigibson/utils/control_utils.py
|
| 294 |
+
omnigibson/utils/data_utils.py
|
| 295 |
+
omnigibson/utils/deprecated_utils.py
|
| 296 |
+
omnigibson/utils/geometry_utils.py
|
| 297 |
+
omnigibson/utils/git_utils.py
|
| 298 |
+
omnigibson/utils/grasping_planning_utils.py
|
| 299 |
+
omnigibson/utils/gym_utils.py
|
| 300 |
+
omnigibson/utils/lazy_import_utils.py
|
| 301 |
+
omnigibson/utils/motion_planning_utils.py
|
| 302 |
+
omnigibson/utils/numpy_utils.py
|
| 303 |
+
omnigibson/utils/object_state_utils.py
|
| 304 |
+
omnigibson/utils/object_utils.py
|
| 305 |
+
omnigibson/utils/physx_utils.py
|
| 306 |
+
omnigibson/utils/processing_utils.py
|
| 307 |
+
omnigibson/utils/profiling_utils.py
|
| 308 |
+
omnigibson/utils/pynvml_utils.py
|
| 309 |
+
omnigibson/utils/python_utils.py
|
| 310 |
+
omnigibson/utils/registry_utils.py
|
| 311 |
+
omnigibson/utils/render_utils.py
|
| 312 |
+
omnigibson/utils/sampling_utils.py
|
| 313 |
+
omnigibson/utils/sim_utils.py
|
| 314 |
+
omnigibson/utils/teleop_utils.py
|
| 315 |
+
omnigibson/utils/transform_utils.py
|
| 316 |
+
omnigibson/utils/transform_utils_np.py
|
| 317 |
+
omnigibson/utils/ui_utils.py
|
| 318 |
+
omnigibson/utils/urdfpy_utils.py
|
| 319 |
+
omnigibson/utils/usd_utils.py
|
| 320 |
+
omnigibson/utils/vision_utils.py
|
| 321 |
+
tests/test_controllers.py
|
| 322 |
+
tests/test_curobo.py
|
| 323 |
+
tests/test_data_collection.py
|
| 324 |
+
tests/test_dump_load_states.py
|
| 325 |
+
tests/test_envs.py
|
| 326 |
+
tests/test_multiple_envs.py
|
| 327 |
+
tests/test_object_removal.py
|
| 328 |
+
tests/test_object_states.py
|
| 329 |
+
tests/test_primitives.py
|
| 330 |
+
tests/test_robot_states_flatcache.py
|
| 331 |
+
tests/test_robot_states_no_flatcache.py
|
| 332 |
+
tests/test_robot_teleoperation.py
|
| 333 |
+
tests/test_scene_graph.py
|
| 334 |
+
tests/test_sensors.py
|
| 335 |
+
tests/test_symbolic_primitives.py
|
| 336 |
+
tests/test_systems.py
|
| 337 |
+
tests/test_transform_utils.py
|
| 338 |
+
tests/test_transition_rules.py
|
OmniGibson/omnigibson.egg-info/dependency_links.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
OmniGibson/omnigibson.egg-info/not-zip-safe
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
|
OmniGibson/omnigibson.egg-info/requires.txt
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
huggingface-hub[cli]>=0.34.4
|
| 2 |
+
gymnasium>=0.28.1
|
| 3 |
+
numpy<2.0.0,>=1.23.5
|
| 4 |
+
scipy>=1.10.1
|
| 5 |
+
GitPython>=3.1.40
|
| 6 |
+
transforms3d>=0.4.1
|
| 7 |
+
networkx>=3.2.1
|
| 8 |
+
PyYAML>=6.0.1
|
| 9 |
+
addict>=2.4.0
|
| 10 |
+
ipython>=8.20.0
|
| 11 |
+
future>=0.18.3
|
| 12 |
+
trimesh>=4.0.8
|
| 13 |
+
h5py>=3.10.0
|
| 14 |
+
cryptography>=41.0.7
|
| 15 |
+
bddl~=3.7.0
|
| 16 |
+
opencv-python>=4.8.1
|
| 17 |
+
nest_asyncio>=1.5.6
|
| 18 |
+
imageio>=2.33.1
|
| 19 |
+
imageio-ffmpeg>=0.4.9
|
| 20 |
+
termcolor>=2.4.0
|
| 21 |
+
progressbar>=2.5
|
| 22 |
+
pymeshlab~=2022.2
|
| 23 |
+
click>=8.1.3
|
| 24 |
+
aenum>=3.1.15
|
| 25 |
+
rtree>=1.2.0
|
| 26 |
+
graphviz>=0.20
|
| 27 |
+
matplotlib>=3.0.0
|
| 28 |
+
lxml>=5.2.2
|
| 29 |
+
numba>=0.59.1
|
| 30 |
+
cffi~=1.17.1
|
| 31 |
+
pillow~=11.0.0
|
| 32 |
+
|
| 33 |
+
[dev]
|
| 34 |
+
pytest>=6.2.3
|
| 35 |
+
pytest-cov>=3.0.0
|
| 36 |
+
pytest_rerunfailures
|
| 37 |
+
mkdocs
|
| 38 |
+
mkdocs-autorefs
|
| 39 |
+
mkdocs-gen-files
|
| 40 |
+
mkdocs-material
|
| 41 |
+
mkdocs-material-extensions
|
| 42 |
+
mkdocstrings[python]
|
| 43 |
+
mkdocs-section-index
|
| 44 |
+
mkdocs-literate-nav
|
| 45 |
+
mkdocs-redirects
|
| 46 |
+
mkdocs-include-markdown-plugin
|
| 47 |
+
telemoma~=0.3.0
|
| 48 |
+
gspread>=6.2.1
|
| 49 |
+
|
| 50 |
+
[eval]
|
| 51 |
+
dm_tree>=0.1.9
|
| 52 |
+
hydra-core>=1.3.2
|
| 53 |
+
websockets>=15.0.1
|
| 54 |
+
msgpack>=1.1.0
|
| 55 |
+
lerobot@ git+https://github.com/huggingface/lerobot@577cd10974b84bea1f06b6472eb9e5e74e07f77a
|
| 56 |
+
gspread>=6.2.1
|
| 57 |
+
open3d>=0.19.0
|
| 58 |
+
|
| 59 |
+
[primitives]
|
| 60 |
+
ninja~=1.13.0
|
| 61 |
+
nvidia-curobo@ git+https://github.com/StanfordVL/curobo@cbaf7d32436160956dad190a9465360fad6aba73
|
| 62 |
+
ompl@ https://storage.googleapis.com/gibson_scenes/ompl-1.6.0-cp310-cp310-manylinux_2_28_x86_64.whl
|
OmniGibson/omnigibson.egg-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
omnigibson
|
OmniGibson/omnigibson/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (5.14 kB). View file
|
|
|
OmniGibson/omnigibson/__pycache__/lazy.cpython-310.pyc
ADDED
|
Binary file (284 Bytes). View file
|
|
|
OmniGibson/omnigibson/__pycache__/macros.cpython-310.pyc
ADDED
|
Binary file (6.8 kB). View file
|
|
|
OmniGibson/omnigibson/__pycache__/simulator.cpython-310.pyc
ADDED
|
Binary file (56.7 kB). View file
|
|
|
OmniGibson/omnigibson/__pycache__/transition_rules.cpython-310.pyc
ADDED
|
Binary file (80.3 kB). View file
|
|
|
OmniGibson/omnigibson/learning/__init__.py
ADDED
|
File without changes
|
OmniGibson/omnigibson/learning/datas/__init__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .iterable_dataset import BehaviorIterableDataset
|
| 2 |
+
from .lerobot_dataset import BehaviorLeRobotDataset, BehaviorLerobotDatasetMetadata
|
| 3 |
+
|
| 4 |
+
__all__ = [
|
| 5 |
+
"BehaviorIterableDataset",
|
| 6 |
+
"BehaviorLeRobotDataset",
|
| 7 |
+
"BehaviorLerobotDatasetMetadata",
|
| 8 |
+
]
|
OmniGibson/omnigibson/learning/datas/iterable_dataset.py
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import h5py
|
| 2 |
+
import json
|
| 3 |
+
import numpy as np
|
| 4 |
+
import os
|
| 5 |
+
import pandas as pd
|
| 6 |
+
import torch as th
|
| 7 |
+
import torch.distributed as dist
|
| 8 |
+
from copy import deepcopy
|
| 9 |
+
from omegaconf import OmegaConf, ListConfig
|
| 10 |
+
from omnigibson.learning.utils.array_tensor_utils import (
|
| 11 |
+
any_concat,
|
| 12 |
+
any_ones_like,
|
| 13 |
+
any_slice,
|
| 14 |
+
any_stack,
|
| 15 |
+
get_batch_size,
|
| 16 |
+
sequential_sum_balanced_partitioning,
|
| 17 |
+
)
|
| 18 |
+
from omnigibson.learning.utils.eval_utils import (
|
| 19 |
+
ACTION_QPOS_INDICES,
|
| 20 |
+
JOINT_RANGE,
|
| 21 |
+
PROPRIO_QPOS_INDICES,
|
| 22 |
+
PROPRIOCEPTION_INDICES,
|
| 23 |
+
TASK_NAMES_TO_INDICES,
|
| 24 |
+
EEF_POSITION_RANGE,
|
| 25 |
+
ROBOT_CAMERA_NAMES,
|
| 26 |
+
)
|
| 27 |
+
from omnigibson.learning.utils.obs_utils import OBS_LOADER_MAP
|
| 28 |
+
from omnigibson.utils.ui_utils import create_module_logger
|
| 29 |
+
from torch.utils.data import IterableDataset, get_worker_info
|
| 30 |
+
from typing import Any, Optional, List, Tuple, Dict, Generator
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
logger = create_module_logger("BehaviorIterableDataset")
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
class BehaviorIterableDataset(IterableDataset):
|
| 37 |
+
"""
|
| 38 |
+
BehaviorIterableDataset is an IterableDataset designed for loading and streaming demonstration data for behavior tasks.
|
| 39 |
+
It supports multi-modal observations (including low-dimensional proprioception, visual data, and point clouds), action chunking,
|
| 40 |
+
temporal context windows, and distributed data loading for scalable training.
|
| 41 |
+
Key Features:
|
| 42 |
+
- Loads demonstration data from disk, supporting multiple tasks and robots.
|
| 43 |
+
- Preloads low-dimensional data (actions, proprioception, task info) into memory for efficient access.
|
| 44 |
+
- Supports visual observation types: RGB, depth, segmentation, and point clouds, with multi-view camera support.
|
| 45 |
+
- Handles action chunking for sequence prediction tasks, with optional prediction horizon and masking.
|
| 46 |
+
- Supports temporal downsampling of data for variable frame rates.
|
| 47 |
+
- Provides deterministic shuffling and partitioning for distributed and multi-worker training.
|
| 48 |
+
- Normalizes observations and actions to standardized ranges for learning.
|
| 49 |
+
- Optionally loads and normalizes privileged task information.
|
| 50 |
+
- Implements efficient chunked streaming of data for training with context windows.
|
| 51 |
+
"""
|
| 52 |
+
|
| 53 |
+
@classmethod
|
| 54 |
+
def get_all_demo_keys(cls, data_path: str, task_names: List[str]) -> List[Any]:
|
| 55 |
+
assert os.path.exists(data_path), "Data path does not exist!"
|
| 56 |
+
task_dir_names = [f"task-{TASK_NAMES_TO_INDICES[name]:04d}" for name in task_names]
|
| 57 |
+
demo_keys = sorted(
|
| 58 |
+
[
|
| 59 |
+
file_name.split(".")[0].split("_")[-1]
|
| 60 |
+
for task_dir_name in task_dir_names
|
| 61 |
+
for file_name in os.listdir(f"{data_path}/2025-challenge-demos/data/{task_dir_name}")
|
| 62 |
+
if file_name.endswith(".parquet")
|
| 63 |
+
]
|
| 64 |
+
)
|
| 65 |
+
return demo_keys
|
| 66 |
+
|
| 67 |
+
def __init__(
|
| 68 |
+
self,
|
| 69 |
+
*args,
|
| 70 |
+
data_path: str,
|
| 71 |
+
demo_keys: List[Any],
|
| 72 |
+
robot_type: str = "R1Pro",
|
| 73 |
+
obs_window_size: int,
|
| 74 |
+
ctx_len: int,
|
| 75 |
+
use_action_chunks: bool = False,
|
| 76 |
+
action_prediction_horizon: Optional[int] = None,
|
| 77 |
+
downsample_factor: int = 1,
|
| 78 |
+
visual_obs_types: List[str],
|
| 79 |
+
multi_view_cameras: Optional[Dict[str, Any]] = None,
|
| 80 |
+
use_task_info: bool = False,
|
| 81 |
+
task_info_range: Optional[ListConfig] = None,
|
| 82 |
+
seed: int = 42,
|
| 83 |
+
shuffle: bool = True,
|
| 84 |
+
**kwargs,
|
| 85 |
+
) -> None:
|
| 86 |
+
"""
|
| 87 |
+
Initialize the BehaviorIterableDataset.
|
| 88 |
+
Args:
|
| 89 |
+
data_path (str): Path to the data directory.
|
| 90 |
+
demo_keys (List[Any]): List of demo keys.
|
| 91 |
+
robot_type (str): Type of the robot. Default is "R1Pro".
|
| 92 |
+
obs_window_size (int): Size of the observation window.
|
| 93 |
+
ctx_len (int): Context length.
|
| 94 |
+
use_action_chunks (bool): Whether to use action chunks.
|
| 95 |
+
Action will be from (T, A) to (T, L_pred_horizon, A)
|
| 96 |
+
action_prediction_horizon (Optional[int]): Horizon of the action prediction.
|
| 97 |
+
Must not be None if use_action_chunks is True.
|
| 98 |
+
downsample_factor (int): Downsample factor for the data (with uniform temporal subsampling).
|
| 99 |
+
Note that the original data is at 30Hz, so if factor=3 then data will be at 10Hz.
|
| 100 |
+
Default is 1 (no downsampling), must be >= 1.
|
| 101 |
+
visual_obs_types (List[str]): List of visual observation types to load.
|
| 102 |
+
Valid options are: "rgb", "depth", "seg".
|
| 103 |
+
multi_view_cameras (Optional[Dict[str, Any]]): Dict of id-camera pairs to load obs from.
|
| 104 |
+
use_task_info (bool): Whether to load privileged task information.
|
| 105 |
+
task_info_range (Optional[ListConfig]): Range of the task information (for normalization).
|
| 106 |
+
seed (int): Random seed.
|
| 107 |
+
shuffle (bool): Whether to shuffle the dataset.
|
| 108 |
+
"""
|
| 109 |
+
super().__init__(*args, **kwargs)
|
| 110 |
+
self._data_path = data_path
|
| 111 |
+
self._demo_keys = demo_keys
|
| 112 |
+
self._robot_type = robot_type
|
| 113 |
+
self._obs_window_size = obs_window_size
|
| 114 |
+
self._ctx_len = ctx_len
|
| 115 |
+
self._use_action_chunks = use_action_chunks
|
| 116 |
+
self._action_prediction_horizon = action_prediction_horizon
|
| 117 |
+
assert (
|
| 118 |
+
self._action_prediction_horizon is not None if self._use_action_chunks else True
|
| 119 |
+
), "action_prediction_horizon must be provided if use_action_chunks is True!"
|
| 120 |
+
self._downsample_factor = downsample_factor
|
| 121 |
+
assert self._downsample_factor >= 1, "downsample_factor must be >= 1!"
|
| 122 |
+
self._use_task_info = use_task_info
|
| 123 |
+
self._task_info_range = (
|
| 124 |
+
th.tensor(OmegaConf.to_container(task_info_range)) if task_info_range is not None else None
|
| 125 |
+
)
|
| 126 |
+
self._seed = seed
|
| 127 |
+
self._shuffle = shuffle
|
| 128 |
+
self._epoch = 0
|
| 129 |
+
|
| 130 |
+
assert set(visual_obs_types).issubset(
|
| 131 |
+
{"rgb", "depth_linear", "seg_instance_id", "pcd"}
|
| 132 |
+
), "visual_obs_types must be a subset of {'rgb', 'depth_linear', 'seg_instance_id', 'pcd'}!"
|
| 133 |
+
self._visual_obs_types = set(visual_obs_types)
|
| 134 |
+
|
| 135 |
+
self._multi_view_cameras = multi_view_cameras
|
| 136 |
+
|
| 137 |
+
self._demo_indices = list(range(len(self._demo_keys)))
|
| 138 |
+
# Preload low dim into memory
|
| 139 |
+
self._all_demos = [self._preload_demo(demo_key) for demo_key in self._demo_keys]
|
| 140 |
+
# get demo lengths (N_chunks)
|
| 141 |
+
self._demo_lengths = []
|
| 142 |
+
for demo in self._all_demos:
|
| 143 |
+
L = get_batch_size(demo, strict=True)
|
| 144 |
+
assert L >= self._obs_window_size >= 1
|
| 145 |
+
self._demo_lengths.append(L - self._obs_window_size + 1)
|
| 146 |
+
logger.info(f"Dataset chunk length: {sum(self._demo_lengths)}")
|
| 147 |
+
|
| 148 |
+
@property
|
| 149 |
+
def epoch(self):
|
| 150 |
+
return self._epoch
|
| 151 |
+
|
| 152 |
+
@epoch.setter
|
| 153 |
+
def epoch(self, epoch: int):
|
| 154 |
+
self._epoch = epoch
|
| 155 |
+
if self._shuffle:
|
| 156 |
+
# deterministically shuffle the demos
|
| 157 |
+
g = th.Generator()
|
| 158 |
+
g.manual_seed(epoch + self._seed)
|
| 159 |
+
self._demo_indices = th.randperm(len(self._demo_keys), generator=g).tolist()
|
| 160 |
+
|
| 161 |
+
def __iter__(self) -> Generator[Dict[str, Any], None, None]:
|
| 162 |
+
global_worker_id, total_global_workers = self._get_global_worker_id()
|
| 163 |
+
demo_lengths_shuffled = [self._demo_lengths[i] for i in self._demo_indices]
|
| 164 |
+
start_demo_id, start_demo_idx, end_demo_id, end_demo_idx = sequential_sum_balanced_partitioning(
|
| 165 |
+
demo_lengths_shuffled, total_global_workers, global_worker_id
|
| 166 |
+
)
|
| 167 |
+
for demo_idx, demo_ptr in enumerate(self._demo_indices[start_demo_id : end_demo_id + 1]):
|
| 168 |
+
start_idx = start_demo_idx if demo_idx == 0 else 0
|
| 169 |
+
end_idx = end_demo_idx if demo_idx == end_demo_id - start_demo_id else self._demo_lengths[demo_ptr]
|
| 170 |
+
yield from self.get_streamed_data(demo_ptr, start_idx, end_idx)
|
| 171 |
+
|
| 172 |
+
def get_streamed_data(self, demo_ptr: int, start_idx: int, end_idx: int) -> Generator[Dict[str, Any], None, None]:
|
| 173 |
+
task_id = int(self._demo_keys[demo_ptr]) // 10000
|
| 174 |
+
chunk_generator = self._chunk_demo(demo_ptr, start_idx, end_idx)
|
| 175 |
+
# Initialize obs loaders
|
| 176 |
+
obs_loaders = dict()
|
| 177 |
+
for obs_type in self._visual_obs_types:
|
| 178 |
+
if obs_type == "pcd":
|
| 179 |
+
# pcd_generator
|
| 180 |
+
f_pcd = h5py.File(
|
| 181 |
+
f"{self._data_path}/pcd_vid/task-{task_id:04d}/episode_{self._demo_keys[demo_ptr]}.hdf5",
|
| 182 |
+
"r",
|
| 183 |
+
swmr=True,
|
| 184 |
+
libver="latest",
|
| 185 |
+
)
|
| 186 |
+
# Create a generator that yields sliding windows of point clouds
|
| 187 |
+
pcd_data = f_pcd["data/demo_0/robot_r1::fused_pcd"]
|
| 188 |
+
pcd_generator = self._h5_window_generator(pcd_data, start_idx, end_idx)
|
| 189 |
+
else:
|
| 190 |
+
# calculate the start a
|
| 191 |
+
for camera_id in self._multi_view_cameras.keys():
|
| 192 |
+
camera_name = self._multi_view_cameras[camera_id]["name"]
|
| 193 |
+
stride = 1
|
| 194 |
+
kwargs = {}
|
| 195 |
+
if obs_type == "seg_instance_id":
|
| 196 |
+
with open(
|
| 197 |
+
f"{self._data_path}/2025-challenge-demos/meta/episodes/task-{task_id:04d}/episode_{self._demo_keys[demo_ptr]}.json",
|
| 198 |
+
"r",
|
| 199 |
+
) as f:
|
| 200 |
+
kwargs["id_list"] = th.tensor(
|
| 201 |
+
json.load(f)[f"{ROBOT_CAMERA_NAMES['R1Pro'][camera_id]}::unique_ins_ids"]
|
| 202 |
+
)
|
| 203 |
+
obs_loaders[f"{camera_name}::{obs_type}"] = iter(
|
| 204 |
+
OBS_LOADER_MAP[obs_type](
|
| 205 |
+
data_path=f"{self._data_path}/2025-challenge-demos",
|
| 206 |
+
task_id=task_id,
|
| 207 |
+
camera_id=camera_id,
|
| 208 |
+
demo_id=self._demo_keys[demo_ptr],
|
| 209 |
+
batch_size=self._obs_window_size,
|
| 210 |
+
stride=stride,
|
| 211 |
+
start_idx=start_idx * stride * self._downsample_factor,
|
| 212 |
+
end_idx=((end_idx - 1) * stride + self._obs_window_size) * self._downsample_factor,
|
| 213 |
+
output_size=tuple(self._multi_view_cameras[camera_id]["resolution"]),
|
| 214 |
+
**kwargs,
|
| 215 |
+
)
|
| 216 |
+
)
|
| 217 |
+
for _ in range(start_idx, end_idx):
|
| 218 |
+
data, mask = next(chunk_generator)
|
| 219 |
+
# load visual obs
|
| 220 |
+
for obs_type in self._visual_obs_types:
|
| 221 |
+
if obs_type == "pcd":
|
| 222 |
+
# get file from
|
| 223 |
+
data["obs"]["pcd"] = next(pcd_generator)
|
| 224 |
+
else:
|
| 225 |
+
for camera in self._multi_view_cameras.values():
|
| 226 |
+
data["obs"][f"{camera['name']}::{obs_type}"] = next(
|
| 227 |
+
obs_loaders[f"{camera['name']}::{obs_type}"]
|
| 228 |
+
)
|
| 229 |
+
data["masks"] = mask
|
| 230 |
+
yield data
|
| 231 |
+
for obs_type in self._visual_obs_types:
|
| 232 |
+
if obs_type == "pcd":
|
| 233 |
+
f_pcd.close()
|
| 234 |
+
else:
|
| 235 |
+
for camera in self._multi_view_cameras.values():
|
| 236 |
+
obs_loaders[f"{camera['name']}::{obs_type}"].close()
|
| 237 |
+
|
| 238 |
+
def _preload_demo(self, demo_key: Any) -> Dict[str, Any]:
|
| 239 |
+
"""
|
| 240 |
+
Preload a single demo into memory. Currently it loads action, proprio, and optionally task info.
|
| 241 |
+
Args:
|
| 242 |
+
demo_key (Any): Key of the demo to preload.
|
| 243 |
+
Returns:
|
| 244 |
+
demo (dict): Preloaded demo.
|
| 245 |
+
"""
|
| 246 |
+
demo = dict()
|
| 247 |
+
demo["obs"] = {"qpos": dict(), "eef": dict()}
|
| 248 |
+
# load low_dim data
|
| 249 |
+
action_dict = dict()
|
| 250 |
+
low_dim_data = self._extract_low_dim_data(demo_key)
|
| 251 |
+
for key, data in low_dim_data.items():
|
| 252 |
+
if key == "proprio":
|
| 253 |
+
# normalize proprioception
|
| 254 |
+
if "base_qvel" in PROPRIOCEPTION_INDICES[self._robot_type]:
|
| 255 |
+
demo["obs"]["odom"] = {
|
| 256 |
+
"base_velocity": 2
|
| 257 |
+
* (
|
| 258 |
+
data[..., PROPRIOCEPTION_INDICES[self._robot_type]["base_qvel"]]
|
| 259 |
+
- JOINT_RANGE[self._robot_type]["base"][0]
|
| 260 |
+
)
|
| 261 |
+
/ (JOINT_RANGE[self._robot_type]["base"][1] - JOINT_RANGE[self._robot_type]["base"][0])
|
| 262 |
+
- 1.0
|
| 263 |
+
}
|
| 264 |
+
for key in PROPRIO_QPOS_INDICES[self._robot_type]:
|
| 265 |
+
if "gripper" in key:
|
| 266 |
+
# rectify gripper actions to {-1, 1}
|
| 267 |
+
demo["obs"]["qpos"][key] = th.mean(
|
| 268 |
+
data[..., PROPRIO_QPOS_INDICES[self._robot_type][key]], dim=-1, keepdim=True
|
| 269 |
+
)
|
| 270 |
+
demo["obs"]["qpos"][key] = th.where(
|
| 271 |
+
demo["obs"]["qpos"][key]
|
| 272 |
+
> (JOINT_RANGE[self._robot_type][key][0] + JOINT_RANGE[self._robot_type][key][1]) / 2,
|
| 273 |
+
1.0,
|
| 274 |
+
-1.0,
|
| 275 |
+
)
|
| 276 |
+
else:
|
| 277 |
+
# normalize the qpos to [-1, 1]
|
| 278 |
+
demo["obs"]["qpos"][key] = (
|
| 279 |
+
2
|
| 280 |
+
* (
|
| 281 |
+
data[..., PROPRIO_QPOS_INDICES[self._robot_type][key]]
|
| 282 |
+
- JOINT_RANGE[self._robot_type][key][0]
|
| 283 |
+
)
|
| 284 |
+
/ (JOINT_RANGE[self._robot_type][key][1] - JOINT_RANGE[self._robot_type][key][0])
|
| 285 |
+
- 1.0
|
| 286 |
+
)
|
| 287 |
+
for key in EEF_POSITION_RANGE[self._robot_type]:
|
| 288 |
+
demo["obs"]["eef"][f"{key}_pos"] = (
|
| 289 |
+
2
|
| 290 |
+
* (
|
| 291 |
+
data[..., PROPRIOCEPTION_INDICES[self._robot_type][f"eef_{key}_pos"]]
|
| 292 |
+
- EEF_POSITION_RANGE[self._robot_type][key][0]
|
| 293 |
+
)
|
| 294 |
+
/ (EEF_POSITION_RANGE[self._robot_type][key][1] - EEF_POSITION_RANGE[self._robot_type][key][0])
|
| 295 |
+
- 1.0
|
| 296 |
+
)
|
| 297 |
+
# don't normalize the eef orientation
|
| 298 |
+
demo["obs"]["eef"][f"{key}_quat"] = data[
|
| 299 |
+
..., PROPRIOCEPTION_INDICES[self._robot_type][f"eef_{key}_quat"]
|
| 300 |
+
]
|
| 301 |
+
elif key == "action":
|
| 302 |
+
# Note that we need to take the action at the timestamp before the next observation
|
| 303 |
+
# First pad the action array so that it is divisible by the downsample factor
|
| 304 |
+
if data.shape[0] % self._downsample_factor != 0:
|
| 305 |
+
pad_size = self._downsample_factor - (data.shape[0] % self._downsample_factor)
|
| 306 |
+
# pad with the last action
|
| 307 |
+
data = th.cat([data, data[-1:].repeat(pad_size, 1)], dim=0)
|
| 308 |
+
# Now downsample the action array
|
| 309 |
+
data = data[self._downsample_factor - 1 :: self._downsample_factor]
|
| 310 |
+
for key, indices in ACTION_QPOS_INDICES[self._robot_type].items():
|
| 311 |
+
action_dict[key] = data[:, indices]
|
| 312 |
+
# action normalization
|
| 313 |
+
if "gripper" not in key: # Gripper actions are already normalized to [-1, 1]
|
| 314 |
+
action_dict[key] = (
|
| 315 |
+
2
|
| 316 |
+
* (action_dict[key] - JOINT_RANGE[self._robot_type][key][0])
|
| 317 |
+
/ (JOINT_RANGE[self._robot_type][key][1] - JOINT_RANGE[self._robot_type][key][0])
|
| 318 |
+
- 1.0
|
| 319 |
+
)
|
| 320 |
+
if self._use_action_chunks:
|
| 321 |
+
# make actions from (T, A) to (T, L_pred_horizon, A)
|
| 322 |
+
# need to construct a mask
|
| 323 |
+
action_chunks = []
|
| 324 |
+
action_chunk_masks = []
|
| 325 |
+
action_structure = deepcopy(any_slice(action_dict, np.s_[0:1])) # (1, A)
|
| 326 |
+
for t in range(get_batch_size(action_dict, strict=True)):
|
| 327 |
+
action_chunk = any_slice(action_dict, np.s_[t : t + self._action_prediction_horizon])
|
| 328 |
+
action_chunk_size = get_batch_size(action_chunk, strict=True)
|
| 329 |
+
pad_size = self._action_prediction_horizon - action_chunk_size
|
| 330 |
+
mask = any_concat(
|
| 331 |
+
[
|
| 332 |
+
th.ones((action_chunk_size,), dtype=th.bool),
|
| 333 |
+
th.zeros((pad_size,), dtype=th.bool),
|
| 334 |
+
],
|
| 335 |
+
dim=0,
|
| 336 |
+
) # (L_pred_horizon,)
|
| 337 |
+
action_chunk = any_concat(
|
| 338 |
+
[
|
| 339 |
+
action_chunk,
|
| 340 |
+
]
|
| 341 |
+
+ [any_ones_like(action_structure)] * pad_size,
|
| 342 |
+
dim=0,
|
| 343 |
+
) # (L_pred_horizon, A)
|
| 344 |
+
action_chunks.append(action_chunk)
|
| 345 |
+
action_chunk_masks.append(mask)
|
| 346 |
+
action_chunks = any_stack(action_chunks, dim=0) # (T, L_pred_horizon, A)
|
| 347 |
+
action_chunk_masks = th.stack(action_chunk_masks, dim=0) # (T, L_pred_horizon)
|
| 348 |
+
demo["actions"] = action_chunks
|
| 349 |
+
demo["action_masks"] = action_chunk_masks
|
| 350 |
+
else:
|
| 351 |
+
demo["actions"] = action_dict
|
| 352 |
+
elif key == "task":
|
| 353 |
+
if self._task_info_range is not None:
|
| 354 |
+
# Normalize task info to [-1, 1]
|
| 355 |
+
demo["obs"]["task"] = (
|
| 356 |
+
2 * (data - self._task_info_range[0]) / (self._task_info_range[1] - self._task_info_range[0])
|
| 357 |
+
- 1.0
|
| 358 |
+
)
|
| 359 |
+
else:
|
| 360 |
+
# If no range is provided, just use the raw data
|
| 361 |
+
demo["obs"]["task"] = data
|
| 362 |
+
else:
|
| 363 |
+
# For other keys, just store the data as is
|
| 364 |
+
demo["obs"][key] = data
|
| 365 |
+
return demo
|
| 366 |
+
|
| 367 |
+
def _extract_low_dim_data(self, demo_key: Any) -> Dict[str, th.Tensor]:
|
| 368 |
+
task_id = int(demo_key) // 10000
|
| 369 |
+
df = pd.read_parquet(
|
| 370 |
+
os.path.join(
|
| 371 |
+
self._data_path, "2025-challenge-demos", "data", f"task-{task_id:04d}", f"episode_{demo_key}.parquet"
|
| 372 |
+
)
|
| 373 |
+
)
|
| 374 |
+
ret = {
|
| 375 |
+
"proprio": th.from_numpy(
|
| 376 |
+
np.array(df["observation.state"][:: self._downsample_factor].tolist(), dtype=np.float32)
|
| 377 |
+
),
|
| 378 |
+
"action": th.from_numpy(np.array(df["action"].tolist(), dtype=np.float32)),
|
| 379 |
+
"cam_rel_poses": th.from_numpy(
|
| 380 |
+
np.array(df["observation.cam_rel_poses"][:: self._downsample_factor].tolist(), dtype=np.float32)
|
| 381 |
+
),
|
| 382 |
+
}
|
| 383 |
+
if self._use_task_info:
|
| 384 |
+
ret["task"] = th.from_numpy(
|
| 385 |
+
np.array(df["observation.task_info"][:: self._downsample_factor].tolist(), dtype=np.float32)
|
| 386 |
+
)
|
| 387 |
+
return ret
|
| 388 |
+
|
| 389 |
+
def _chunk_demo(self, demo_ptr: int, start_idx: int, end_idx: int) -> Generator[Tuple[dict, th.Tensor], None, None]:
|
| 390 |
+
demo = self._all_demos[demo_ptr]
|
| 391 |
+
# split obs into chunks
|
| 392 |
+
for chunk_idx in range(start_idx, end_idx):
|
| 393 |
+
data, mask = [], []
|
| 394 |
+
s = np.s_[chunk_idx : chunk_idx + self._obs_window_size]
|
| 395 |
+
data = dict()
|
| 396 |
+
for k in demo:
|
| 397 |
+
if k == "actions":
|
| 398 |
+
data[k] = any_slice(demo[k], np.s_[chunk_idx : chunk_idx + self._ctx_len])
|
| 399 |
+
action_chunk_size = get_batch_size(data[k], strict=True)
|
| 400 |
+
pad_size = self._ctx_len - action_chunk_size
|
| 401 |
+
if self._use_action_chunks:
|
| 402 |
+
assert pad_size == 0, "pad_size should be 0 if use_action_chunks is True!"
|
| 403 |
+
mask = demo["action_masks"][chunk_idx : chunk_idx + self._ctx_len]
|
| 404 |
+
else:
|
| 405 |
+
# pad action chunks to equal length of ctx_len
|
| 406 |
+
data[k] = any_concat(
|
| 407 |
+
[
|
| 408 |
+
data[k],
|
| 409 |
+
]
|
| 410 |
+
+ [any_ones_like(any_slice(data[k], np.s_[0:1]))] * pad_size,
|
| 411 |
+
dim=0,
|
| 412 |
+
)
|
| 413 |
+
mask = th.cat(
|
| 414 |
+
[
|
| 415 |
+
th.ones((action_chunk_size,), dtype=th.bool),
|
| 416 |
+
th.zeros((pad_size,), dtype=th.bool),
|
| 417 |
+
],
|
| 418 |
+
dim=0,
|
| 419 |
+
)
|
| 420 |
+
elif k != "action_masks":
|
| 421 |
+
data[k] = any_slice(demo[k], s)
|
| 422 |
+
else:
|
| 423 |
+
# action_masks has already been processed
|
| 424 |
+
pass
|
| 425 |
+
yield data, mask
|
| 426 |
+
|
| 427 |
+
def _get_global_worker_id(self):
|
| 428 |
+
worker_info = get_worker_info()
|
| 429 |
+
worker_id = worker_info.id if worker_info is not None else 0
|
| 430 |
+
if dist.is_initialized():
|
| 431 |
+
rank = dist.get_rank()
|
| 432 |
+
world_size = dist.get_world_size()
|
| 433 |
+
num_workers = worker_info.num_workers if worker_info else 1
|
| 434 |
+
global_worker_id = rank * num_workers + worker_id
|
| 435 |
+
total_global_workers = world_size * num_workers
|
| 436 |
+
else:
|
| 437 |
+
global_worker_id = worker_id
|
| 438 |
+
total_global_workers = worker_info.num_workers if worker_info else 1
|
| 439 |
+
return global_worker_id, total_global_workers
|
| 440 |
+
|
| 441 |
+
def _h5_window_generator(self, df: h5py.Dataset, start_idx: int, end_idx: int) -> Generator[th.Tensor, None, None]:
|
| 442 |
+
for i in range(start_idx, end_idx):
|
| 443 |
+
yield th.from_numpy(
|
| 444 |
+
df[
|
| 445 |
+
i * self._downsample_factor : (i + self._obs_window_size)
|
| 446 |
+
* self._downsample_factor : self._downsample_factor
|
| 447 |
+
]
|
| 448 |
+
)
|
OmniGibson/omnigibson/learning/datas/lerobot_dataset.py
ADDED
|
@@ -0,0 +1,557 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datasets
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
import numpy as np
|
| 5 |
+
import packaging.version
|
| 6 |
+
import torch as th
|
| 7 |
+
from collections import defaultdict
|
| 8 |
+
from collections.abc import Callable
|
| 9 |
+
from datasets import load_dataset
|
| 10 |
+
from huggingface_hub import snapshot_download
|
| 11 |
+
from lerobot.constants import HF_LEROBOT_HOME
|
| 12 |
+
from lerobot.datasets.lerobot_dataset import LeRobotDataset, LeRobotDatasetMetadata, CODEBASE_VERSION
|
| 13 |
+
from lerobot.datasets.utils import (
|
| 14 |
+
EPISODES_PATH,
|
| 15 |
+
EPISODES_STATS_PATH,
|
| 16 |
+
STATS_PATH,
|
| 17 |
+
TASKS_PATH,
|
| 18 |
+
cast_stats_to_numpy,
|
| 19 |
+
check_delta_timestamps,
|
| 20 |
+
check_timestamps_sync,
|
| 21 |
+
check_version_compatibility,
|
| 22 |
+
get_delta_indices,
|
| 23 |
+
get_episode_data_index,
|
| 24 |
+
get_safe_version,
|
| 25 |
+
backward_compatible_episodes_stats,
|
| 26 |
+
load_json,
|
| 27 |
+
load_jsonlines,
|
| 28 |
+
load_info,
|
| 29 |
+
is_valid_version,
|
| 30 |
+
)
|
| 31 |
+
from lerobot.datasets.video_utils import get_safe_default_codec
|
| 32 |
+
from omnigibson.learning.utils.eval_utils import TASK_NAMES_TO_INDICES, ROBOT_CAMERA_NAMES
|
| 33 |
+
from omnigibson.learning.utils.lerobot_utils import hf_transform_to_torch, decode_video_frames, aggregate_stats
|
| 34 |
+
from omnigibson.learning.utils.obs_utils import OBS_LOADER_MAP
|
| 35 |
+
from omnigibson.utils.ui_utils import create_module_logger
|
| 36 |
+
from pathlib import Path
|
| 37 |
+
from torch.utils.data import Dataset, get_worker_info
|
| 38 |
+
from typing import Iterable, List, Tuple
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
logger = create_module_logger("BehaviorLeRobotDataset")
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class BehaviorLeRobotDataset(LeRobotDataset):
|
| 45 |
+
"""
|
| 46 |
+
BehaviorLeRobotDataset is a customized dataset class for loading and managing LeRobot datasets,
|
| 47 |
+
with additional filtering and loading options tailored for the BEHAVIOR-1K benchmark.
|
| 48 |
+
This class extends LeRobotDataset and introduces the following customizations:
|
| 49 |
+
- Task-based filtering: Load only episodes corresponding to specific tasks.
|
| 50 |
+
- Modality and camera selection: Load only specified modalities (e.g., "rgb", "depth", "seg_instance_id")
|
| 51 |
+
and cameras (e.g., "left_wrist", "right_wrist", "head").
|
| 52 |
+
- Ability to download and use additional annotation and metainfo files.
|
| 53 |
+
- Local-only mode: Optionally restrict dataset usage to local files, disabling downloads.
|
| 54 |
+
- Optional batch streaming using keyframe for faster access.
|
| 55 |
+
These customizations allow for more efficient and targeted dataset usage in the context of B1K tasks
|
| 56 |
+
"""
|
| 57 |
+
|
| 58 |
+
def __init__(
|
| 59 |
+
self,
|
| 60 |
+
repo_id: str,
|
| 61 |
+
root: str | Path | None = None,
|
| 62 |
+
episodes: list[int] | None = None,
|
| 63 |
+
image_transforms: Callable | None = None,
|
| 64 |
+
delta_timestamps: dict[list[float]] | None = None,
|
| 65 |
+
tolerance_s: float = 1e-4,
|
| 66 |
+
revision: str | None = None,
|
| 67 |
+
force_cache_sync: bool = False,
|
| 68 |
+
download_videos: bool = True,
|
| 69 |
+
video_backend: str | None = "pyav",
|
| 70 |
+
batch_encoding_size: int = 1,
|
| 71 |
+
# === Customized arguments for BehaviorLeRobotDataset ===
|
| 72 |
+
tasks: Iterable[str] = None,
|
| 73 |
+
modalities: Iterable[str] = None,
|
| 74 |
+
cameras: Iterable[str] = None,
|
| 75 |
+
local_only: bool = False,
|
| 76 |
+
check_timestamp_sync: bool = True,
|
| 77 |
+
chunk_streaming_using_keyframe: bool = True,
|
| 78 |
+
shuffle: bool = True,
|
| 79 |
+
seed: int = 42,
|
| 80 |
+
):
|
| 81 |
+
"""
|
| 82 |
+
Custom args:
|
| 83 |
+
episodes (List[int]): list of episodes to use PER TASK.
|
| 84 |
+
NOTE: This is different from the actual episode indices in the dataset.
|
| 85 |
+
Rather, this is meant to be used for train/val split, or loading a specific amount of partial data.
|
| 86 |
+
If set to None, all episodes will be loaded for a given task.
|
| 87 |
+
tasks (List[str]): list of task names to load. If None, all tasks will be loaded.
|
| 88 |
+
modalities (List[str]): list of modality names to load. If None, all modalities will be loaded.
|
| 89 |
+
must be a subset of ["rgb", "depth", "seg_instance_id"]
|
| 90 |
+
cameras (List[str]): list of camera names to load. If None, all cameras will be loaded.
|
| 91 |
+
must be a subset of ["left_wrist", "right_wrist", "head"]
|
| 92 |
+
local_only (bool): whether to only use local data (not download from HuggingFace).
|
| 93 |
+
NOTE: set this to False and force_cache_sync to True if you want to force re-syncing the local cache with the remote dataset.
|
| 94 |
+
For more details, please refer to the `force_cache_sync` argument in the base class.
|
| 95 |
+
check_timestamp_sync (bool): whether to check timestamp synchronization between different modalities and the state/action data.
|
| 96 |
+
While it is set to True in the original LeRobotDataset and is set to True here by default, it can be set to False to skip the check for faster loading.
|
| 97 |
+
This will especially save time if you are loading the complete challenge demo dataset.
|
| 98 |
+
chunk_streaming_using_keyframe (bool): whether to use chunk streaming mode for loading the dataset using keyframes.
|
| 99 |
+
When this is enabled, the dataset will pseudo-randomly load data in chunks based on keyframes, allowing for faster access to the data.
|
| 100 |
+
NOTE: As B1K challenge demos has GOP size of 250 frames for efficient storage, it is STRONGLY recommended to set this to True if you don't need true frame-level random access.
|
| 101 |
+
When this is enabled, it is recommended to set shuffle to True for better randomness in chunk selection.
|
| 102 |
+
We also enforce that segmentation instance ID videos can only be loaded in chunk_streaming_using_keyframe mode for faster access.
|
| 103 |
+
shuffle (bool): whether to shuffle the chunks after loading. This ONLY applies in chunk streaming mode. Recommended to be set to True for better randomness in chunk selection.
|
| 104 |
+
seed (int): random seed for shuffling chunks.
|
| 105 |
+
"""
|
| 106 |
+
Dataset.__init__(self)
|
| 107 |
+
self.repo_id = repo_id
|
| 108 |
+
self.root = Path(os.path.expanduser(str(root))) if root else HF_LEROBOT_HOME / repo_id
|
| 109 |
+
self.image_transforms = image_transforms
|
| 110 |
+
self.delta_timestamps = delta_timestamps
|
| 111 |
+
self.tolerance_s = tolerance_s
|
| 112 |
+
self.revision = revision if revision else CODEBASE_VERSION
|
| 113 |
+
self.video_backend = video_backend if video_backend else get_safe_default_codec()
|
| 114 |
+
self.delta_indices = None
|
| 115 |
+
self.batch_encoding_size = batch_encoding_size
|
| 116 |
+
self.episodes_since_last_encoding = 0
|
| 117 |
+
|
| 118 |
+
# Unused attributes
|
| 119 |
+
self.image_writer = None
|
| 120 |
+
self.episode_buffer = None
|
| 121 |
+
|
| 122 |
+
self.root.mkdir(exist_ok=True, parents=True)
|
| 123 |
+
|
| 124 |
+
# ========== Customizations ==========
|
| 125 |
+
self.seed = seed
|
| 126 |
+
if modalities is None:
|
| 127 |
+
modalities = ["rgb", "depth", "seg_instance_id"]
|
| 128 |
+
if "seg_instance_id" in modalities:
|
| 129 |
+
assert chunk_streaming_using_keyframe, "For the sake of data loading speed, please use chunk_streaming_using_keyframe=True when loading segmentation instance ID videos."
|
| 130 |
+
if "depth" in modalities:
|
| 131 |
+
assert self.video_backend == "pyav", (
|
| 132 |
+
"Depth videos can only be decoded with the 'pyav' backend. "
|
| 133 |
+
"Please set video_backend='pyav' when initializing the dataset."
|
| 134 |
+
)
|
| 135 |
+
if cameras is None:
|
| 136 |
+
cameras = ["head", "left_wrist", "right_wrist"]
|
| 137 |
+
self.task_names = set(tasks) if tasks is not None else set(TASK_NAMES_TO_INDICES.keys())
|
| 138 |
+
self.task_indices = [TASK_NAMES_TO_INDICES[task] for task in self.task_names]
|
| 139 |
+
# Load metadata
|
| 140 |
+
self.meta = BehaviorLerobotDatasetMetadata(
|
| 141 |
+
repo_id=self.repo_id,
|
| 142 |
+
root=self.root,
|
| 143 |
+
revision=self.revision,
|
| 144 |
+
force_cache_sync=force_cache_sync,
|
| 145 |
+
tasks=self.task_names,
|
| 146 |
+
modalities=modalities,
|
| 147 |
+
cameras=cameras,
|
| 148 |
+
)
|
| 149 |
+
# overwrite episode based on task
|
| 150 |
+
all_episodes = load_jsonlines(self.root / EPISODES_PATH)
|
| 151 |
+
# get the episodes grouped by task
|
| 152 |
+
epi_by_task = defaultdict(list)
|
| 153 |
+
for item in all_episodes:
|
| 154 |
+
if item["episode_index"] // 1e4 in self.meta.tasks:
|
| 155 |
+
epi_by_task[item["episode_index"] // 1e4].append(item["episode_index"])
|
| 156 |
+
# sort and cherrypick episodes within each task
|
| 157 |
+
for task_id, ep_indices in epi_by_task.items():
|
| 158 |
+
epi_by_task[task_id] = sorted(ep_indices)
|
| 159 |
+
if episodes is not None:
|
| 160 |
+
epi_by_task[task_id] = [epi_by_task[task_id][i] for i in episodes if i < len(epi_by_task[task_id])]
|
| 161 |
+
# now put episodes back together
|
| 162 |
+
self.episodes = sorted([ep for eps in epi_by_task.values() for ep in eps])
|
| 163 |
+
# handle streaming mode and shuffling of episodes
|
| 164 |
+
self._chunk_streaming_using_keyframe = chunk_streaming_using_keyframe
|
| 165 |
+
if self._chunk_streaming_using_keyframe:
|
| 166 |
+
if not shuffle:
|
| 167 |
+
logger.warning(
|
| 168 |
+
"chunk_streaming_using_keyframe mode is enabled but shuffle is set to False. This may lead to less randomness in chunk selection."
|
| 169 |
+
)
|
| 170 |
+
self.chunks = self._get_keyframe_chunk_indices()
|
| 171 |
+
# Now, we randomly permute the episodes if shuffle is True
|
| 172 |
+
if shuffle:
|
| 173 |
+
self.current_streaming_chunk_idx = None
|
| 174 |
+
self.current_streaming_frame_idx = None
|
| 175 |
+
else:
|
| 176 |
+
self.current_streaming_chunk_idx = 0
|
| 177 |
+
self.current_streaming_frame_idx = self.chunks[self.current_streaming_chunk_idx][0]
|
| 178 |
+
self.obs_loaders = dict()
|
| 179 |
+
self._should_obs_loaders_reload = True
|
| 180 |
+
# record the positional index of each episode index within self.episodes
|
| 181 |
+
self.episode_data_index_pos = {ep_idx: i for i, ep_idx in enumerate(self.episodes)}
|
| 182 |
+
logger.info(f"Total episodes: {len(self.episodes)}")
|
| 183 |
+
# ====================================
|
| 184 |
+
|
| 185 |
+
if self.episodes is not None and self.meta._version >= packaging.version.parse("v2.1"):
|
| 186 |
+
episodes_stats = [self.meta.episodes_stats[ep_idx] for ep_idx in self.episodes]
|
| 187 |
+
self.stats = aggregate_stats(episodes_stats)
|
| 188 |
+
|
| 189 |
+
# Load actual data
|
| 190 |
+
try:
|
| 191 |
+
if force_cache_sync:
|
| 192 |
+
raise FileNotFoundError
|
| 193 |
+
for fpath in self.get_episodes_file_paths():
|
| 194 |
+
assert (self.root / fpath).is_file(), f"Missing file: {self.root / fpath}"
|
| 195 |
+
self.hf_dataset = self.load_hf_dataset()
|
| 196 |
+
except (AssertionError, FileNotFoundError, NotADirectoryError) as e:
|
| 197 |
+
if local_only:
|
| 198 |
+
raise e
|
| 199 |
+
self.revision = get_safe_version(self.repo_id, self.revision)
|
| 200 |
+
self.download_episodes(download_videos)
|
| 201 |
+
self.hf_dataset = self.load_hf_dataset()
|
| 202 |
+
|
| 203 |
+
self.episode_data_index = get_episode_data_index(self.meta.episodes, self.episodes)
|
| 204 |
+
|
| 205 |
+
# Check timestamps
|
| 206 |
+
if check_timestamp_sync:
|
| 207 |
+
timestamps = th.stack(self.hf_dataset["timestamp"]).numpy()
|
| 208 |
+
episode_indices = th.stack(self.hf_dataset["episode_index"]).numpy()
|
| 209 |
+
ep_data_index_np = {k: t.numpy() for k, t in self.episode_data_index.items()}
|
| 210 |
+
check_timestamps_sync(timestamps, episode_indices, ep_data_index_np, self.fps, self.tolerance_s)
|
| 211 |
+
|
| 212 |
+
# Setup delta_indices
|
| 213 |
+
if self.delta_timestamps is not None:
|
| 214 |
+
check_delta_timestamps(self.delta_timestamps, self.fps, self.tolerance_s)
|
| 215 |
+
self.delta_indices = get_delta_indices(self.delta_timestamps, self.fps)
|
| 216 |
+
|
| 217 |
+
def get_episodes_file_paths(self) -> list[str]:
|
| 218 |
+
"""
|
| 219 |
+
Overwrite the original method to use the episodes indices instead of range(self.meta.total_episodes)
|
| 220 |
+
"""
|
| 221 |
+
episodes = self.episodes if self.episodes is not None else list(self.meta.episodes.keys())
|
| 222 |
+
fpaths = [str(self.meta.get_data_file_path(ep_idx)) for ep_idx in episodes]
|
| 223 |
+
# append metainfo and language annotations
|
| 224 |
+
fpaths += [str(self.meta.get_metainfo_path(ep_idx)) for ep_idx in episodes]
|
| 225 |
+
# TODO: add this back once we have all the language annotations
|
| 226 |
+
# fpaths += [str(self.meta.get_annotation_path(ep_idx)) for ep_idx in episodes]
|
| 227 |
+
if len(self.meta.video_keys) > 0:
|
| 228 |
+
video_files = [
|
| 229 |
+
str(self.meta.get_video_file_path(ep_idx, vid_key))
|
| 230 |
+
for vid_key in self.meta.video_keys
|
| 231 |
+
for ep_idx in episodes
|
| 232 |
+
]
|
| 233 |
+
fpaths += video_files
|
| 234 |
+
|
| 235 |
+
return fpaths
|
| 236 |
+
|
| 237 |
+
def download_episodes(self, download_videos: bool = True) -> None:
|
| 238 |
+
"""
|
| 239 |
+
Overwrite base method to allow more flexible pattern matching.
|
| 240 |
+
Here, we do coarse filtering based on tasks, cameras, and modalities.
|
| 241 |
+
We do this instead of filename patterns to speed up pattern checking and download speed.
|
| 242 |
+
"""
|
| 243 |
+
allow_patterns = []
|
| 244 |
+
if set(self.task_indices) != set(TASK_NAMES_TO_INDICES.values()):
|
| 245 |
+
for task in self.task_indices:
|
| 246 |
+
allow_patterns.append(f"**/task-{task:04d}/**")
|
| 247 |
+
if len(self.meta.modalities) != 3:
|
| 248 |
+
for modality in self.meta.modalities:
|
| 249 |
+
if len(self.meta.camera_names) != 3:
|
| 250 |
+
for camera in self.meta.camera_names:
|
| 251 |
+
allow_patterns.append(f"**/observation.images.{modality}.{camera}/**")
|
| 252 |
+
else:
|
| 253 |
+
allow_patterns.append(f"**/observation.images.{modality}.*/**")
|
| 254 |
+
elif len(self.meta.camera_names) != 3:
|
| 255 |
+
for camera in self.meta.camera_names:
|
| 256 |
+
allow_patterns.append(f"**/observation.images.*.{camera}/**")
|
| 257 |
+
ignore_patterns = []
|
| 258 |
+
if not download_videos:
|
| 259 |
+
ignore_patterns.append("videos/")
|
| 260 |
+
if set(self.task_indices) != set(TASK_NAMES_TO_INDICES.values()):
|
| 261 |
+
for task in set(TASK_NAMES_TO_INDICES.values()).difference(self.task_indices):
|
| 262 |
+
ignore_patterns.append(f"**/task-{task:04d}/**")
|
| 263 |
+
|
| 264 |
+
allow_patterns = None if allow_patterns == [] else allow_patterns
|
| 265 |
+
ignore_patterns = None if ignore_patterns == [] else ignore_patterns
|
| 266 |
+
self.pull_from_repo(allow_patterns=allow_patterns, ignore_patterns=ignore_patterns)
|
| 267 |
+
|
| 268 |
+
def pull_from_repo(
|
| 269 |
+
self,
|
| 270 |
+
allow_patterns: list[str] | str | None = None,
|
| 271 |
+
ignore_patterns: list[str] | str | None = None,
|
| 272 |
+
) -> None:
|
| 273 |
+
"""
|
| 274 |
+
Overwrite base class to increase max workers to num of CPUs - 2
|
| 275 |
+
"""
|
| 276 |
+
logger.info(f"Pulling dataset {self.repo_id} from HuggingFace hub...")
|
| 277 |
+
snapshot_download(
|
| 278 |
+
self.repo_id,
|
| 279 |
+
repo_type="dataset",
|
| 280 |
+
revision=self.revision,
|
| 281 |
+
local_dir=self.root,
|
| 282 |
+
allow_patterns=allow_patterns,
|
| 283 |
+
ignore_patterns=ignore_patterns,
|
| 284 |
+
max_workers=os.cpu_count() - 2,
|
| 285 |
+
)
|
| 286 |
+
|
| 287 |
+
def load_hf_dataset(self) -> datasets.Dataset:
|
| 288 |
+
"""hf_dataset contains all the observations, states, actions, rewards, etc."""
|
| 289 |
+
if self.episodes is None:
|
| 290 |
+
path = str(self.root / "data")
|
| 291 |
+
hf_dataset = load_dataset("parquet", data_dir=path, split="train")
|
| 292 |
+
else:
|
| 293 |
+
files = [str(self.root / self.meta.get_data_file_path(ep_idx)) for ep_idx in self.episodes]
|
| 294 |
+
hf_dataset = load_dataset("parquet", data_files=files, split="train")
|
| 295 |
+
|
| 296 |
+
hf_dataset.set_transform(hf_transform_to_torch)
|
| 297 |
+
return hf_dataset
|
| 298 |
+
|
| 299 |
+
def __getitem__(self, idx) -> dict:
|
| 300 |
+
if not self._chunk_streaming_using_keyframe:
|
| 301 |
+
return super().__getitem__(idx)
|
| 302 |
+
# Streaming mode: we will load the episode at the current streaming index, and then increment the index for next call
|
| 303 |
+
# Randomize chunk index on first call
|
| 304 |
+
if self.current_streaming_chunk_idx is None:
|
| 305 |
+
worker_info = get_worker_info()
|
| 306 |
+
worker_id = 0 if worker_info is None else worker_info.id
|
| 307 |
+
rng = np.random.default_rng(self.seed + worker_id)
|
| 308 |
+
rng.shuffle(self.chunks)
|
| 309 |
+
self.current_streaming_chunk_idx = rng.integers(0, len(self.chunks)).item()
|
| 310 |
+
self.current_streaming_frame_idx = self.chunks[self.current_streaming_chunk_idx][0]
|
| 311 |
+
# Current chunk iterated, move to next chunk
|
| 312 |
+
if self.current_streaming_frame_idx >= self.chunks[self.current_streaming_chunk_idx][1]:
|
| 313 |
+
self.current_streaming_chunk_idx += 1
|
| 314 |
+
# All data iterated, restart from beginning
|
| 315 |
+
if self.current_streaming_chunk_idx >= len(self.chunks):
|
| 316 |
+
self.current_streaming_chunk_idx = 0
|
| 317 |
+
self.current_streaming_frame_idx = self.chunks[self.current_streaming_chunk_idx][0]
|
| 318 |
+
self._should_obs_loaders_reload = True
|
| 319 |
+
item = self.hf_dataset[self.current_streaming_frame_idx]
|
| 320 |
+
ep_idx = item["episode_index"].item()
|
| 321 |
+
|
| 322 |
+
if self._should_obs_loaders_reload:
|
| 323 |
+
for loader in self.obs_loaders.values():
|
| 324 |
+
loader.close()
|
| 325 |
+
self.obs_loaders = dict()
|
| 326 |
+
# reload video loaders for new episode
|
| 327 |
+
self.current_streaming_episode_idx = ep_idx
|
| 328 |
+
for vid_key in self.meta.video_keys:
|
| 329 |
+
kwargs = {}
|
| 330 |
+
task_id = item["task_index"].item()
|
| 331 |
+
if "seg_instance_id" in vid_key:
|
| 332 |
+
# load id list
|
| 333 |
+
with open(
|
| 334 |
+
self.root / "meta/episodes" / f"task-{task_id:04d}" / f"episode_{ep_idx:08d}.json",
|
| 335 |
+
"r",
|
| 336 |
+
) as f:
|
| 337 |
+
kwargs["id_list"] = th.tensor(
|
| 338 |
+
json.load(f)[f"{ROBOT_CAMERA_NAMES['R1Pro'][vid_key.split('.')[-1]]}::unique_ins_ids"]
|
| 339 |
+
)
|
| 340 |
+
self.obs_loaders[vid_key] = iter(
|
| 341 |
+
OBS_LOADER_MAP[vid_key.split(".")[2]](
|
| 342 |
+
data_path=self.root,
|
| 343 |
+
task_id=task_id,
|
| 344 |
+
camera_id=vid_key.split(".")[-1],
|
| 345 |
+
demo_id=f"{ep_idx:08d}",
|
| 346 |
+
start_idx=self.chunks[self.current_streaming_chunk_idx][2],
|
| 347 |
+
start_idx_is_keyframe=True,
|
| 348 |
+
batch_size=1,
|
| 349 |
+
stride=1,
|
| 350 |
+
**kwargs,
|
| 351 |
+
)
|
| 352 |
+
)
|
| 353 |
+
self._should_obs_loaders_reload = False
|
| 354 |
+
|
| 355 |
+
query_indices = None
|
| 356 |
+
if self.delta_indices is not None:
|
| 357 |
+
query_indices, padding = self._get_query_indices(self.current_streaming_frame_idx, ep_idx)
|
| 358 |
+
query_result = self._query_hf_dataset(query_indices)
|
| 359 |
+
item = {**item, **padding}
|
| 360 |
+
for key, val in query_result.items():
|
| 361 |
+
item[key] = val
|
| 362 |
+
|
| 363 |
+
# load visual observations
|
| 364 |
+
for key in self.meta.video_keys:
|
| 365 |
+
item[key] = next(self.obs_loaders[key])[0]
|
| 366 |
+
|
| 367 |
+
if self.image_transforms is not None:
|
| 368 |
+
image_keys = self.meta.camera_keys
|
| 369 |
+
for cam in image_keys:
|
| 370 |
+
item[cam] = self.image_transforms(item[cam])
|
| 371 |
+
|
| 372 |
+
# Add task as a string
|
| 373 |
+
task_idx = item["task_index"].item()
|
| 374 |
+
item["task"] = self.meta.tasks[task_idx]
|
| 375 |
+
self.current_streaming_frame_idx += 1
|
| 376 |
+
|
| 377 |
+
return item
|
| 378 |
+
|
| 379 |
+
def _get_query_indices(self, idx: int, ep_idx: int) -> tuple[dict[str, list[int | bool]]]:
|
| 380 |
+
ep_idx = self.episode_data_index_pos[ep_idx]
|
| 381 |
+
ep_start = self.episode_data_index["from"][ep_idx]
|
| 382 |
+
ep_end = self.episode_data_index["to"][ep_idx]
|
| 383 |
+
query_indices = {
|
| 384 |
+
key: [max(ep_start.item(), min(ep_end.item() - 1, idx + delta)) for delta in delta_idx]
|
| 385 |
+
for key, delta_idx in self.delta_indices.items()
|
| 386 |
+
}
|
| 387 |
+
padding = { # Pad values outside of current episode range
|
| 388 |
+
f"{key}_is_pad": th.BoolTensor(
|
| 389 |
+
[(idx + delta < ep_start.item()) | (idx + delta >= ep_end.item()) for delta in delta_idx]
|
| 390 |
+
)
|
| 391 |
+
for key, delta_idx in self.delta_indices.items()
|
| 392 |
+
}
|
| 393 |
+
return query_indices, padding
|
| 394 |
+
|
| 395 |
+
def _query_videos(self, query_timestamps: dict[str, list[float]], ep_idx: int) -> dict[str, th.Tensor]:
|
| 396 |
+
"""Note: When using data workers (e.g. DataLoader with num_workers>0), do not call this function
|
| 397 |
+
in the main process (e.g. by using a second Dataloader with num_workers=0). It will result in a
|
| 398 |
+
Segmentation Fault. This probably happens because a memory reference to the video loader is created in
|
| 399 |
+
the main process and a subprocess fails to access it.
|
| 400 |
+
"""
|
| 401 |
+
item = {}
|
| 402 |
+
for vid_key, query_ts in query_timestamps.items():
|
| 403 |
+
video_path = self.root / self.meta.get_video_file_path(ep_idx, vid_key)
|
| 404 |
+
frames = decode_video_frames(video_path, query_ts, self.tolerance_s, self.video_backend)
|
| 405 |
+
item[vid_key] = frames.squeeze(0)
|
| 406 |
+
|
| 407 |
+
return item
|
| 408 |
+
|
| 409 |
+
def _get_keyframe_chunk_indices(self, chunk_size=250) -> List[Tuple[int, int, int]]:
|
| 410 |
+
"""
|
| 411 |
+
Divide each episode into chunks of data based on GOP of the data (here for B1K, GOP size is 250 frames).
|
| 412 |
+
Args:
|
| 413 |
+
chunk_size (int): size of each chunk in number of frames. Default is 250 for B1K. Should be the GOP size of the video data.
|
| 414 |
+
Returns:
|
| 415 |
+
List of tuples, where each tuple contains (start_index, end_index, local_start_index) for each chunk.
|
| 416 |
+
"""
|
| 417 |
+
episode_lengths = {ep_idx: ep_dict["length"] for ep_idx, ep_dict in self.meta.episodes.items()}
|
| 418 |
+
episode_lengths = [episode_lengths[ep_idx] for ep_idx in self.episodes]
|
| 419 |
+
chunks = []
|
| 420 |
+
offset = 0
|
| 421 |
+
for L in episode_lengths:
|
| 422 |
+
local_starts = list(range(0, L, chunk_size))
|
| 423 |
+
local_ends = local_starts[1:] + [L]
|
| 424 |
+
for ls, le in zip(local_starts, local_ends):
|
| 425 |
+
chunks.append((offset + ls, offset + le, ls))
|
| 426 |
+
offset += L
|
| 427 |
+
return chunks
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
class BehaviorLerobotDatasetMetadata(LeRobotDatasetMetadata):
|
| 431 |
+
"""
|
| 432 |
+
BehaviorLerobotDatasetMetadata extends LeRobotDatasetMetadata with the following customizations:
|
| 433 |
+
1. Restricts the set of allowed modalities to {"rgb", "depth", "seg_instance_id"}.
|
| 434 |
+
2. Restricts the set of allowed camera names to those defined in ROBOT_CAMERA_NAMES["R1Pro"].
|
| 435 |
+
3. Provides a filtered view of dataset features, including only those corresponding to the selected modalities and camera names.
|
| 436 |
+
"""
|
| 437 |
+
|
| 438 |
+
def __init__(
|
| 439 |
+
self,
|
| 440 |
+
repo_id: str,
|
| 441 |
+
root: str | Path | None = None,
|
| 442 |
+
revision: str | None = None,
|
| 443 |
+
force_cache_sync: bool = False,
|
| 444 |
+
# === Customized arguments for BehaviorLeRobotDataset ===
|
| 445 |
+
tasks: Iterable[str] = None,
|
| 446 |
+
modalities: Iterable[str] = None,
|
| 447 |
+
cameras: Iterable[str] = None,
|
| 448 |
+
):
|
| 449 |
+
# ========== Customizations ==========
|
| 450 |
+
self.task_name_candidates = set(tasks) if tasks is not None else set(TASK_NAMES_TO_INDICES.keys())
|
| 451 |
+
self.modalities = set(modalities)
|
| 452 |
+
self.camera_names = set(cameras)
|
| 453 |
+
assert self.modalities.issubset(
|
| 454 |
+
{"rgb", "depth", "seg_instance_id"}
|
| 455 |
+
), f"Modalities must be a subset of ['rgb', 'depth', 'seg_instance_id'], but got {self.modalities}"
|
| 456 |
+
assert self.camera_names.issubset(
|
| 457 |
+
ROBOT_CAMERA_NAMES["R1Pro"]
|
| 458 |
+
), f"Camera names must be a subset of {ROBOT_CAMERA_NAMES['R1Pro']}, but got {self.camera_names}"
|
| 459 |
+
# ===================================
|
| 460 |
+
|
| 461 |
+
self.repo_id = repo_id
|
| 462 |
+
self.revision = revision if revision else CODEBASE_VERSION
|
| 463 |
+
self.root = Path(root) if root is not None else HF_LEROBOT_HOME / repo_id
|
| 464 |
+
|
| 465 |
+
try:
|
| 466 |
+
if force_cache_sync:
|
| 467 |
+
raise FileNotFoundError
|
| 468 |
+
self.load_metadata()
|
| 469 |
+
except (FileNotFoundError, NotADirectoryError):
|
| 470 |
+
if is_valid_version(self.revision):
|
| 471 |
+
self.revision = get_safe_version(self.repo_id, self.revision)
|
| 472 |
+
|
| 473 |
+
(self.root / "meta").mkdir(exist_ok=True, parents=True)
|
| 474 |
+
self.pull_from_repo(allow_patterns="meta/**", ignore_patterns="meta/episodes/**")
|
| 475 |
+
self.load_metadata()
|
| 476 |
+
|
| 477 |
+
def load_metadata(self):
|
| 478 |
+
self.info = load_info(self.root)
|
| 479 |
+
check_version_compatibility(self.repo_id, self._version, CODEBASE_VERSION)
|
| 480 |
+
self.tasks, self.task_to_task_index, self.task_names = self.load_tasks(self.root)
|
| 481 |
+
# filter based on self.task_name_candidates
|
| 482 |
+
valid_task_indices = [idx for idx, name in self.task_names.items() if name in self.task_name_candidates]
|
| 483 |
+
self.task_names = set([self.task_names[idx] for idx in valid_task_indices])
|
| 484 |
+
self.tasks = {idx: self.tasks[idx] for idx in valid_task_indices}
|
| 485 |
+
self.task_to_task_index = {v: k for k, v in self.tasks.items()}
|
| 486 |
+
|
| 487 |
+
self.episodes = self.load_episodes(self.root)
|
| 488 |
+
if self._version < packaging.version.parse("v2.1"):
|
| 489 |
+
self.stats = self.load_stats(self.root)
|
| 490 |
+
self.episodes_stats = backward_compatible_episodes_stats(self.stats, self.episodes)
|
| 491 |
+
else:
|
| 492 |
+
self.episodes_stats = self.load_episodes_stats(self.root)
|
| 493 |
+
self.stats = aggregate_stats(list(self.episodes_stats.values()))
|
| 494 |
+
logger.info(f"Loaded metadata for {len(self.episodes)} episodes.")
|
| 495 |
+
|
| 496 |
+
def load_tasks(self, local_dir: Path) -> tuple[dict, dict]:
|
| 497 |
+
tasks = load_jsonlines(local_dir / TASKS_PATH)
|
| 498 |
+
task_names = {item["task_index"]: item["task_name"] for item in sorted(tasks, key=lambda x: x["task_index"])}
|
| 499 |
+
tasks = {item["task_index"]: item["task"] for item in sorted(tasks, key=lambda x: x["task_index"])}
|
| 500 |
+
task_to_task_index = {task: task_index for task_index, task in tasks.items()}
|
| 501 |
+
return tasks, task_to_task_index, task_names
|
| 502 |
+
|
| 503 |
+
def load_episodes(self, local_dir: Path) -> dict:
|
| 504 |
+
episodes = load_jsonlines(local_dir / EPISODES_PATH)
|
| 505 |
+
return {
|
| 506 |
+
item["episode_index"]: item
|
| 507 |
+
for item in sorted(episodes, key=lambda x: x["episode_index"])
|
| 508 |
+
if item["episode_index"] // 1e4 in self.tasks
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
def load_stats(self, local_dir: Path) -> dict[str, dict[str, np.ndarray]]:
|
| 512 |
+
if not (local_dir / STATS_PATH).exists():
|
| 513 |
+
return None
|
| 514 |
+
stats = load_json(local_dir / STATS_PATH)
|
| 515 |
+
return cast_stats_to_numpy(stats)
|
| 516 |
+
|
| 517 |
+
def load_episodes_stats(self, local_dir: Path) -> dict:
|
| 518 |
+
episodes_stats = load_jsonlines(local_dir / EPISODES_STATS_PATH)
|
| 519 |
+
return {
|
| 520 |
+
item["episode_index"]: cast_stats_to_numpy(item["stats"])
|
| 521 |
+
for item in sorted(episodes_stats, key=lambda x: x["episode_index"])
|
| 522 |
+
if item["episode_index"] in self.episodes
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
def get_annotation_path(self, ep_index: int) -> Path:
|
| 526 |
+
ep_chunk = self.get_episode_chunk(ep_index)
|
| 527 |
+
fpath = self.annotation_path.format(episode_chunk=ep_chunk, episode_index=ep_index)
|
| 528 |
+
return Path(fpath)
|
| 529 |
+
|
| 530 |
+
def get_metainfo_path(self, ep_index: int) -> Path:
|
| 531 |
+
ep_chunk = self.get_episode_chunk(ep_index)
|
| 532 |
+
fpath = self.metainfo_path.format(episode_chunk=ep_chunk, episode_index=ep_index)
|
| 533 |
+
return Path(fpath)
|
| 534 |
+
|
| 535 |
+
@property
|
| 536 |
+
def annotation_path(self) -> str | None:
|
| 537 |
+
"""Formattable string for the annotation files."""
|
| 538 |
+
return self.info["annotation_path"]
|
| 539 |
+
|
| 540 |
+
@property
|
| 541 |
+
def metainfo_path(self) -> str | None:
|
| 542 |
+
"""Formattable string for the metainfo files."""
|
| 543 |
+
return self.info["metainfo_path"]
|
| 544 |
+
|
| 545 |
+
@property
|
| 546 |
+
def features(self) -> dict[str, dict]:
|
| 547 |
+
"""All features contained in the dataset."""
|
| 548 |
+
features = dict()
|
| 549 |
+
# pop not required features
|
| 550 |
+
for name in self.info["features"].keys():
|
| 551 |
+
if (
|
| 552 |
+
name.startswith("observation.images.")
|
| 553 |
+
and name.split(".")[-1] in self.camera_names
|
| 554 |
+
and name.split(".")[-2] in self.modalities
|
| 555 |
+
):
|
| 556 |
+
features[name] = self.info["features"][name]
|
| 557 |
+
return features
|
OmniGibson/omnigibson/learning/eval.py
ADDED
|
@@ -0,0 +1,490 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import csv
|
| 2 |
+
import cv2
|
| 3 |
+
import hydra
|
| 4 |
+
import json
|
| 5 |
+
import logging
|
| 6 |
+
import numpy as np
|
| 7 |
+
import omnigibson as og
|
| 8 |
+
import omnigibson.utils.transform_utils as T
|
| 9 |
+
import os
|
| 10 |
+
import sys
|
| 11 |
+
import torch as th
|
| 12 |
+
import traceback
|
| 13 |
+
from av.container import Container
|
| 14 |
+
from av.stream import Stream
|
| 15 |
+
from gello.robots.sim_robot.og_teleop_utils import (
|
| 16 |
+
augment_rooms,
|
| 17 |
+
load_available_tasks,
|
| 18 |
+
generate_robot_config,
|
| 19 |
+
get_task_relevant_room_types,
|
| 20 |
+
)
|
| 21 |
+
from gello.robots.sim_robot.og_teleop_cfg import DISABLED_TRANSITION_RULES
|
| 22 |
+
from hydra.utils import instantiate
|
| 23 |
+
from inspect import getsourcefile
|
| 24 |
+
from omegaconf import DictConfig, OmegaConf
|
| 25 |
+
from omnigibson.envs.env_wrapper import EnvironmentWrapper
|
| 26 |
+
from omnigibson.learning.utils.config_utils import register_omegaconf_resolvers
|
| 27 |
+
from omnigibson.learning.utils.eval_utils import (
|
| 28 |
+
ROBOT_CAMERA_NAMES,
|
| 29 |
+
PROPRIOCEPTION_INDICES,
|
| 30 |
+
generate_basic_environment_config,
|
| 31 |
+
flatten_obs_dict,
|
| 32 |
+
TASK_NAMES_TO_INDICES,
|
| 33 |
+
)
|
| 34 |
+
from omnigibson.learning.utils.obs_utils import (
|
| 35 |
+
create_video_writer,
|
| 36 |
+
write_video,
|
| 37 |
+
)
|
| 38 |
+
from omnigibson.macros import gm, create_module_macros
|
| 39 |
+
from omnigibson.metrics import MetricBase, AgentMetric, TaskMetric
|
| 40 |
+
from omnigibson.robots import BaseRobot
|
| 41 |
+
from omnigibson.utils.asset_utils import get_task_instance_path
|
| 42 |
+
from omnigibson.utils.python_utils import recursively_convert_to_torch
|
| 43 |
+
from pathlib import Path
|
| 44 |
+
from signal import signal, SIGINT
|
| 45 |
+
from typing import Any, Tuple, List
|
| 46 |
+
|
| 47 |
+
m = create_module_macros(module_path=__file__)
|
| 48 |
+
m.NUM_EVAL_EPISODES = 1
|
| 49 |
+
m.NUM_TRAIN_INSTANCES = 200
|
| 50 |
+
m.NUM_EVAL_INSTANCES = 10
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
# set global variables to boost performance
|
| 54 |
+
gm.ENABLE_FLATCACHE = True
|
| 55 |
+
gm.USE_GPU_DYNAMICS = False
|
| 56 |
+
gm.ENABLE_TRANSITION_RULES = True
|
| 57 |
+
|
| 58 |
+
# create module logger
|
| 59 |
+
logger = logging.getLogger("evaluator")
|
| 60 |
+
logger.setLevel(20) # info
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
class Evaluator:
|
| 64 |
+
"""
|
| 65 |
+
Evaluator class for running and evaluating policies for behavior task.
|
| 66 |
+
This class manages the setup, execution, and evaluation of policy rollouts in OmniGibson environment,
|
| 67 |
+
tracking metrics such as the number of trials, successes, and total time. It supports loading environments,
|
| 68 |
+
robots, policies, and metrics, and provides methods for stepping through the environment, resetting state,
|
| 69 |
+
and handling video outputs and loggings.
|
| 70 |
+
"""
|
| 71 |
+
|
| 72 |
+
def __init__(self, cfg: DictConfig) -> None:
|
| 73 |
+
self.cfg = cfg
|
| 74 |
+
|
| 75 |
+
# record total number and success number of trials and trial time
|
| 76 |
+
self.n_trials = 0
|
| 77 |
+
self.n_success_trials = 0
|
| 78 |
+
self.total_time = 0
|
| 79 |
+
self.robot_action = dict()
|
| 80 |
+
|
| 81 |
+
self.env = self.load_env(env_wrapper=self.cfg.env_wrapper)
|
| 82 |
+
self.policy = self.load_policy()
|
| 83 |
+
self.robot = self.load_robot()
|
| 84 |
+
self.metrics = self.load_metrics()
|
| 85 |
+
|
| 86 |
+
self.reset()
|
| 87 |
+
# manually reset environment episode number
|
| 88 |
+
self.env._current_episode = 0
|
| 89 |
+
self._video_writer = None
|
| 90 |
+
|
| 91 |
+
def load_env(self, env_wrapper: DictConfig) -> EnvironmentWrapper:
|
| 92 |
+
"""
|
| 93 |
+
Read the environment config file and create the environment.
|
| 94 |
+
The config file is located in the configs/envs directory.
|
| 95 |
+
"""
|
| 96 |
+
# Disable a subset of transition rules for data collection
|
| 97 |
+
for rule in DISABLED_TRANSITION_RULES:
|
| 98 |
+
rule.ENABLED = False
|
| 99 |
+
# Load config file
|
| 100 |
+
available_tasks = load_available_tasks()
|
| 101 |
+
task_name = self.cfg.task.name
|
| 102 |
+
assert task_name in available_tasks, f"Got invalid task name: {task_name}"
|
| 103 |
+
# Now, get human stats of the task
|
| 104 |
+
task_idx = TASK_NAMES_TO_INDICES[task_name]
|
| 105 |
+
self.human_stats = {
|
| 106 |
+
"length": [],
|
| 107 |
+
"distance_traveled": [],
|
| 108 |
+
"left_eef_displacement": [],
|
| 109 |
+
"right_eef_displacement": [],
|
| 110 |
+
}
|
| 111 |
+
with open(os.path.join(gm.DATA_PATH, "2025-challenge-task-instances", "metadata", "episodes.jsonl"), "r") as f:
|
| 112 |
+
episodes = [json.loads(line) for line in f]
|
| 113 |
+
for episode in episodes:
|
| 114 |
+
if episode["episode_index"] // 1e4 == task_idx:
|
| 115 |
+
for k in self.human_stats.keys():
|
| 116 |
+
self.human_stats[k].append(episode[k])
|
| 117 |
+
# take a mean
|
| 118 |
+
for k in self.human_stats.keys():
|
| 119 |
+
self.human_stats[k] = sum(self.human_stats[k]) / len(self.human_stats[k])
|
| 120 |
+
|
| 121 |
+
# Load the seed instance by default
|
| 122 |
+
task_cfg = available_tasks[task_name][0]
|
| 123 |
+
robot_type = self.cfg.robot.type
|
| 124 |
+
assert robot_type == "R1Pro", f"Got invalid robot type: {robot_type}, only R1Pro is supported."
|
| 125 |
+
cfg = generate_basic_environment_config(task_name=task_name, task_cfg=task_cfg)
|
| 126 |
+
if self.cfg.partial_scene_load:
|
| 127 |
+
relevant_rooms = get_task_relevant_room_types(activity_name=task_name)
|
| 128 |
+
relevant_rooms = augment_rooms(relevant_rooms, task_cfg["scene_model"], task_name)
|
| 129 |
+
cfg["scene"]["load_room_types"] = relevant_rooms
|
| 130 |
+
|
| 131 |
+
cfg["robots"] = [
|
| 132 |
+
generate_robot_config(
|
| 133 |
+
task_name=task_name,
|
| 134 |
+
task_cfg=task_cfg,
|
| 135 |
+
)
|
| 136 |
+
]
|
| 137 |
+
# Update observation modalities
|
| 138 |
+
cfg["robots"][0]["obs_modalities"] = ["proprio", "rgb"]
|
| 139 |
+
cfg["robots"][0]["proprio_obs"] = list(PROPRIOCEPTION_INDICES["R1Pro"].keys())
|
| 140 |
+
if self.cfg.robot.controllers is not None:
|
| 141 |
+
cfg["robots"][0]["controller_config"].update(self.cfg.robot.controllers)
|
| 142 |
+
if self.cfg.max_steps is None:
|
| 143 |
+
logger.info(
|
| 144 |
+
f"Setting timeout to be 2x the average length of human demos: {int(self.human_stats['length'] * 2)}"
|
| 145 |
+
)
|
| 146 |
+
cfg["task"]["termination_config"]["max_steps"] = int(self.human_stats["length"] * 2)
|
| 147 |
+
else:
|
| 148 |
+
logger.info(f"Setting timeout to be {self.cfg.max_steps} steps through config.")
|
| 149 |
+
cfg["task"]["termination_config"]["max_steps"] = self.cfg.max_steps
|
| 150 |
+
cfg["task"]["include_obs"] = False
|
| 151 |
+
env = og.Environment(configs=cfg)
|
| 152 |
+
# instantiate env wrapper
|
| 153 |
+
env = instantiate(env_wrapper, env=env)
|
| 154 |
+
return env
|
| 155 |
+
|
| 156 |
+
def load_robot(self) -> BaseRobot:
|
| 157 |
+
"""
|
| 158 |
+
Loads and returns the robot instance from the environment.
|
| 159 |
+
Returns:
|
| 160 |
+
BaseRobot: The robot instance loaded from the environment.
|
| 161 |
+
"""
|
| 162 |
+
robot = self.env.scene.object_registry("name", "robot_r1")
|
| 163 |
+
return robot
|
| 164 |
+
|
| 165 |
+
def load_policy(self) -> Any:
|
| 166 |
+
"""
|
| 167 |
+
Loads and returns the policy instance.
|
| 168 |
+
"""
|
| 169 |
+
policy = instantiate(self.cfg.model)
|
| 170 |
+
logger.info("")
|
| 171 |
+
logger.info("=" * 50)
|
| 172 |
+
logger.info(f"Loaded policy: {self.cfg.policy_name}")
|
| 173 |
+
logger.info("=" * 50)
|
| 174 |
+
logger.info("")
|
| 175 |
+
return policy
|
| 176 |
+
|
| 177 |
+
def load_metrics(self) -> List[MetricBase]:
|
| 178 |
+
"""
|
| 179 |
+
Load agent and task metrics.
|
| 180 |
+
"""
|
| 181 |
+
return [AgentMetric(self.human_stats), TaskMetric(self.human_stats)]
|
| 182 |
+
|
| 183 |
+
def step(self) -> Tuple[bool, bool]:
|
| 184 |
+
"""
|
| 185 |
+
Performs a single step of the task by executing the policy, interacting with the environment,
|
| 186 |
+
processing observations, updating metrics, and tracking trial success.
|
| 187 |
+
|
| 188 |
+
Returns:
|
| 189 |
+
Tuple[bool, bool]:
|
| 190 |
+
- terminated (bool): Whether the episode has terminated (i.e., reached a terminal state).
|
| 191 |
+
- truncated (bool): Whether the episode was truncated (i.e., stopped due to a time limit or other constraint).
|
| 192 |
+
|
| 193 |
+
Workflow:
|
| 194 |
+
1. Computes the next action using the policy based on the current observation.
|
| 195 |
+
2. Steps the environment with the computed action and retrieves the next observation,
|
| 196 |
+
termination and truncation flags, and additional info.
|
| 197 |
+
3. If the episode has ended (terminated or truncated), increments the trial counter and
|
| 198 |
+
updates the count of successful trials if the task was completed successfully.
|
| 199 |
+
4. Preprocesses the new observation.
|
| 200 |
+
5. Invokes step callbacks for all registered metrics to update their state.
|
| 201 |
+
6. Returns the termination and truncation status.
|
| 202 |
+
"""
|
| 203 |
+
self.robot_action = self.policy.forward(obs=self.obs)
|
| 204 |
+
|
| 205 |
+
obs, _, terminated, truncated, info = self.env.step(self.robot_action, n_render_iterations=1)
|
| 206 |
+
# process obs
|
| 207 |
+
self.obs = self._preprocess_obs(obs)
|
| 208 |
+
|
| 209 |
+
if terminated or truncated:
|
| 210 |
+
self.n_trials += 1
|
| 211 |
+
if info["done"]["success"]:
|
| 212 |
+
self.n_success_trials += 1
|
| 213 |
+
|
| 214 |
+
for metric in self.metrics:
|
| 215 |
+
metric.step_callback(self.env)
|
| 216 |
+
return terminated, truncated
|
| 217 |
+
|
| 218 |
+
@property
|
| 219 |
+
def video_writer(self) -> Tuple[Container, Stream]:
|
| 220 |
+
"""
|
| 221 |
+
Returns the video writer for the current evaluation step.
|
| 222 |
+
"""
|
| 223 |
+
return self._video_writer
|
| 224 |
+
|
| 225 |
+
@video_writer.setter
|
| 226 |
+
def video_writer(self, video_writer: Tuple[Container, Stream]) -> None:
|
| 227 |
+
if self._video_writer is not None:
|
| 228 |
+
(container, stream) = self._video_writer
|
| 229 |
+
# Flush any remaining packets
|
| 230 |
+
for packet in stream.encode():
|
| 231 |
+
container.mux(packet)
|
| 232 |
+
# Close the container
|
| 233 |
+
container.close()
|
| 234 |
+
self._video_writer = video_writer
|
| 235 |
+
|
| 236 |
+
def load_task_instance(self, instance_id: int, test_hidden: bool = False) -> None:
|
| 237 |
+
"""
|
| 238 |
+
Loads the configuration for a specific task instance.
|
| 239 |
+
|
| 240 |
+
Args:
|
| 241 |
+
instance_id (int): The ID of the task instance to load.
|
| 242 |
+
test_hidden (bool): [Interal use only] Whether to load the hidden test instance.
|
| 243 |
+
"""
|
| 244 |
+
scene_model = self.env.task.scene_name
|
| 245 |
+
tro_filename = self.env.task.get_cached_activity_scene_filename(
|
| 246 |
+
scene_model=scene_model,
|
| 247 |
+
activity_name=self.env.task.activity_name,
|
| 248 |
+
activity_definition_id=self.env.task.activity_definition_id,
|
| 249 |
+
activity_instance_id=instance_id,
|
| 250 |
+
)
|
| 251 |
+
if test_hidden:
|
| 252 |
+
tro_file_path = os.path.join(
|
| 253 |
+
gm.DATA_PATH,
|
| 254 |
+
"2025-challenge-test-instances",
|
| 255 |
+
self.env.task.activity_name,
|
| 256 |
+
f"{tro_filename}-tro_state.json",
|
| 257 |
+
)
|
| 258 |
+
else:
|
| 259 |
+
tro_file_path = os.path.join(
|
| 260 |
+
get_task_instance_path(scene_model),
|
| 261 |
+
f"json/{scene_model}_task_{self.env.task.activity_name}_instances/{tro_filename}-tro_state.json",
|
| 262 |
+
)
|
| 263 |
+
with open(tro_file_path, "r") as f:
|
| 264 |
+
tro_state = recursively_convert_to_torch(json.load(f))
|
| 265 |
+
for tro_key, tro_state in tro_state.items():
|
| 266 |
+
if tro_key == "robot_poses":
|
| 267 |
+
presampled_robot_poses = tro_state
|
| 268 |
+
robot_pos = presampled_robot_poses[self.robot.model_name][0]["position"]
|
| 269 |
+
robot_quat = presampled_robot_poses[self.robot.model_name][0]["orientation"]
|
| 270 |
+
self.robot.set_position_orientation(robot_pos, robot_quat)
|
| 271 |
+
# Write robot poses to scene metadata
|
| 272 |
+
self.env.scene.write_task_metadata(key=tro_key, data=tro_state)
|
| 273 |
+
else:
|
| 274 |
+
self.env.task.object_scope[tro_key].load_state(tro_state, serialized=False)
|
| 275 |
+
|
| 276 |
+
# Try to ensure that all task-relevant objects are stable
|
| 277 |
+
# They should already be stable from the sampled instance, but there is some issue where loading the state
|
| 278 |
+
# causes some jitter (maybe for small mass / thin objects?)
|
| 279 |
+
for _ in range(25):
|
| 280 |
+
og.sim.step_physics()
|
| 281 |
+
for entity in self.env.task.object_scope.values():
|
| 282 |
+
if not entity.is_system and entity.exists:
|
| 283 |
+
entity.keep_still()
|
| 284 |
+
|
| 285 |
+
self.env.scene.update_initial_file()
|
| 286 |
+
self.env.scene.reset()
|
| 287 |
+
|
| 288 |
+
def _preprocess_obs(self, obs: dict) -> dict:
|
| 289 |
+
"""
|
| 290 |
+
Preprocess the observation dictionary before passing it to the policy.
|
| 291 |
+
Args:
|
| 292 |
+
obs (dict): The observation dictionary to preprocess.
|
| 293 |
+
|
| 294 |
+
Returns:
|
| 295 |
+
dict: The preprocessed observation dictionary.
|
| 296 |
+
"""
|
| 297 |
+
obs = flatten_obs_dict(obs)
|
| 298 |
+
base_pose = self.robot.get_position_orientation()
|
| 299 |
+
cam_rel_poses = []
|
| 300 |
+
# The first time we query for camera parameters, it will return all zeros
|
| 301 |
+
# For this case, we use camera.get_position_orientation() instead.
|
| 302 |
+
# The reason we are not using camera.get_position_orientation() by defualt is because it will always return the most recent camera poses
|
| 303 |
+
# However, since og render is somewhat "async", it takes >= 3 render calls per step to actually get the up-to-date camera renderings
|
| 304 |
+
# Since we are using n_render_iterations=1 for speed concern, we need the correct corresponding camera poses instead of the most update-to-date one.
|
| 305 |
+
# Thus, we use camera parameters which are guaranteed to be in sync with the visual observations.
|
| 306 |
+
for camera_name in ROBOT_CAMERA_NAMES["R1Pro"].values():
|
| 307 |
+
camera = self.robot.sensors[camera_name.split("::")[1]]
|
| 308 |
+
direct_cam_pose = camera.camera_parameters["cameraViewTransform"]
|
| 309 |
+
if np.allclose(direct_cam_pose, np.zeros(16)):
|
| 310 |
+
cam_rel_poses.append(
|
| 311 |
+
th.cat(T.relative_pose_transform(*(camera.get_position_orientation()), *base_pose))
|
| 312 |
+
)
|
| 313 |
+
else:
|
| 314 |
+
cam_pose = T.mat2pose(th.tensor(np.linalg.inv(np.reshape(direct_cam_pose, [4, 4]).T), dtype=th.float32))
|
| 315 |
+
cam_rel_poses.append(th.cat(T.relative_pose_transform(*cam_pose, *base_pose)))
|
| 316 |
+
obs["robot_r1::cam_rel_poses"] = th.cat(cam_rel_poses, axis=-1)
|
| 317 |
+
# append task id to obs
|
| 318 |
+
obs["task_id"] = th.tensor([TASK_NAMES_TO_INDICES[self.cfg.task.name]], dtype=th.int64)
|
| 319 |
+
return obs
|
| 320 |
+
|
| 321 |
+
def _write_video(self) -> None:
|
| 322 |
+
"""
|
| 323 |
+
Write the current robot observations to video.
|
| 324 |
+
"""
|
| 325 |
+
# concatenate obs
|
| 326 |
+
left_wrist_rgb = cv2.resize(
|
| 327 |
+
self.obs[ROBOT_CAMERA_NAMES["R1Pro"]["left_wrist"] + "::rgb"].numpy(),
|
| 328 |
+
(224, 224),
|
| 329 |
+
)
|
| 330 |
+
right_wrist_rgb = cv2.resize(
|
| 331 |
+
self.obs[ROBOT_CAMERA_NAMES["R1Pro"]["right_wrist"] + "::rgb"].numpy(),
|
| 332 |
+
(224, 224),
|
| 333 |
+
)
|
| 334 |
+
head_rgb = cv2.resize(
|
| 335 |
+
self.obs[ROBOT_CAMERA_NAMES["R1Pro"]["head"] + "::rgb"].numpy(),
|
| 336 |
+
(448, 448),
|
| 337 |
+
)
|
| 338 |
+
write_video(
|
| 339 |
+
np.expand_dims(np.hstack([np.vstack([left_wrist_rgb, right_wrist_rgb]), head_rgb]), 0),
|
| 340 |
+
video_writer=self.video_writer,
|
| 341 |
+
batch_size=1,
|
| 342 |
+
mode="rgb",
|
| 343 |
+
)
|
| 344 |
+
|
| 345 |
+
def reset(self) -> None:
|
| 346 |
+
"""
|
| 347 |
+
Reset the environment, policy, and compute metrics.
|
| 348 |
+
"""
|
| 349 |
+
self.obs = self._preprocess_obs(self.env.reset()[0])
|
| 350 |
+
# run metric start callbacks
|
| 351 |
+
for metric in self.metrics:
|
| 352 |
+
metric.start_callback(self.env)
|
| 353 |
+
self.policy.reset()
|
| 354 |
+
self.n_success_trials, self.n_trials = 0, 0
|
| 355 |
+
|
| 356 |
+
def __enter__(self):
|
| 357 |
+
signal(SIGINT, self._sigint_handler)
|
| 358 |
+
return self
|
| 359 |
+
|
| 360 |
+
def __exit__(self, exc_type, exc_value, exc_tb):
|
| 361 |
+
# print stats
|
| 362 |
+
logger.info("")
|
| 363 |
+
logger.info("=" * 50)
|
| 364 |
+
logger.info(f"Total success trials: {self.n_success_trials}")
|
| 365 |
+
logger.info(f"Total trials: {self.n_trials}")
|
| 366 |
+
if self.n_trials > 0:
|
| 367 |
+
logger.info(f"Success rate: {self.n_success_trials / self.n_trials}")
|
| 368 |
+
logger.info("=" * 50)
|
| 369 |
+
logger.info("")
|
| 370 |
+
if exc_type is not None:
|
| 371 |
+
traceback.print_exception(exc_type, exc_value, exc_tb)
|
| 372 |
+
self.video_writer = None
|
| 373 |
+
self.env.close()
|
| 374 |
+
og.shutdown()
|
| 375 |
+
|
| 376 |
+
def _sigint_handler(self, signal_received, frame):
|
| 377 |
+
logger.warning("SIGINT or CTRL-C detected.\n")
|
| 378 |
+
self.__exit__(None, None, None)
|
| 379 |
+
sys.exit(0)
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
if __name__ == "__main__":
|
| 383 |
+
register_omegaconf_resolvers()
|
| 384 |
+
# open yaml from task path
|
| 385 |
+
with hydra.initialize_config_dir(f"{Path(getsourcefile(lambda:0)).parents[0]}/configs", version_base="1.1"):
|
| 386 |
+
config = hydra.compose("base_config.yaml", overrides=sys.argv[1:])
|
| 387 |
+
OmegaConf.resolve(config)
|
| 388 |
+
# set headless mode
|
| 389 |
+
gm.HEADLESS = config.headless
|
| 390 |
+
# set video path
|
| 391 |
+
if config.write_video:
|
| 392 |
+
video_path = Path(config.log_path).expanduser() / "videos"
|
| 393 |
+
video_path.mkdir(parents=True, exist_ok=True)
|
| 394 |
+
assert not (
|
| 395 |
+
config.eval_on_train_instances and config.test_hidden
|
| 396 |
+
), "Cannot eval on train instances and test hidden instances simultaneously."
|
| 397 |
+
if config.test_hidden:
|
| 398 |
+
logger.info("You are evaluating on hidden test instances! This is for internal use only.")
|
| 399 |
+
# get run instances
|
| 400 |
+
if config.eval_on_train_instances:
|
| 401 |
+
logger.info(
|
| 402 |
+
"You are evaluating on training instances, set eval_on_train_instances to False for test instances."
|
| 403 |
+
)
|
| 404 |
+
task_idx = TASK_NAMES_TO_INDICES[config.task.name]
|
| 405 |
+
with open(os.path.join(gm.DATA_PATH, "2025-challenge-task-instances", "metadata", "episodes.jsonl"), "r") as f:
|
| 406 |
+
episodes = [json.loads(line) for line in f]
|
| 407 |
+
instances_to_run = []
|
| 408 |
+
for episode in episodes:
|
| 409 |
+
if episode["episode_index"] // 1e4 == task_idx:
|
| 410 |
+
instances_to_run.append(str(int((episode["episode_index"] // 10) % 1e3)))
|
| 411 |
+
if config.eval_instance_ids:
|
| 412 |
+
assert set(config.eval_instance_ids).issubset(
|
| 413 |
+
set(range(m.NUM_TRAIN_INSTANCES))
|
| 414 |
+
), f"eval instance ids must be in range({m.NUM_TRAIN_INSTANCES})"
|
| 415 |
+
instances_to_run = [instances_to_run[i] for i in config.eval_instance_ids]
|
| 416 |
+
elif config.test_hidden:
|
| 417 |
+
instances_to_run = (
|
| 418 |
+
config.eval_instance_ids if config.eval_instance_ids is not None else set(range(m.NUM_EVAL_INSTANCES))
|
| 419 |
+
)
|
| 420 |
+
assert set(instances_to_run).issubset(
|
| 421 |
+
set(range(m.NUM_EVAL_INSTANCES))
|
| 422 |
+
), f"eval instance ids must be in range({m.NUM_EVAL_INSTANCES})"
|
| 423 |
+
else:
|
| 424 |
+
instances_to_run = (
|
| 425 |
+
config.eval_instance_ids if config.eval_instance_ids is not None else set(range(m.NUM_EVAL_INSTANCES))
|
| 426 |
+
)
|
| 427 |
+
assert set(instances_to_run).issubset(
|
| 428 |
+
set(range(m.NUM_EVAL_INSTANCES))
|
| 429 |
+
), f"eval instance ids must be in range({m.NUM_EVAL_INSTANCES})"
|
| 430 |
+
# load csv file
|
| 431 |
+
task_instance_csv_path = os.path.join(
|
| 432 |
+
gm.DATA_PATH, "2025-challenge-task-instances", "metadata", "test_instances.csv"
|
| 433 |
+
)
|
| 434 |
+
with open(task_instance_csv_path, "r") as f:
|
| 435 |
+
lines = list(csv.reader(f))[1:]
|
| 436 |
+
assert (
|
| 437 |
+
lines[TASK_NAMES_TO_INDICES[config.task.name]][1] == config.task.name
|
| 438 |
+
), f"Task name from config {config.task.name} does not match task name from csv {lines[TASK_NAMES_TO_INDICES[config.task.name]][1]}"
|
| 439 |
+
test_instances = lines[TASK_NAMES_TO_INDICES[config.task.name]][2].strip().split(",")
|
| 440 |
+
instances_to_run = [int(test_instances[i]) for i in instances_to_run]
|
| 441 |
+
# establish metrics
|
| 442 |
+
metrics = {}
|
| 443 |
+
metrics_path = Path(config.log_path).expanduser() / "metrics"
|
| 444 |
+
metrics_path.mkdir(parents=True, exist_ok=True)
|
| 445 |
+
|
| 446 |
+
with Evaluator(config) as evaluator:
|
| 447 |
+
logger.info("Starting evaluation...")
|
| 448 |
+
|
| 449 |
+
for idx in instances_to_run:
|
| 450 |
+
evaluator.reset()
|
| 451 |
+
evaluator.load_task_instance(idx, test_hidden=config.test_hidden)
|
| 452 |
+
logger.info(f"Starting task instance {idx} for evaluation...")
|
| 453 |
+
for epi in range(m.NUM_EVAL_EPISODES):
|
| 454 |
+
evaluator.reset()
|
| 455 |
+
done = False
|
| 456 |
+
if config.write_video:
|
| 457 |
+
video_name = str(video_path) + f"/{config.task.name}_{idx}_{epi}.mp4"
|
| 458 |
+
evaluator.video_writer = create_video_writer(
|
| 459 |
+
fpath=video_name,
|
| 460 |
+
resolution=(448, 672),
|
| 461 |
+
)
|
| 462 |
+
# run metric start callbacks
|
| 463 |
+
for metric in evaluator.metrics:
|
| 464 |
+
metric.start_callback(evaluator.env)
|
| 465 |
+
while not done:
|
| 466 |
+
terminated, truncated = evaluator.step()
|
| 467 |
+
if terminated or truncated:
|
| 468 |
+
done = True
|
| 469 |
+
if config.write_video:
|
| 470 |
+
evaluator._write_video()
|
| 471 |
+
if evaluator.env._current_step % 1000 == 0:
|
| 472 |
+
logger.info(f"Current step: {evaluator.env._current_step}")
|
| 473 |
+
# run metric end callbacks
|
| 474 |
+
for metric in evaluator.metrics:
|
| 475 |
+
metric.end_callback(evaluator.env)
|
| 476 |
+
logger.info(f"Evaluation finished at step {evaluator.env._current_step}.")
|
| 477 |
+
logger.info(f"Evaluation exit state: {terminated}, {truncated}")
|
| 478 |
+
logger.info(f"Total trials: {evaluator.n_trials}")
|
| 479 |
+
logger.info(f"Total success trials: {evaluator.n_success_trials}")
|
| 480 |
+
# gather metric results and write to file
|
| 481 |
+
for metric in evaluator.metrics:
|
| 482 |
+
metrics.update(metric.gather_results())
|
| 483 |
+
with open(metrics_path / f"{config.task.name}_{idx}_{epi}.json", "w") as f:
|
| 484 |
+
json.dump(metrics, f)
|
| 485 |
+
# reset video writer
|
| 486 |
+
if config.write_video:
|
| 487 |
+
evaluator.video_writer = None
|
| 488 |
+
logger.info(f"Saved video to {video_name}")
|
| 489 |
+
else:
|
| 490 |
+
logger.warning("No observations were recorded.")
|
OmniGibson/omnigibson/learning/policies.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import torch as th
|
| 3 |
+
from omnigibson.learning.utils.array_tensor_utils import torch_to_numpy
|
| 4 |
+
from omnigibson.learning.utils.network_utils import WebsocketClientPolicy
|
| 5 |
+
from typing import Optional
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
__all__ = [
|
| 9 |
+
"LocalPolicy",
|
| 10 |
+
"WebsocketPolicy",
|
| 11 |
+
]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class LocalPolicy:
|
| 15 |
+
"""
|
| 16 |
+
Local policy that directly queries action from policy,
|
| 17 |
+
outputs zero delta action if policy is None.
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
def __init__(self, *args, action_dim: Optional[int] = None, **kwargs) -> None:
|
| 21 |
+
self.policy = None # To be set later
|
| 22 |
+
self.action_dim = action_dim
|
| 23 |
+
|
| 24 |
+
def act(self, obs: dict) -> th.Tensor:
|
| 25 |
+
return self.forward(obs)
|
| 26 |
+
|
| 27 |
+
def forward(self, obs: dict, *args, **kwargs) -> th.Tensor:
|
| 28 |
+
"""
|
| 29 |
+
Directly return a zero action tensor of the specified action dimension.
|
| 30 |
+
"""
|
| 31 |
+
if self.policy is not None:
|
| 32 |
+
return self.policy.act(obs).detach().cpu()
|
| 33 |
+
else:
|
| 34 |
+
assert self.action_dim is not None
|
| 35 |
+
return th.zeros(self.action_dim, dtype=th.float32)
|
| 36 |
+
|
| 37 |
+
def reset(self) -> None:
|
| 38 |
+
if self.policy is not None:
|
| 39 |
+
self.policy.reset()
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class WebsocketPolicy:
|
| 43 |
+
"""
|
| 44 |
+
Websocket policy for controlling the robot over a websocket connection.
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
def __init__(
|
| 48 |
+
self,
|
| 49 |
+
*args,
|
| 50 |
+
host: Optional[str] = None,
|
| 51 |
+
port: Optional[int] = None,
|
| 52 |
+
**kwargs,
|
| 53 |
+
) -> None:
|
| 54 |
+
logging.info(f"Creating websocket client policy with host: {host}, port: {port}")
|
| 55 |
+
self.policy = WebsocketClientPolicy(host=host, port=port)
|
| 56 |
+
|
| 57 |
+
def forward(self, obs: dict, *args, **kwargs) -> th.Tensor:
|
| 58 |
+
# convert observation to numpy
|
| 59 |
+
obs = torch_to_numpy(obs)
|
| 60 |
+
return self.policy.act(obs).detach().cpu()
|
| 61 |
+
|
| 62 |
+
def reset(self) -> None:
|
| 63 |
+
self.policy.reset()
|
OmniGibson/omnigibson/learning/utils/__init__.py
ADDED
|
File without changes
|
OmniGibson/omnigibson/learning/utils/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (178 Bytes). View file
|
|
|
OmniGibson/omnigibson/learning/utils/__pycache__/obs_utils.cpython-310.pyc
ADDED
|
Binary file (31.3 kB). View file
|
|
|
OmniGibson/omnigibson/learning/utils/config_utils.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import functools
|
| 2 |
+
import warnings
|
| 3 |
+
from copy import deepcopy
|
| 4 |
+
from omegaconf import OmegaConf
|
| 5 |
+
from typing import Literal
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
_NO_INSTANTIATE = "__no_instantiate__" # return config as-is
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def meta_decorator(decor):
|
| 12 |
+
"""
|
| 13 |
+
a decorator decorator, allowing the wrapped decorator to be used as:
|
| 14 |
+
@decorator(*args, **kwargs)
|
| 15 |
+
def callable()
|
| 16 |
+
-- or --
|
| 17 |
+
@decorator # without parenthesis, args and kwargs will use default
|
| 18 |
+
def callable()
|
| 19 |
+
|
| 20 |
+
Args:
|
| 21 |
+
decor: a decorator whose first argument is a callable (function or class
|
| 22 |
+
to be decorated), and the rest of the arguments can be omitted as default.
|
| 23 |
+
decor(f, ... the other arguments must have default values)
|
| 24 |
+
|
| 25 |
+
Warning:
|
| 26 |
+
decor can NOT be a function that receives a single, callable argument.
|
| 27 |
+
See stackoverflow: http://goo.gl/UEYbDB
|
| 28 |
+
"""
|
| 29 |
+
single_callable = lambda args, kwargs: len(args) == 1 and len(kwargs) == 0 and callable(args[0])
|
| 30 |
+
|
| 31 |
+
@functools.wraps(decor)
|
| 32 |
+
def new_decor(*args, **kwargs):
|
| 33 |
+
if single_callable(args, kwargs):
|
| 34 |
+
# this is the double-decorated f.
|
| 35 |
+
# It should not run on a single callable.
|
| 36 |
+
return decor(args[0])
|
| 37 |
+
else:
|
| 38 |
+
# decorator arguments
|
| 39 |
+
return lambda real_f: decor(real_f, *args, **kwargs)
|
| 40 |
+
|
| 41 |
+
return new_decor
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
@meta_decorator
|
| 45 |
+
def call_once(func, on_second_call: Literal["noop", "raise", "warn"] = "noop"):
|
| 46 |
+
"""
|
| 47 |
+
Decorator to ensure that a function is only called once.
|
| 48 |
+
|
| 49 |
+
Args:
|
| 50 |
+
on_second_call (str): what happens when the function is called a second time.
|
| 51 |
+
"""
|
| 52 |
+
assert on_second_call in [
|
| 53 |
+
"noop",
|
| 54 |
+
"raise",
|
| 55 |
+
"warn",
|
| 56 |
+
], "mode must be one of 'noop', 'raise', 'warn'"
|
| 57 |
+
|
| 58 |
+
@functools.wraps(func)
|
| 59 |
+
def wrapper(*args, **kwargs):
|
| 60 |
+
if wrapper._called:
|
| 61 |
+
if on_second_call == "raise":
|
| 62 |
+
raise RuntimeError(f"{func.__name__} has already been called. Can only call once.")
|
| 63 |
+
elif on_second_call == "warn":
|
| 64 |
+
warnings.warn(f"{func.__name__} has already been called. Should only call once.")
|
| 65 |
+
else:
|
| 66 |
+
wrapper._called = True
|
| 67 |
+
return func(*args, **kwargs)
|
| 68 |
+
|
| 69 |
+
wrapper._called = False
|
| 70 |
+
return wrapper
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
@call_once(on_second_call="noop")
|
| 74 |
+
def register_omegaconf_resolvers():
|
| 75 |
+
import numpy as np
|
| 76 |
+
|
| 77 |
+
OmegaConf.register_new_resolver("_optional", lambda v: f"_{v}" if v else "")
|
| 78 |
+
OmegaConf.register_new_resolver("optional_", lambda v: f"{v}_" if v else "")
|
| 79 |
+
OmegaConf.register_new_resolver("_optional_", lambda v: f"_{v}_" if v else "")
|
| 80 |
+
OmegaConf.register_new_resolver("__optional", lambda v: f"__{v}" if v else "")
|
| 81 |
+
OmegaConf.register_new_resolver("optional__", lambda v: f"{v}__" if v else "")
|
| 82 |
+
OmegaConf.register_new_resolver("__optional__", lambda v: f"__{v}__" if v else "")
|
| 83 |
+
OmegaConf.register_new_resolver("iftrue", lambda cond, v_default: cond if cond else v_default)
|
| 84 |
+
OmegaConf.register_new_resolver("ifelse", lambda cond, v1, v2="": v1 if cond else v2)
|
| 85 |
+
OmegaConf.register_new_resolver("ifequal", lambda query, key, v1, v2: v1 if query == key else v2)
|
| 86 |
+
OmegaConf.register_new_resolver("intbool", lambda cond: 1 if cond else 0)
|
| 87 |
+
OmegaConf.register_new_resolver("mult", lambda *x: np.prod(x).tolist())
|
| 88 |
+
OmegaConf.register_new_resolver("add", lambda *x: sum(x))
|
| 89 |
+
OmegaConf.register_new_resolver("div", lambda x, y: x / y)
|
| 90 |
+
OmegaConf.register_new_resolver("intdiv", lambda x, y: x // y)
|
| 91 |
+
|
| 92 |
+
# try each key until the key exists. Useful for multiple classes that have different
|
| 93 |
+
# names for the same key
|
| 94 |
+
def _try_key(cfg, *keys):
|
| 95 |
+
for k in keys:
|
| 96 |
+
if k in cfg:
|
| 97 |
+
return cfg[k]
|
| 98 |
+
raise KeyError(f"no key in {keys} is valid")
|
| 99 |
+
|
| 100 |
+
OmegaConf.register_new_resolver("trykey", _try_key)
|
| 101 |
+
# replace `resnet.gn.ws` -> `resnet_gn_ws`, because omegaconf doesn't support
|
| 102 |
+
# keys with dots. Useful for generating run name with dots
|
| 103 |
+
OmegaConf.register_new_resolver("underscore_to_dots", lambda s: s.replace("_", "."))
|
| 104 |
+
|
| 105 |
+
def _no_instantiate(cfg):
|
| 106 |
+
cfg = deepcopy(cfg)
|
| 107 |
+
cfg[_NO_INSTANTIATE] = True
|
| 108 |
+
return cfg
|
| 109 |
+
|
| 110 |
+
OmegaConf.register_new_resolver("no_instantiate", _no_instantiate)
|
OmniGibson/omnigibson/learning/utils/dataset_utils.py
ADDED
|
@@ -0,0 +1,791 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import getpass
|
| 2 |
+
import json
|
| 3 |
+
import numpy as np
|
| 4 |
+
import os
|
| 5 |
+
import omnigibson as og
|
| 6 |
+
import pandas as pd
|
| 7 |
+
import random
|
| 8 |
+
import re
|
| 9 |
+
import requests
|
| 10 |
+
import shutil
|
| 11 |
+
import tarfile
|
| 12 |
+
import time
|
| 13 |
+
import zipfile
|
| 14 |
+
from collections import Counter
|
| 15 |
+
from datetime import datetime
|
| 16 |
+
from typing import Any, Tuple, List, Optional
|
| 17 |
+
from tqdm import tqdm
|
| 18 |
+
from google.oauth2.service_account import Credentials
|
| 19 |
+
from omnigibson.learning.utils.eval_utils import TASK_NAMES_TO_INDICES
|
| 20 |
+
from urllib.parse import urlparse
|
| 21 |
+
|
| 22 |
+
VALID_USER_NAME = ["wsai", "yinhang", "svl", "wsai-yfj", "wpai", "qinengw", "jdw"]
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def makedirs_with_mode(path, mode=0o2775) -> None:
|
| 26 |
+
"""
|
| 27 |
+
Recursively create directories with specified mode applied to all newly created dirs.
|
| 28 |
+
Args:
|
| 29 |
+
path (str): The directory path to create.
|
| 30 |
+
mode (int): The mode to apply to newly created directories.
|
| 31 |
+
"""
|
| 32 |
+
# Normalize path
|
| 33 |
+
path = os.path.abspath(path)
|
| 34 |
+
parts = path.split(os.sep)
|
| 35 |
+
if parts[0] == "":
|
| 36 |
+
parts[0] = os.sep # for absolute paths on Unix
|
| 37 |
+
|
| 38 |
+
current_path = parts[0]
|
| 39 |
+
for part in parts[1:]:
|
| 40 |
+
current_path = os.path.join(current_path, part)
|
| 41 |
+
if not os.path.exists(current_path):
|
| 42 |
+
try:
|
| 43 |
+
os.makedirs(current_path, exist_ok=True)
|
| 44 |
+
# Apply mode explicitly because os.mkdir may be affected by umask
|
| 45 |
+
os.chmod(current_path, mode)
|
| 46 |
+
except Exception as e:
|
| 47 |
+
print(f"Failed to create directory {current_path}: {e}")
|
| 48 |
+
else:
|
| 49 |
+
pass
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def get_credentials(credentials_path: str = "~/Documents/credentials") -> Tuple[Any, dict, str]:
|
| 53 |
+
"""
|
| 54 |
+
[Internal use only] Get Google Sheets and Lightwheel API credentials.
|
| 55 |
+
Args:
|
| 56 |
+
credentials_path (str): Path to the credentials directory.
|
| 57 |
+
Returns:
|
| 58 |
+
Tuple[gspread.Client, dict, str]: Google Sheets client and Lightwheel API credentials and token.
|
| 59 |
+
"""
|
| 60 |
+
import gspread
|
| 61 |
+
|
| 62 |
+
credentials_path = os.path.expanduser(credentials_path)
|
| 63 |
+
# authorize with Google Sheets API
|
| 64 |
+
SCOPES = ["https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/drive"]
|
| 65 |
+
SERVICE_ACCOUNT_FILE = f"{credentials_path}/google_credentials.json"
|
| 66 |
+
credentials = Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
|
| 67 |
+
gc = gspread.authorize(credentials)
|
| 68 |
+
|
| 69 |
+
# fetch lightwheel API token
|
| 70 |
+
LIGHTWHEEL_API_FILE = f"{credentials_path}/lightwheel_credentials.json"
|
| 71 |
+
LIGHTWHEEL_LOGIN_URL = "http://authserver.lightwheel.net/api/authenticate/v1/user/login"
|
| 72 |
+
with open(LIGHTWHEEL_API_FILE, "r") as f:
|
| 73 |
+
lightwheel_api_credentials = json.load(f)
|
| 74 |
+
|
| 75 |
+
response = requests.post(
|
| 76 |
+
LIGHTWHEEL_LOGIN_URL,
|
| 77 |
+
json={"username": lightwheel_api_credentials["username"], "password": lightwheel_api_credentials["password"]},
|
| 78 |
+
)
|
| 79 |
+
response.raise_for_status()
|
| 80 |
+
lw_token = response.json().get("token")
|
| 81 |
+
return gc, lightwheel_api_credentials, lw_token
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def update_google_sheet(credentials_path: str, task_name: str, row_idx: int) -> None:
|
| 85 |
+
"""
|
| 86 |
+
[Internal use only] update internal data replay tracking sheet.
|
| 87 |
+
Args:
|
| 88 |
+
credentials_path (str): Path to the credentials directory.
|
| 89 |
+
task_name (str): Name of the task to update.
|
| 90 |
+
row_idx (int): Row index to update.
|
| 91 |
+
"""
|
| 92 |
+
import gspread
|
| 93 |
+
|
| 94 |
+
assert getpass.getuser() in VALID_USER_NAME, f"Invalid user {getpass.getuser()}"
|
| 95 |
+
# authorize with Google Sheets API
|
| 96 |
+
SCOPES = ["https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/drive"]
|
| 97 |
+
SERVICE_ACCOUNT_FILE = f"{credentials_path}/google_credentials.json"
|
| 98 |
+
credentials = Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
|
| 99 |
+
gc = gspread.authorize(credentials)
|
| 100 |
+
spreadsheet = gc.open("B1K Challenge 2025 Data Replay Tracking Sheet")
|
| 101 |
+
worksheet_name = f"{TASK_NAMES_TO_INDICES[task_name]} - {task_name}"
|
| 102 |
+
task_worksheet = spreadsheet.worksheet(worksheet_name)
|
| 103 |
+
# get row data
|
| 104 |
+
row_data = task_worksheet.row_values(row_idx)
|
| 105 |
+
assert row_data[4] == "pending"
|
| 106 |
+
assert row_data[5] == getpass.getuser()
|
| 107 |
+
# update status and timestamp
|
| 108 |
+
task_worksheet.update(
|
| 109 |
+
range_name=f"E{row_idx}:G{row_idx}",
|
| 110 |
+
values=[["done", getpass.getuser(), time.strftime("%Y-%m-%d %H:%M:%S")]],
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def get_all_instance_id_for_task(lw_token: str, lightwheel_api_credentials: dict, task_name: str) -> Tuple[int, str]:
|
| 115 |
+
"""
|
| 116 |
+
[Internal use only] Given task name, fetch all instance IDs for that task.
|
| 117 |
+
Args:
|
| 118 |
+
lw_token (str): Lightwheel API token.
|
| 119 |
+
lightwheel_api_credentials (dict): Lightwheel API credentials.
|
| 120 |
+
task_name (str): Name of the task.
|
| 121 |
+
Returns:
|
| 122 |
+
Tuple[int, str]: instance_id and resourceUuid
|
| 123 |
+
"""
|
| 124 |
+
header = {
|
| 125 |
+
"UserName": lightwheel_api_credentials["username"],
|
| 126 |
+
"Authorization": lw_token,
|
| 127 |
+
}
|
| 128 |
+
body = {
|
| 129 |
+
"searchRequest": {
|
| 130 |
+
"whereEqFields": {
|
| 131 |
+
"projectUuid": lightwheel_api_credentials["projectUuid"],
|
| 132 |
+
"level1": task_name,
|
| 133 |
+
"taskType": 2,
|
| 134 |
+
"isEnd": True,
|
| 135 |
+
"passed": True,
|
| 136 |
+
"resourceType": 3,
|
| 137 |
+
},
|
| 138 |
+
"selectedFields": [],
|
| 139 |
+
"sortFields": {"createdAt": 2, "difficulty": 2},
|
| 140 |
+
"isDeleted": False,
|
| 141 |
+
},
|
| 142 |
+
"page": 1,
|
| 143 |
+
"pageSize": 300,
|
| 144 |
+
}
|
| 145 |
+
response = requests.post("https://assetserver.lightwheel.net/api/asset/v1/task/get", headers=header, json=body)
|
| 146 |
+
response.raise_for_status()
|
| 147 |
+
return [(item["level2"], item["resourceUuid"]) for item in response.json().get("data", [])]
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def get_urls_from_lightwheel(uuids: List[str], lightwheel_api_credentials: dict, lw_token: str) -> List[str]:
|
| 151 |
+
"""
|
| 152 |
+
[Internal use only] Given a list of UUIDs, fetch their download URLs from Lightwheel API.
|
| 153 |
+
Args:
|
| 154 |
+
uuids (List[str]): List of version UUIDs.
|
| 155 |
+
lightwheel_api_credentials (dict): Lightwheel API credentials.
|
| 156 |
+
lw_token (str): Lightwheel API token.
|
| 157 |
+
Returns:
|
| 158 |
+
List[str]: List of download URLs.
|
| 159 |
+
"""
|
| 160 |
+
header = {
|
| 161 |
+
"UserName": lightwheel_api_credentials["username"],
|
| 162 |
+
"Authorization": lw_token,
|
| 163 |
+
}
|
| 164 |
+
body = {"versionUuids": uuids, "projectUuid": lightwheel_api_credentials["projectUuid"]}
|
| 165 |
+
response = requests.post(
|
| 166 |
+
"https://assetserver.lightwheel.net/api/asset/v1/teleoperation/download", headers=header, json=body
|
| 167 |
+
)
|
| 168 |
+
response.raise_for_status()
|
| 169 |
+
urls = [res["files"][0]["url"] for res in response.json()["downloadInfos"]]
|
| 170 |
+
return urls
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
def get_timestamp_from_lightwheel(urls: List[str]) -> List[str]:
|
| 174 |
+
"""
|
| 175 |
+
[Internal use only] Given a list of URLs, fetch their timestamps (on the filename) from Lightwheel API.
|
| 176 |
+
Args:
|
| 177 |
+
urls (List[str]): List of download URLs.
|
| 178 |
+
Returns:
|
| 179 |
+
List[str]: List of timestamps.
|
| 180 |
+
"""
|
| 181 |
+
timestamps = []
|
| 182 |
+
for url in tqdm(urls):
|
| 183 |
+
resp = requests.head(url, allow_redirects=True)
|
| 184 |
+
cd = resp.headers.get("content-disposition")
|
| 185 |
+
if cd and "filename=" in cd:
|
| 186 |
+
# e.g. 'attachment; filename="episode_00001234.parquet"'
|
| 187 |
+
fname = cd.split("filename=")[-1].strip('"; ')
|
| 188 |
+
else:
|
| 189 |
+
# fallback: use last part of the URL path
|
| 190 |
+
fname = urlparse(resp.url).path.split("/")[-1]
|
| 191 |
+
# extract timestamp from filename, which is of the format "`taskname`_`timestamp``.tar"
|
| 192 |
+
timestamp = fname.rsplit("_", 1)[1].split(".")[0]
|
| 193 |
+
assert len(timestamp) == 16, f"Invalid timestamp format: {timestamp}"
|
| 194 |
+
timestamps.append(timestamp)
|
| 195 |
+
return timestamps
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def download_and_extract_data(
|
| 199 |
+
url: str,
|
| 200 |
+
data_dir: str,
|
| 201 |
+
task_name: str,
|
| 202 |
+
instance_id: int,
|
| 203 |
+
traj_id: int,
|
| 204 |
+
) -> None:
|
| 205 |
+
"""
|
| 206 |
+
[Internal use only] Download and extract data from a Lightwheel API URL.
|
| 207 |
+
Args:
|
| 208 |
+
url (str): The download URL.
|
| 209 |
+
data_dir (str): The directory to save the data.
|
| 210 |
+
task_name (str): The name of the task.
|
| 211 |
+
instance_id (int): The instance ID.
|
| 212 |
+
traj_id (int): The trajectory ID.
|
| 213 |
+
"""
|
| 214 |
+
makedirs_with_mode(f"{data_dir}/2025-challenge-rawdata/task-{TASK_NAMES_TO_INDICES[task_name]:04d}")
|
| 215 |
+
# Download zip file
|
| 216 |
+
response = requests.get(url)
|
| 217 |
+
response.raise_for_status()
|
| 218 |
+
base_name = os.path.basename(url).split("?")[0] # remove ?Expires... suffix
|
| 219 |
+
file_name = os.path.join(data_dir, "2025-challenge-rawdata", base_name)
|
| 220 |
+
base_name = base_name.split(".")[0] # remove .tar suffix
|
| 221 |
+
with open(file_name, "wb") as f:
|
| 222 |
+
f.write(response.content)
|
| 223 |
+
# unzip file
|
| 224 |
+
with tarfile.open(file_name, "r:*") as tar_ref:
|
| 225 |
+
tar_ref.extractall(f"{data_dir}/2025-challenge-rawdata")
|
| 226 |
+
# rename and move to "raw" folder
|
| 227 |
+
assert os.path.exists(
|
| 228 |
+
f"{data_dir}/2025-challenge-rawdata/{base_name}/{task_name}.hdf5"
|
| 229 |
+
), f"File not found: {data_dir}/2025-challenge-rawdata/{base_name}/{task_name}.hdf5"
|
| 230 |
+
# check running_args.json
|
| 231 |
+
with open(f"{data_dir}/2025-challenge-rawdata/{base_name}/running_args.json", "r") as f:
|
| 232 |
+
running_args = json.load(f)
|
| 233 |
+
assert running_args["task_name"] == task_name, f"Task name mismatch: {running_args['task_name']} != {task_name}"
|
| 234 |
+
assert (
|
| 235 |
+
running_args["instance_id"] == instance_id
|
| 236 |
+
), f"Instance ID mismatch: {running_args['instance_id']} in running_args.json != {instance_id} from LW API"
|
| 237 |
+
os.rename(
|
| 238 |
+
f"{data_dir}/2025-challenge-rawdata/{base_name}/{task_name}.hdf5",
|
| 239 |
+
f"{data_dir}/2025-challenge-rawdata/task-{TASK_NAMES_TO_INDICES[task_name]:04d}/episode_{TASK_NAMES_TO_INDICES[task_name]:04d}{instance_id:03d}{traj_id:01d}.hdf5",
|
| 240 |
+
)
|
| 241 |
+
# remove tar file and
|
| 242 |
+
os.remove(file_name)
|
| 243 |
+
os.remove(f"{data_dir}/2025-challenge-rawdata/{base_name}/running_args.json")
|
| 244 |
+
os.rmdir(f"{data_dir}/2025-challenge-rawdata/{base_name}")
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
def reorder_sheet(worksheet) -> None:
|
| 248 |
+
"""
|
| 249 |
+
Reorder rows in the worksheet based on column B and column A.
|
| 250 |
+
|
| 251 |
+
Rules:
|
| 252 |
+
0. First row is header row -> keep as-is.
|
| 253 |
+
1. Rows with B == 0 → first group, sorted by A.
|
| 254 |
+
2. Rows with B != -1 (and not 0) → second group, sorted by A.
|
| 255 |
+
3. Rows with B == -1 → last group, sorted by A.
|
| 256 |
+
"""
|
| 257 |
+
|
| 258 |
+
# Get all values
|
| 259 |
+
all_values = worksheet.get_all_values()
|
| 260 |
+
if not all_values:
|
| 261 |
+
return # empty sheet
|
| 262 |
+
|
| 263 |
+
header, rows = all_values[0], all_values[1:]
|
| 264 |
+
|
| 265 |
+
# Parse into (A, B, rest_of_row)
|
| 266 |
+
def parse_row(row):
|
| 267 |
+
row[0] = int(row[0])
|
| 268 |
+
row[1] = int(row[1])
|
| 269 |
+
return row[0], row[1], row
|
| 270 |
+
|
| 271 |
+
parsed = [parse_row(row) for row in rows]
|
| 272 |
+
|
| 273 |
+
# Grouping
|
| 274 |
+
group_b0 = [r for r in parsed if r[1] == 0]
|
| 275 |
+
group_notm1 = [r for r in parsed if r[1] > 0]
|
| 276 |
+
group_m1 = [r for r in parsed if r[1] < 0]
|
| 277 |
+
|
| 278 |
+
# Sort each group by A
|
| 279 |
+
group_b0.sort(key=lambda x: x[0])
|
| 280 |
+
group_notm1.sort(key=lambda x: x[0])
|
| 281 |
+
group_m1.sort(key=lambda x: x[0])
|
| 282 |
+
|
| 283 |
+
# Rebuild ordered rows
|
| 284 |
+
new_rows = [r[2] for r in group_b0 + group_notm1 + group_m1]
|
| 285 |
+
|
| 286 |
+
# Write back in one batch
|
| 287 |
+
worksheet.update("A1", [header] + new_rows)
|
| 288 |
+
print("Reordered rows in worksheet:", worksheet.title)
|
| 289 |
+
time.sleep(1) # to avoid rate limiting
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
def remove_failed_episodes(worksheet, data_dir: str) -> None:
|
| 293 |
+
"""
|
| 294 |
+
For the given worksheet and data_dir:
|
| 295 |
+
0. Ignore the first row (header)
|
| 296 |
+
1. Extract task_id from ws.title, which is "{task_id} - {task_name}"
|
| 297 |
+
2. For each row with column B == -1:
|
| 298 |
+
- take demo_id = int(column A)
|
| 299 |
+
- construct episode_name = f"episode_{task_id:04d}{demo_id:04d}"
|
| 300 |
+
- remove corresponding files from data_dir in all subfolders
|
| 301 |
+
"""
|
| 302 |
+
# --- Step 1: get task_id from sheet title ---
|
| 303 |
+
title = worksheet.title
|
| 304 |
+
task_id_str, _ = title.split(" - ", 1)
|
| 305 |
+
task_id = int(task_id_str)
|
| 306 |
+
|
| 307 |
+
# --- Step 2: read all rows (ignore header) ---
|
| 308 |
+
all_values = worksheet.get_all_values()
|
| 309 |
+
rows = all_values[1:]
|
| 310 |
+
total_removed = 0
|
| 311 |
+
for row in rows:
|
| 312 |
+
if len(row) < 2:
|
| 313 |
+
continue
|
| 314 |
+
try:
|
| 315 |
+
demo_id = int(row[0])
|
| 316 |
+
b_val = int(row[1])
|
| 317 |
+
except ValueError:
|
| 318 |
+
continue
|
| 319 |
+
|
| 320 |
+
if b_val == -1:
|
| 321 |
+
episode_name = f"episode_{task_id:04d}{demo_id:03d}0"
|
| 322 |
+
|
| 323 |
+
# Files to remove
|
| 324 |
+
files = [
|
| 325 |
+
os.path.join(data_dir, f"data/task-{task_id:04d}/{episode_name}.parquet"),
|
| 326 |
+
os.path.join(data_dir, f"meta/episodes/task-{task_id:04d}/{episode_name}.json"),
|
| 327 |
+
os.path.join(data_dir, f"raw/task-{task_id:04d}/{episode_name}.hdf5"),
|
| 328 |
+
os.path.join(data_dir, f"videos/task-{task_id:04d}/observation.images.depth.head/{episode_name}.mp4"),
|
| 329 |
+
os.path.join(
|
| 330 |
+
data_dir, f"videos/task-{task_id:04d}/observation.images.depth.left_wrist/{episode_name}.mp4"
|
| 331 |
+
),
|
| 332 |
+
os.path.join(
|
| 333 |
+
data_dir, f"videos/task-{task_id:04d}/observation.images.depth.right_wrist/{episode_name}.mp4"
|
| 334 |
+
),
|
| 335 |
+
os.path.join(data_dir, f"videos/task-{task_id:04d}/observation.images.rgb.head/{episode_name}.mp4"),
|
| 336 |
+
os.path.join(
|
| 337 |
+
data_dir, f"videos/task-{task_id:04d}/observation.images.rgb.left_wrist/{episode_name}.mp4"
|
| 338 |
+
),
|
| 339 |
+
os.path.join(
|
| 340 |
+
data_dir, f"videos/task-{task_id:04d}/observation.images.rgb.right_wrist/{episode_name}.mp4"
|
| 341 |
+
),
|
| 342 |
+
os.path.join(
|
| 343 |
+
data_dir, f"videos/task-{task_id:04d}/observation.images.seg_instance_id.head/{episode_name}.mp4"
|
| 344 |
+
),
|
| 345 |
+
os.path.join(
|
| 346 |
+
data_dir,
|
| 347 |
+
f"videos/task-{task_id:04d}/observation.images.seg_instance_id.left_wrist/{episode_name}.mp4",
|
| 348 |
+
),
|
| 349 |
+
os.path.join(
|
| 350 |
+
data_dir,
|
| 351 |
+
f"videos/task-{task_id:04d}/observation.images.seg_instance_id.right_wrist/{episode_name}.mp4",
|
| 352 |
+
),
|
| 353 |
+
]
|
| 354 |
+
n_removed = 0
|
| 355 |
+
for f in files:
|
| 356 |
+
if os.path.exists(f):
|
| 357 |
+
os.remove(f)
|
| 358 |
+
n_removed += 1
|
| 359 |
+
total_removed += n_removed
|
| 360 |
+
print(f"Total removed files for task {task_id}: {total_removed}")
|
| 361 |
+
return total_removed
|
| 362 |
+
|
| 363 |
+
|
| 364 |
+
def extract_annotations(
|
| 365 |
+
data_dir: str,
|
| 366 |
+
annotation_data_dir: str,
|
| 367 |
+
credentials_path: str = "~/Documents/credentials",
|
| 368 |
+
remove_memory_prefix: bool = False,
|
| 369 |
+
) -> None:
|
| 370 |
+
"""
|
| 371 |
+
Extract annotations from the annotation data directory and store in the data directory.
|
| 372 |
+
If remove_memory_prefix is True, remove "memory_prefix" field in skill annotations.
|
| 373 |
+
"""
|
| 374 |
+
data_dir = os.path.expanduser(data_dir)
|
| 375 |
+
makedirs_with_mode(f"{data_dir}/annotations")
|
| 376 |
+
annotation_data_dir = os.path.expanduser(annotation_data_dir)
|
| 377 |
+
# get tracking worksheet
|
| 378 |
+
gc = get_credentials(credentials_path)[0]
|
| 379 |
+
spreadsheet = gc.open("B1K Challenge 2025 Data Replay Tracking Sheet")
|
| 380 |
+
|
| 381 |
+
task_processed = 0
|
| 382 |
+
# iterate through all files under annotation_data_dir,
|
| 383 |
+
for file in os.listdir(annotation_data_dir):
|
| 384 |
+
if file.endswith(".zip"):
|
| 385 |
+
# extract filename
|
| 386 |
+
filename = file[:-4]
|
| 387 |
+
if filename not in TASK_NAMES_TO_INDICES:
|
| 388 |
+
print(f"Invalid task name: {filename}")
|
| 389 |
+
continue
|
| 390 |
+
# unzip the file
|
| 391 |
+
with zipfile.ZipFile(os.path.join(annotation_data_dir, file), "r") as zip_ref:
|
| 392 |
+
zip_ref.extractall(f"{data_dir}/annotations")
|
| 393 |
+
# rename folder based on task indices
|
| 394 |
+
task_index = TASK_NAMES_TO_INDICES[filename]
|
| 395 |
+
os.rename(f"{data_dir}/annotations/{filename}", f"{data_dir}/annotations/task-{task_index:04d}")
|
| 396 |
+
# now, assert there are 200 files in the task folder
|
| 397 |
+
assert (
|
| 398 |
+
len(os.listdir(f"{data_dir}/annotations/task-{task_index:04d}")) == 200
|
| 399 |
+
), f"Task {task_index} does not have 200 files."
|
| 400 |
+
# now, fetch all timestamp - task indices correspondance from worksheet
|
| 401 |
+
worksheet = spreadsheet.worksheet(f"{task_index} - {filename}")
|
| 402 |
+
rows = worksheet.get_all_values()[1:] # skip header
|
| 403 |
+
for row in rows:
|
| 404 |
+
if row and row[4] == "done":
|
| 405 |
+
instance_id, traj_id, timestamp = int(row[0]), int(row[1]), row[3]
|
| 406 |
+
assert os.path.isfile(
|
| 407 |
+
f"{data_dir}/annotations/task-{task_index:04d}/{filename}_{timestamp}.json"
|
| 408 |
+
), f"Missing annotation for {instance_id}"
|
| 409 |
+
# rename episode
|
| 410 |
+
os.rename(
|
| 411 |
+
f"{data_dir}/annotations/task-{task_index:04d}/{filename}_{timestamp}.json",
|
| 412 |
+
f"{data_dir}/annotations/task-{task_index:04d}/episode_{task_index:04d}{instance_id:03d}{traj_id:01d}.json",
|
| 413 |
+
)
|
| 414 |
+
if remove_memory_prefix:
|
| 415 |
+
# remove "memory" in skill_annotations and primitive_annotations
|
| 416 |
+
with open(
|
| 417 |
+
f"{data_dir}/annotations/task-{task_index:04d}/episode_{task_index:04d}{instance_id:03d}{traj_id:01d}.json",
|
| 418 |
+
"r",
|
| 419 |
+
) as f:
|
| 420 |
+
annotation_data = json.load(f)
|
| 421 |
+
for skill in annotation_data.get("skill_annotation", []):
|
| 422 |
+
if "memory_prefix" in skill:
|
| 423 |
+
del skill["memory_prefix"]
|
| 424 |
+
for primitive in annotation_data.get("primitive_annotation", []):
|
| 425 |
+
if "memory_prefix" in primitive:
|
| 426 |
+
del primitive["memory_prefix"]
|
| 427 |
+
with open(
|
| 428 |
+
f"{data_dir}/annotations/task-{task_index:04d}/episode_{task_index:04d}{instance_id:03d}{traj_id:01d}.json",
|
| 429 |
+
"w",
|
| 430 |
+
) as f:
|
| 431 |
+
json.dump(annotation_data, f, indent=4)
|
| 432 |
+
print(f"Finished processing task {task_index} - {filename}")
|
| 433 |
+
task_processed += 1
|
| 434 |
+
time.sleep(1.5) # to avoid rate limiting
|
| 435 |
+
|
| 436 |
+
# remove __MACOSX folder
|
| 437 |
+
shutil.rmtree(f"{data_dir}/annotations/__MACOSX")
|
| 438 |
+
print(f"Finished processing {task_processed} tasks.")
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
def check_leaf_folders_have_n(data_dir: str, n: int = 200) -> Tuple[dict, int]:
|
| 442 |
+
"""
|
| 443 |
+
Recursively find all leaf folders under data_dir.
|
| 444 |
+
A leaf folder is one that contains only files (no subdirectories).
|
| 445 |
+
For each leaf folder, check it has exactly n files.
|
| 446 |
+
Args:
|
| 447 |
+
data_dir (str): The root directory to start searching.
|
| 448 |
+
n (int): The exact number of files each leaf folder should have.
|
| 449 |
+
Returns:
|
| 450 |
+
Tuple[dict, int]: A tuple containing:
|
| 451 |
+
- A dictionary mapping leaf folder paths to their file counts.
|
| 452 |
+
- The total file count across all leaf folders.
|
| 453 |
+
"""
|
| 454 |
+
data_dir = os.path.expanduser(data_dir)
|
| 455 |
+
results = {}
|
| 456 |
+
total_count = 0
|
| 457 |
+
for root, dirs, files in os.walk(data_dir):
|
| 458 |
+
# ignore hidden folders
|
| 459 |
+
dirs[:] = [d for d in dirs if not d.startswith(".")]
|
| 460 |
+
# leaf folder: contains files but no subdirs
|
| 461 |
+
if not dirs:
|
| 462 |
+
count = len([f for f in files if os.path.isfile(os.path.join(root, f))])
|
| 463 |
+
results[root] = count
|
| 464 |
+
total_count += count
|
| 465 |
+
if count == n:
|
| 466 |
+
print(f"✅ {root} has exactly {n} files.")
|
| 467 |
+
else:
|
| 468 |
+
raise Exception(f"❌ {root} has {count} files (expected {n}).")
|
| 469 |
+
print(f"Total files across all leaf folders: {total_count}")
|
| 470 |
+
return results, total_count
|
| 471 |
+
|
| 472 |
+
|
| 473 |
+
def update_sheet_counts(worksheet) -> None:
|
| 474 |
+
"""
|
| 475 |
+
[Internal use only] Updates the worksheet:
|
| 476 |
+
1. For rows with B != 0:
|
| 477 |
+
- E = "ignored"
|
| 478 |
+
- F = ""
|
| 479 |
+
2. Replace column B with the number of occurrences of column A
|
| 480 |
+
in previous rows.
|
| 481 |
+
"""
|
| 482 |
+
all_values = worksheet.get_all_values()
|
| 483 |
+
if not all_values:
|
| 484 |
+
return
|
| 485 |
+
|
| 486 |
+
_, rows = all_values[0], all_values[1:]
|
| 487 |
+
|
| 488 |
+
# Track counts of column A values
|
| 489 |
+
counts = {}
|
| 490 |
+
|
| 491 |
+
updated_rows = []
|
| 492 |
+
for row in rows:
|
| 493 |
+
row[0] = int(row[0])
|
| 494 |
+
row[1] = int(row[1])
|
| 495 |
+
row[7] = ""
|
| 496 |
+
|
| 497 |
+
# --- Step 1: update columns E/F based on original B ---
|
| 498 |
+
if row[1] != 0:
|
| 499 |
+
row[4] = "ignored" # Column E (0-indexed 4)
|
| 500 |
+
row[5] = "" # Column F (0-indexed 5)
|
| 501 |
+
|
| 502 |
+
# --- Step 2: update column B with previous counts of A ---
|
| 503 |
+
prev_count = counts.get(row[0], 0)
|
| 504 |
+
row[1] = int(prev_count) # Column B
|
| 505 |
+
counts[row[0]] = prev_count + 1
|
| 506 |
+
|
| 507 |
+
updated_rows.append(row)
|
| 508 |
+
|
| 509 |
+
# Update the sheet in one batch
|
| 510 |
+
worksheet.update("A2", updated_rows)
|
| 511 |
+
print("Changed worksheet:", worksheet.title)
|
| 512 |
+
time.sleep(1) # to avoid rate limiting
|
| 513 |
+
|
| 514 |
+
|
| 515 |
+
def assign_test_instances(task_ws, ws_misc, misc_values) -> None:
|
| 516 |
+
"""
|
| 517 |
+
For a given task worksheet and the misc spreadsheet:
|
| 518 |
+
1. Get task_id and task_name from worksheet title "{id} - {name}".
|
| 519 |
+
2. Collect unique integers in Column A and compute missing IDs from {1..300}.
|
| 520 |
+
3. Sample up to 20 missing IDs
|
| 521 |
+
4. Write groups into columns C in the matching row of Test Instances tab.
|
| 522 |
+
"""
|
| 523 |
+
# --- Step 1: parse task id/name from worksheet title ---
|
| 524 |
+
title = task_ws.title
|
| 525 |
+
task_id_str, task_name = title.split(" - ", 1)
|
| 526 |
+
task_id = int(task_id_str)
|
| 527 |
+
|
| 528 |
+
# --- Step 2: collect unique ints in column A ---
|
| 529 |
+
all_values = task_ws.get_all_values()
|
| 530 |
+
rows = all_values[1:] # ignore header
|
| 531 |
+
col_a_set = set()
|
| 532 |
+
for row in rows:
|
| 533 |
+
if not row or not row[0]:
|
| 534 |
+
continue
|
| 535 |
+
try:
|
| 536 |
+
col_a_set.add(int(row[0]))
|
| 537 |
+
except ValueError:
|
| 538 |
+
continue
|
| 539 |
+
|
| 540 |
+
ref_set = set(range(1, 301))
|
| 541 |
+
# assert col_a_set is a subset of ref_set
|
| 542 |
+
assert col_a_set.issubset(ref_set), f"Column A has values outside 1-300: {col_a_set - ref_set}"
|
| 543 |
+
missing = list(ref_set - col_a_set)
|
| 544 |
+
assert len(missing) >= 20, f"Not enough missing IDs to sample 20: only {len(missing)} missing."
|
| 545 |
+
|
| 546 |
+
# --- Step 3: sample up to 20 ---
|
| 547 |
+
sample_missing = random.sample(missing, 20)
|
| 548 |
+
random.shuffle(sample_missing)
|
| 549 |
+
|
| 550 |
+
# --- Step 4: open misc sheet and find correct row ---
|
| 551 |
+
|
| 552 |
+
# First row is header
|
| 553 |
+
target_row = misc_values[task_id + 1]
|
| 554 |
+
assert (
|
| 555 |
+
int(target_row[0]) == task_id and target_row[1].strip() == task_name
|
| 556 |
+
), f"Row mismatch for task {task_id} - {task_name}: found {target_row[0]} - {target_row[1]}"
|
| 557 |
+
|
| 558 |
+
# --- Step 5: update in one batch ---
|
| 559 |
+
ws_misc.update(range_name=f"C{task_id + 2}:C{task_id + 2}", values=[[", ".join(map(str, sample_missing))]])
|
| 560 |
+
time.sleep(1)
|
| 561 |
+
|
| 562 |
+
print(f"✅ Updated task {task_id} - {task_name} with test instances.")
|
| 563 |
+
|
| 564 |
+
|
| 565 |
+
def update_parquet_indices(root_dir: str):
|
| 566 |
+
"""For every parquet file named episode_XXXXXXXX.parquet, update episode_index and task_index."""
|
| 567 |
+
pat = re.compile(r"episode_(\d{8})\.parquet$")
|
| 568 |
+
|
| 569 |
+
for dirpath, _, filenames in os.walk(root_dir):
|
| 570 |
+
print(dirpath)
|
| 571 |
+
for fname in filenames:
|
| 572 |
+
fpath = os.path.join(dirpath, fname)
|
| 573 |
+
|
| 574 |
+
m = pat.search(fname)
|
| 575 |
+
if not m:
|
| 576 |
+
continue # not a matching parquet
|
| 577 |
+
|
| 578 |
+
episode_num = int(m.group(1))
|
| 579 |
+
task_num = int(m.group(1)[:4])
|
| 580 |
+
try:
|
| 581 |
+
df = pd.read_parquet(fpath)
|
| 582 |
+
|
| 583 |
+
assert "episode_index" in df.columns
|
| 584 |
+
df["episode_index"] = episode_num
|
| 585 |
+
assert "task_index" in df.columns
|
| 586 |
+
df["task_index"] = task_num
|
| 587 |
+
|
| 588 |
+
# overwrite parquet
|
| 589 |
+
df.to_parquet(fpath, index=False)
|
| 590 |
+
|
| 591 |
+
except Exception as e:
|
| 592 |
+
print(f"Skipping {fpath}, error: {e}")
|
| 593 |
+
|
| 594 |
+
|
| 595 |
+
def remove_grasp_state(root_dir: str):
|
| 596 |
+
"""
|
| 597 |
+
For every parquet file named episode_XXXXXXXX.parquet,
|
| 598 |
+
If observation.state has dim 258, remove dim 193 and 233 (grasp_left and grasp_right) and save the parquet back to disk.
|
| 599 |
+
"""
|
| 600 |
+
pat = re.compile(r"episode_(\d{8})\.parquet$")
|
| 601 |
+
|
| 602 |
+
for dirpath, _, filenames in os.walk(root_dir):
|
| 603 |
+
print(dirpath)
|
| 604 |
+
for fname in filenames:
|
| 605 |
+
fpath = os.path.join(dirpath, fname)
|
| 606 |
+
|
| 607 |
+
m = pat.search(fname)
|
| 608 |
+
if not m:
|
| 609 |
+
continue # not a matching parquet
|
| 610 |
+
|
| 611 |
+
try:
|
| 612 |
+
df = pd.read_parquet(fpath)
|
| 613 |
+
|
| 614 |
+
assert "observation.state" in df.columns
|
| 615 |
+
obs = np.array(df["observation.state"].tolist())
|
| 616 |
+
if obs.ndim == 2 and obs.shape[1] == 258:
|
| 617 |
+
obs = np.delete(obs, [193, 233], axis=1)
|
| 618 |
+
df["observation.state"] = obs.tolist()
|
| 619 |
+
|
| 620 |
+
# overwrite parquet
|
| 621 |
+
df.to_parquet(fpath, index=False)
|
| 622 |
+
|
| 623 |
+
except Exception as e:
|
| 624 |
+
print(f"Skipping {fpath}, error: {e}")
|
| 625 |
+
|
| 626 |
+
|
| 627 |
+
def fix_permissions(root_dir: str):
|
| 628 |
+
"""Recursively set rw-rw-r-- for all files owned by the current user."""
|
| 629 |
+
for dirpath, _, filenames in os.walk(root_dir):
|
| 630 |
+
print(dirpath)
|
| 631 |
+
for fname in filenames:
|
| 632 |
+
fpath = os.path.join(dirpath, fname)
|
| 633 |
+
try:
|
| 634 |
+
os.chmod(fpath, 0o664) # rw-rw-r--
|
| 635 |
+
except (PermissionError, FileNotFoundError):
|
| 636 |
+
continue
|
| 637 |
+
|
| 638 |
+
|
| 639 |
+
def download_raw(credentials_path: str = "~/Documents/credentials", max_traj_per_task: int = 200):
|
| 640 |
+
task_list = list(TASK_NAMES_TO_INDICES.keys())
|
| 641 |
+
data_dir = "/vision/group/behavior/2025-challenge-rawdata"
|
| 642 |
+
gc, lightwheel_api_credentials, lw_token = get_credentials(credentials_path=credentials_path)
|
| 643 |
+
|
| 644 |
+
tracking_spreadsheet = gc.open("B1K Challenge 2025 Data Replay Tracking Sheet")
|
| 645 |
+
worksheets = tracking_spreadsheet.worksheets()
|
| 646 |
+
for ws in worksheets:
|
| 647 |
+
file_downloaded = 0
|
| 648 |
+
traj_downloaded = 0
|
| 649 |
+
task_name = ws.title.split(" - ")[-1]
|
| 650 |
+
if task_name in task_list:
|
| 651 |
+
task_id = TASK_NAMES_TO_INDICES[task_name]
|
| 652 |
+
all_rows = ws.get_all_values()
|
| 653 |
+
for row in all_rows[1:]:
|
| 654 |
+
if row and int(row[1]) == 0: # We download a maximum of one trajectory for each task instance id
|
| 655 |
+
resource_uuid = row[2]
|
| 656 |
+
instance_id = int(row[0])
|
| 657 |
+
# check whether raw file already exists
|
| 658 |
+
if not os.path.exists(
|
| 659 |
+
os.path.join(
|
| 660 |
+
data_dir, "raw", f"task-{task_id:04d}", f"episode_{task_id:04d}{instance_id:03d}0.hdf5"
|
| 661 |
+
)
|
| 662 |
+
):
|
| 663 |
+
url = get_urls_from_lightwheel([resource_uuid], lightwheel_api_credentials, lw_token=lw_token)[
|
| 664 |
+
0
|
| 665 |
+
]
|
| 666 |
+
try:
|
| 667 |
+
download_and_extract_data(url, data_dir, task_name, instance_id, 0)
|
| 668 |
+
file_downloaded += 1
|
| 669 |
+
traj_downloaded += 1
|
| 670 |
+
except AssertionError as e:
|
| 671 |
+
print(
|
| 672 |
+
f"Error downloading or extracting data for {task_name} resource uuid {resource_uuid}: {e}"
|
| 673 |
+
)
|
| 674 |
+
else:
|
| 675 |
+
traj_downloaded += 1
|
| 676 |
+
if traj_downloaded >= max_traj_per_task:
|
| 677 |
+
break
|
| 678 |
+
time.sleep(1)
|
| 679 |
+
|
| 680 |
+
print(f"Finished processing task: {ws.title}, {file_downloaded} files downloaded.")
|
| 681 |
+
|
| 682 |
+
print("All tasks processed.")
|
| 683 |
+
|
| 684 |
+
|
| 685 |
+
def is_more_than_x_hours_ago(dt_str, x, fmt="%Y-%m-%d %H:%M:%S"):
|
| 686 |
+
dt = datetime.strptime(dt_str, fmt)
|
| 687 |
+
diff_hours = (datetime.now() - dt).total_seconds() / 3600
|
| 688 |
+
return diff_hours > x
|
| 689 |
+
|
| 690 |
+
|
| 691 |
+
def update_tracking_sheet(
|
| 692 |
+
credentials_path: str = "~/Documents/credentials", max_entries_per_task: Optional[int] = None
|
| 693 |
+
) -> None:
|
| 694 |
+
"""
|
| 695 |
+
[Internal use only] Updates the tracking sheet with the latest information from lightwheel.
|
| 696 |
+
Args:
|
| 697 |
+
credentials_path (str): The path to the credentials file.
|
| 698 |
+
max_entries_per_task (Optional[int]): The maximum number of entries to process per task.
|
| 699 |
+
"""
|
| 700 |
+
import gspread
|
| 701 |
+
|
| 702 |
+
assert getpass.getuser() in VALID_USER_NAME, f"Invalid user {getpass.getuser()}"
|
| 703 |
+
gc, lightwheel_api_credentials, lw_token = get_credentials(credentials_path)
|
| 704 |
+
spreadsheet = gc.open("B1K Challenge 2025 Data Replay Tracking Sheet")
|
| 705 |
+
# Update main sheet
|
| 706 |
+
main_worksheet = spreadsheet.worksheet("Main")
|
| 707 |
+
main_worksheet.update(range_name="A5:A5", values=[[f"Last updated: {time.strftime('%Y-%m-%d %H:%M:%S')}"]])
|
| 708 |
+
|
| 709 |
+
for task_name, task_index in tqdm(TASK_NAMES_TO_INDICES.items()):
|
| 710 |
+
worksheet_name = f"{task_index} - {task_name}"
|
| 711 |
+
# Get or create the worksheet
|
| 712 |
+
try:
|
| 713 |
+
task_worksheet = spreadsheet.worksheet(worksheet_name)
|
| 714 |
+
except gspread.exceptions.WorksheetNotFound:
|
| 715 |
+
task_worksheet = spreadsheet.add_worksheet(title=worksheet_name, rows="1", cols="8")
|
| 716 |
+
header = [
|
| 717 |
+
"Instance ID",
|
| 718 |
+
"Traj ID",
|
| 719 |
+
"Resource UUID",
|
| 720 |
+
"Timestamp",
|
| 721 |
+
"Status",
|
| 722 |
+
"Worker ID",
|
| 723 |
+
"Last Updated",
|
| 724 |
+
"Misc",
|
| 725 |
+
]
|
| 726 |
+
task_worksheet.update(range_name="A1:H1", values=[header])
|
| 727 |
+
|
| 728 |
+
# Get all ids from lightwheel
|
| 729 |
+
lw_ids = get_all_instance_id_for_task(lw_token, lightwheel_api_credentials, task_name)
|
| 730 |
+
|
| 731 |
+
# Get all resource uuids
|
| 732 |
+
rows = task_worksheet.get_all_values()
|
| 733 |
+
if len(rows) != len(lw_ids) + 1:
|
| 734 |
+
print(f"Row count mismatch for task {task_name}: {len(rows)} != {len(lw_ids) + 1}")
|
| 735 |
+
resource_uuids = set(row[2] for row in rows[1:] if len(row) > 2)
|
| 736 |
+
counter = Counter(row[0] for row in rows[1:] if len(row) > 0)
|
| 737 |
+
for lw_id in lw_ids:
|
| 738 |
+
num_entries = task_worksheet.row_count - 1
|
| 739 |
+
if max_entries_per_task is not None and num_entries >= max_entries_per_task:
|
| 740 |
+
break
|
| 741 |
+
if lw_id[1] not in resource_uuids:
|
| 742 |
+
url = get_urls_from_lightwheel([lw_id[1]], lightwheel_api_credentials, lw_token)
|
| 743 |
+
timestamp = str(get_timestamp_from_lightwheel(url)[0])
|
| 744 |
+
# append new row with unprocessed status
|
| 745 |
+
new_row = [
|
| 746 |
+
lw_id[0],
|
| 747 |
+
counter[lw_id[0]],
|
| 748 |
+
lw_id[1],
|
| 749 |
+
timestamp,
|
| 750 |
+
"unprocessed",
|
| 751 |
+
"",
|
| 752 |
+
time.strftime("%Y-%m-%d %H:%M:%S"),
|
| 753 |
+
"",
|
| 754 |
+
]
|
| 755 |
+
task_worksheet.append_row(new_row, value_input_option="USER_ENTERED")
|
| 756 |
+
counter[lw_id[0]] += 1
|
| 757 |
+
# rate limit
|
| 758 |
+
time.sleep(1)
|
| 759 |
+
# now iterate through entires and find failure ones
|
| 760 |
+
for row_idx, row in enumerate(rows[1:], start=2):
|
| 761 |
+
hours_to_check = 24
|
| 762 |
+
if row and row[4].strip().lower() == "pending" and is_more_than_x_hours_ago(row[6], hours_to_check):
|
| 763 |
+
print(
|
| 764 |
+
f"Row {row_idx} in {worksheet_name} is pending for more than {hours_to_check} hours, marking as failed."
|
| 765 |
+
)
|
| 766 |
+
# change row[4] to failed and append 'a' to row[7]
|
| 767 |
+
task_worksheet.update(
|
| 768 |
+
range_name=f"E{row_idx}:H{row_idx}",
|
| 769 |
+
values=[["failed", row[5].strip(), time.strftime("%Y-%m-%d %H:%M:%S"), row[7].strip() + "a"]],
|
| 770 |
+
)
|
| 771 |
+
time.sleep(1) # rate limit
|
| 772 |
+
# rate limit
|
| 773 |
+
time.sleep(1)
|
| 774 |
+
print(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] All tasks updated successfully.")
|
| 775 |
+
|
| 776 |
+
|
| 777 |
+
if __name__ == "__main__":
|
| 778 |
+
# check_leaf_folders_have_n("~/behavior", 200)
|
| 779 |
+
# gc = get_credentials("~/Documents/credentials")[0]
|
| 780 |
+
# tracking_spreadsheet = gc.open("B1K Challenge 2025 Data Replay Tracking Sheet")
|
| 781 |
+
# misc_sheet = gc.open("B50 Task Misc")
|
| 782 |
+
# misc_ws = misc_sheet.worksheet("Test Instances")
|
| 783 |
+
# misc_values = misc_ws.get_all_values()
|
| 784 |
+
# for task_name, task_index in tqdm(TASK_NAMES_TO_INDICES.items()):
|
| 785 |
+
# task_ws = tracking_spreadsheet.worksheet(f"{task_index} - {task_name}")
|
| 786 |
+
# assign_test_instances(task_ws, misc_ws, misc_values)
|
| 787 |
+
# time.sleep(1)
|
| 788 |
+
# extract_annotations(
|
| 789 |
+
# "/scr/behavior/2025-challenge-demos", "/home/svl/Downloads/annotations", remove_memory_prefix=True
|
| 790 |
+
# )
|
| 791 |
+
og.shutdown()
|