generated from runpod-workers/worker-template
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d9b5fc2
Showing
11 changed files
with
496 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: CD | Dev Docker Image | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clear Space | ||
run: | | ||
rm -rf /usr/share/dotnet | ||
rm -rf /opt/ghc | ||
rm -rf "/usr/local/share/boost" | ||
rm -rf "$AGENT_TOOLSDIRECTORY" | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Determine Docker tag | ||
id: docker-tag | ||
run: | | ||
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | ||
echo "DOCKER_TAG=dev" >> $GITHUB_ENV | ||
else | ||
echo "DOCKER_TAG=${{ github.sha }}" >> $GITHUB_ENV | ||
fi | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: ${{ vars.DOCKERHUB_REPO }}/${{ vars.DOCKERHUB_IMG }}:${{ env.DOCKER_TAG }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: CD | Release Docker Image | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clear Space | ||
run: | | ||
rm -rf /usr/share/dotnet | ||
rm -rf /opt/ghc | ||
rm -rf "/usr/local/share/boost" | ||
rm -rf "$AGENT_TOOLSDIRECTORY" | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
push: true | ||
tags: ${{ vars.DOCKERHUB_REPO }}/${{ vars.DOCKERHUB_IMG }}:${{ github.event.release.tag_name }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: CI | Update runpod package version | ||
|
||
on: | ||
repository_dispatch: | ||
types: [python-package-release] | ||
|
||
push: | ||
branches: ["main"] | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
check_dep: | ||
runs-on: ubuntu-latest | ||
name: Check python requirements file and update | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Check for new package version and update | ||
run: | | ||
# Get current version | ||
current_version=$(grep -oP 'runpod==\K[^"]+' ./builder/requirements.txt) | ||
# Get new version | ||
new_version=$(curl -s https://pypi.org/pypi/runpod/json | jq -r .info.version) | ||
echo "NEW_VERSION_ENV=$new_version" >> $GITHUB_ENV | ||
if [ -z "$new_version" ]; then | ||
echo "Failed to fetch the new version." | ||
exit 1 | ||
fi | ||
# Check if the version is already up-to-date | ||
if [ "$current_version" = "$new_version" ]; then | ||
echo "The package version is already up-to-date." | ||
exit 0 | ||
fi | ||
# Update requirements.txt | ||
sed -i "s/runpod==.*/runpod==$new_version/" ./builder/requirements.txt | ||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: Update package version | ||
title: Update runpod package version | ||
body: The package version has been updated to ${{ env.NEW_VERSION_ENV }} | ||
branch: runpod-package-update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: CI | Test Worker | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
initialize_worker: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
id: ${{ steps.extract_id.outputs.runpod_job_id }} | ||
|
||
steps: | ||
- name: Deploy Worker | ||
id: deploy | ||
uses: fjogeleit/http-request-action@v1 | ||
with: | ||
url: "https://api.runpod.ai/v2/${{ secrets.RUNPOD_ENDPOINT }}/run" | ||
method: "POST" | ||
customHeaders: '{"Content-Type": "application/json"}' | ||
bearerToken: ${{ secrets.RUNPOD_API_KEY }} | ||
data: '{"input":{"github_pat": "${{ secrets.GH_PAT }}", "github_org":"${{ secrets.GH_ORG }}"}}' | ||
|
||
- name: Extract Job ID | ||
id: extract_id | ||
run: | | ||
ID=$(echo '${{ steps.deploy.outputs.response }}' | jq -r '.id') | ||
echo "::set-output name=runpod_job_id::$ID" | ||
run_tests: | ||
needs: initialize_worker | ||
runs-on: runpod | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Python 3.11 & install dependencies | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r builder/requirements.txt | ||
- name: Execute Tests | ||
run: | | ||
python src/handler.py --test_input='{"input": "test"}' | ||
terminate_worker: | ||
if: ${{ always() && !success() }} | ||
needs: initialize_worker | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Shutdown Worker | ||
uses: fjogeleit/http-request-action@v1 | ||
with: | ||
url: "https://api.runpod.ai/v2/${{ secrets.RUNPOD_ENDPOINT }}/cancel/${{ needs.initialize_worker.outputs.id }}" | ||
method: "POST" | ||
customHeaders: '{"Content-Type": "application/json"}' | ||
bearerToken: ${{ secrets.RUNPOD_API_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Base image | ||
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04 | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# Use bash shell with pipefail option | ||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
# Set the working directory | ||
WORKDIR / | ||
|
||
# Update and upgrade the system packages (Worker Template) | ||
COPY builder/setup.sh /setup.sh | ||
RUN /bin/bash /setup.sh && \ | ||
rm /setup.sh | ||
|
||
# Install Python dependencies (Worker Template) | ||
COPY builder/requirements.txt /requirements.txt | ||
RUN python3 -m pip install --upgrade pip && \ | ||
python3 -m pip install --upgrade -r /requirements.txt --no-cache-dir && \ | ||
rm /requirements.txt | ||
|
||
# Add src files (Worker Template) | ||
ADD src . | ||
|
||
CMD python3 -u /handler.py |
Oops, something went wrong.