Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

WIP: feat: testing things #85

Closed
wants to merge 23 commits into from
4 changes: 4 additions & 0 deletions .github/workflow_event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"event_name": "push",
"ref": "refs/heads/main"
}
43 changes: 43 additions & 0 deletions .github/workflows/cloudflare-miner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Deploy to DigitalOcean

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Create .env file
run: |
touch subnet/miner-cloudflare/.env
echo SERVICE_MESH_SECRET_KEY=${{ secrets.SERVICE_MESH_SECRET_KEY }} >> ./subnet/miner-cloudflare/.env
echo CLOUDFLARE_AUTH_TOKEN=${{ secrets.CLOUDFLARE_AUTH_TOKEN }} >> ./subnet/miner-cloudflare/.env
echo CLOUDFLARE_ACCOUNT_ID=${{ secrets.CLOUDFLARE_ACCOUNT_ID }} >> ./subnet/miner-cloudflare/.env
echo MINER_ADDRESS=${{ secrets.MINER_ADDRESS }} >> ./subnet/miner-cloudflare/.env
echo UUID=${{ secrets.CLOUDFLARE_MINER_TEST_ID }} >> ./subnet/miner-cloudflare/.env
echo SERVICE_MESH_URL=${{ secrets.SERVICE_MESH_URL }} >> ./subnet/miner-cloudflare/.env
echo API_ONLY=${{ secrets.CLOUDFLARE_MINER_API_ONLY }} >> ./subnet/miner-cloudflare/.env

- name: Build Docker Image
run: docker build -t cloudflare-miner ./subnet/miner-cloudflare/

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push Docker Image to GitHub Container Registry
run: |
IMAGE_TAG=ghcr.io/${GITHUB_REPOSITORY,,}/cloudflare-miner:${{ github.sha }}
docker tag cloudflare-miner $IMAGE_TAG
docker push $IMAGE_TAG
12 changes: 12 additions & 0 deletions subnet/miner-cloudflare/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.10-slim

WORKDIR /code

COPY . /code
# COPY ./requirements.txt /code/requirements.txt
# COPY ./setup.py /code/setup.py

RUN python -m pip install -e .


CMD ["python", "main.py"]
2 changes: 1 addition & 1 deletion subnet/miner-cloudflare/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ async def chat(request: ChatRequest):

if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=os.getenv('PORT', 9000))
uvicorn.run(app, host="0.0.0.0", port=os.getenv('PORT', 8080))
1 change: 0 additions & 1 deletion subnet/miner-cloudflare/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
bittensor
torch
flask
pydantic
python-dotenv
simplejson
Expand Down
6 changes: 3 additions & 3 deletions subnet/miner-cloudflare/stream_miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, config=None, axon=None, wallet=None, subtensor=None):
self.miner_services = {
"type": 'cloudflare',
"models": ['llama-2-7b-chat-int8', 'mistral-7b-instruct-v0.1'],
"address": os.getenv('ADDRESS')
"MINER_ADDRESS": os.getenv('MINER_ADDRESS')
}

check_config(StreamMiner, self.config)
Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(self, config=None, axon=None, wallet=None, subtensor=None):

# TODO replace with hosted endpoint of service map
url = os.getenv('SERVICE_MESH_URL')
secret = os.getenv('SECRET_KEY')
secret = os.getenv('SERVICE_MESH_SECRET_KEY')
# for now miners are allow listed manually and given a secret key to identify
headers = {'Content-Type': 'application/json',
'Authorization': f'Bearer {secret}'}
Expand All @@ -104,7 +104,7 @@ def __init__(self, config=None, axon=None, wallet=None, subtensor=None):
else:
self.uuid = os.getenv('UUID') or uuid.uuid4()
url = os.getenv('SERVICE_MESH_URL')
secret = os.getenv('SECRET_KEY')
secret = os.getenv('SERVICE_MESH_SECRET_KEY')
# for now miners are allow listed manually and given a secret key to identify
headers = {'Content-Type': 'application/json',
'Authorization': f'Bearer {secret}'}
Expand Down
Loading