Skip to content

Commit

Permalink
added container runner script
Browse files Browse the repository at this point in the history
  • Loading branch information
yk committed Mar 15, 2023
1 parent 840d97e commit 3bd4776
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions inference/worker/__main__.py
Expand Up @@ -39,11 +39,12 @@ def main():
logger.error(f"Bad status: {e.status_code=} {str(e)=}")
logger.error("Did you provide the correct API key?")
logger.error("Try upgrading the worker to get the latest protocol version")
signal.signal(signal.SIGINT, signal.SIG_DFL)
break
raise
except Exception:
logger.exception("Error in websocket")
logger.info("Retrying in 5 seconds...")
if not settings.retry_on_error:
sys.exit(1)
time.sleep(5)


Expand Down
16 changes: 16 additions & 0 deletions inference/worker/run_worker_container.sh
@@ -0,0 +1,16 @@
#!/bin/bash

function cleanup {
echo "Stopping script"
exit 0
}

# Set up a trap to catch the SIGINT signal (Ctrl+C) and call the cleanup function
trap cleanup SIGINT

image_name="ghcr.io/laion-ai/open-assistant/oasst-inference-worker-full:latest"

while true; do
docker pull $image_name
docker run --rm -it -e retry_on_error=False $image_name
done
2 changes: 2 additions & 0 deletions inference/worker/settings.py
Expand Up @@ -16,5 +16,7 @@ class Settings(pydantic.BaseSettings):
"Assistant: Hello! How can I help you today?\n"
)

retry_on_error: bool = True


settings = Settings()

0 comments on commit 3bd4776

Please sign in to comment.