Skip to content

Commit

Permalink
Merge pull request #3 from allora-network/diego/ora-1199-coin-predict…
Browse files Browse the repository at this point in the history
…ion-reputer-deployment-for-devnet

Minor fixes and README
  • Loading branch information
xmariachi authored Apr 13, 2024
2 parents 0ce34bb + fb009b2 commit 3f480d3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ logs/*
worker-data
head-data
truth-data
prices.db
2 changes: 1 addition & 1 deletion Dockerfile_b7s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 alloranetwork/allora-inference-base:latest
FROM --platform=linux/amd64 allora-inference-base:dev-latest

USER root
RUN pip install requests
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The `Dockerfile_b7s` file is functional but simple, so you may want to change it

For further details, please check the base repo [allora-inference-base](https://github.com/allora-network/allora-inference-base).

Note: The reputers use an internal blockless topic adding the suffix `/reputer` to be added to the `--topic` flag, but not to the `--allora-chain-topic-id`.

### Application path

By default, the application runtime lives under `/app`, as well as the Python code the worker provides (`/app/main.py`). The current user needs to have write permissions on `/app/runtime`.
Expand Down
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def update_price(token_name, token_from, token_to):
return jsonify({'error': 'Invalid token ID'}), 400

timestamp = int(datetime.now().timestamp())
token = token_name.upper()
token = token_name.lower()

# Save price into database
conn = sqlite3.connect(DATABASE_PATH)
Expand Down Expand Up @@ -84,7 +84,7 @@ def init_price_token(token_name, token_from, token_to):
# Check if there is any existing data for the specified token
conn = sqlite3.connect(DATABASE_PATH)
cursor = conn.cursor()
cursor.execute("SELECT COUNT(*) FROM prices WHERE token=? LIMIT 1", (token_name.upper(),))
cursor.execute("SELECT COUNT(*) FROM prices WHERE token=? LIMIT 1", (token_name.lower(),))
count = cursor.fetchone()[0]
conn.close()

Expand All @@ -111,7 +111,7 @@ def init_price_token(token_name, token_from, token_to):
for data_point in historical_data:
timestamp = int(data_point[0] / 1000) # Convert milliseconds to seconds
price = data_point[1]
cursor.execute("INSERT INTO prices (timestamp, token, price) VALUES (?, ?, ?)", (timestamp, token_name.upper(), price))
cursor.execute("INSERT INTO prices (timestamp, token, price) VALUES (?, ?, ?)", (timestamp, token_name.lower(), price))
print(f"inserting data point {timestamp} : {price}" )
conn.commit()
conn.close()
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:
--runtime-path=/app/runtime --runtime-cli=bls-runtime --workspace=/data/workspace \
--private-key=/data/keys/priv.bin --log-level=debug --port=9011 \
--boot-nodes=/ip4/172.20.0.100/tcp/9010/p2p/12D3KooWNbKMnvUWZ2e3Z5bm4GzSJht7SALzpW2MsS2CBKfXuFfK \
--topic=1
--topic=1/reputer
volumes:
- ./worker-data:/data
working_dir: /data
Expand Down

0 comments on commit 3f480d3

Please sign in to comment.