Skip to content

Commit

Permalink
Release/3.0.0 (#168)
Browse files Browse the repository at this point in the history
* dockerizing filetao; Add envars to 'docs/docker/run-filetao-with-docker.md'

* dockerizing filetao; Use full path for miner data volume

* dockerizing filetao; Allowing to use non-default port for Redis

* dockerizing filetao; removing unnecessary volume

* Fixed wallet creation in user registration.

* dockerizing filetao; improving redis container for non-default port

* dockerizing filetao; improving redis container for non-default port

* updating 'check_environment' function and adapting code

* Wallet generation fixes.

* remove unused code, add mnemonic

* add redis db, singleton server wallet

* Added Procfile, gitignore and runtime.txt for launching app on Heroku.

* Fix dependency conflict in requirements.txt

* Fix additional dependency conflict in requirements.txt

* Fix fastapi bittensor dependency conflict in requirements.txt

* Fix fastapi uvicorn dependency conflict in requirements.txt

* FastAPI slug too large. Updated webdev gitignore to match main repo.

* FastAPI slug too large. Added api, cli, miner, shared, validator, tests to gitignore.

* Added django frontend & set everything up

* support py311

* add scripts and dereg script to docker image

* return str from get_block_seed error

* Added FileResponse to retrieve_data() for client file download.

* update reamde for 3.11 support

* update names from database

* fix import from storage for API

* install torc-cpu first so we override bittensor req to use cuda

* update to test and import fixes in main, add hotkeys for db

* set min priority for hotkeys not registered to SN21

* add metagraph check for updating cached

* fix bug in get_reids_size rm await

* add convenience data getters for validator

* add tier statistics calc

* add tmp scratch

* remove save check, no longer turned on by default

* Updated requirements.txt for heroku slug build. Installing torch cpu before bittensor.

* Fixed package version conflict between bittensor and fastapi.

* Fixed package version conflict between bittensor and uvicorn.

* Added PYTHONPATH=/app to Procfile. Fix for storage import.

* Updated requirements.txt with filetao. Prep for heroku deployment.

* Pushed Procfile to top level.

* Fixed entry point in Procfile.

* Fixed database import in main.py

* Added redis env vars to database.py

* Updated env var REDIS_DB to string

* Updated env var REDIS_PORT to string

* Updated env var REDIS_HOST

* Updated get_database with Heroku provided REDIS_URL

* update database, fix improper scan_iter usage and add totalreqs

* bugfix and add inverted dict for tier stats

* add wandb project link to readme

* return proper dict, add compute by tier stats

* add updated sql queries

* add testnet blurb

* fix sql command to add data to network table

* Added bcrypt library to requirements.txt to fix generate_seed() in main.py

* Update database.py

* Added env var ACCESS_TOKEN_EXPIRE_MINUTES to main.py

* Changed env var ACCESS_TOKEN_EXPIRE_MINUTES type to str

* Added ALGORITHM to env var in main.py

* version 3

* use get for missing values

* fix perms

* fix perms

* version bump

* handle case of no successful responses

* update API to store hotkey metadata and pull from when retrieving

* check for uid in monitor lookup

* add hotkeys missing arg in retrieve

* add missing imports

* add pwd context crypt

* except when mnemonic fails to generate

* open access for priority also

* return hotkeys

* get proper return from upload, use test.txt filename

* get metagraph to fetch hotkeys from metadata

* fix api retrieve priority for open access

* fix retrieve

* fix test for retrieve

* print new return values

* readme blurb for docker

* add getters for dict obj in tier stats comp

* use x- alias instead of dummy service in docker-compose.yml

* dont build custom redis docker image

* remove dummy filetao service

* remove -prod postfix and container_name from docker-compose to make it easier to setup multiple instances

* optimize dockerfile & docker-compose.yml config

* docker-compose fixes, more ENV options, and make some truely optional

* use python3.11 in docker for extra speed boost

* modify metadata schema to be more useful, add endpoints

* convert metadata schema, add convenience endpoints for metadata

* Added changes to include redis password

* use imported bittensor

* update API to return first successful parallel query

* detour dendrite for more accurate time

* drop REDIS_CONF env var as there is no need for it anymore

* further simplify dockerized setup

* Begin indexer for api neuron

* Make api folder a module

* Fix imports

* Fix import

* Rename api helpers to indexer

* Fix endpoint import

* Fix import one more time for indexer.endpoint

* set proc time after processing synapse

* Fix majority of issues in indexer

* refactor redis to separate file

* Sqlite dont check for thread safety

* Wait before collecting data in indexer, refactor endpoint to pull from database

* Remove unused code

* (WIP) add delete to subnet, add delet endpoint to backend

* return 400 for file already exists with store

* Added CORS to Fast API. Also made changes to accommodate Redis password. Added env.example

* Fix timing with neuron creation and indexer thread start, store incentive in HotkeysTable

* update excluse list properly in ping uids

* http 422 error on file exists in upload_file

* decrease variance slightly on sigm normalization

* replace sub handler hotkey

* readme updates

* low-level api demo notebook

* fix metadata overwrite issue, mirror dropbox behavior

* import fix rename_file and delete_cid_meta

* import DeleteUser

* cancel extra tasks in api to not linger

* add retry mechanism to api

* correct typos

* mark all miner errors with non-200 status codes

* (WIP) expanded tier set

* allow skipping Redis checks

* fix type annotation breaking under py39

* Update readme to reflect rewards, storage constants

* Update main.py

Update generate cid args to use raw data bytes.

* Update main.py

Add bool for whether or not to increment file count when uploading (or overwriting)

* Update database.py

Add bool for incrementing file count in metdata func

* Update main.py

Actually still incr

* redis pw warning if not found, don't exit

* error -> warning for redis pw

* add config to redis init

* pass on non-registered miners (old)

* skip attempt to index if no cap data found

* Update config.py

* Update base.py

* Update store.py

* Update retrieve.py

* Update store_api.py

* Update retrieve_api.py

* Update challenge.py

* redis pw warning if not found, don't exit

* error -> warning for redis pw

* update fastapi req

* use torch cpu if desired in instructions

* add readme for backend

* typo fix

* change -> filename_exists()

* remove webdev reqs, update pycryptodome

* remove test txt

* remove comment

* blurb about extend use

* remove bittensor type hint for lint

* update bittensor version and indexer import struct

* add loguru now that bittensor>611 doesn't use it

* typo

* need pandas

* need bigger than BIGINT for storage value

* convert network cap and usage to mb for BIGINT fitting

* convert all storage usage/cap values to MB

* typo

* ensure data directory is created

* max chunk size 512 -> 256

* use mainnet finney

* update DELETE methods

* refactor data cap

* udpate readme to new storage caps

* readme fix for tier advance calc

* constants fix, adjust wilson

* avoid div/0 err

* default to finney

* Added check to see if user is over storage limit when uploading file.

* bespoke blacklist for delete

* proper synapse

* Fix max user storage in backend

* Fix argparse argument definition for api.whitelisted_hotkeys

* nargs fix2

* allow whitelisted priority

* Fix deletion functionality in backend

* Fix delete_user_data not passing user wallet to delete api

* Fix user wallet retrieval in delete file api

* select max 3 valis at a time in backend

* Remove axons/uids argument from delete api call

* Fix import error for random library

* Iterate over list in delete_user_data and check encryption

* Add debug print to delete_user_data metadata

* Change print func for debug to bt logging

* Start axon even if serving fails

* Disable call to deleting file on miner

* speed up indexer and remove non-registered hotkeys from consideration

* convert cap and usage to MB in tier calc

* structure output

* fix delete payload

* reenable delete in backend

* proper update UserInDB storage value

* Remove debug print outputting all data from retrieved file

* cleanup delete api

* fix tier stats to use MB instead of bytes

* Bugfix/cli testing fixes (#186)

* Removed await for function returning None

* Argparse moved to outside async main to prevent unhandled exception from polluting stdout

* Reverted missing await for run command. Need to investigate where Nonetype is being produced.

* Some formatting updates to docker section for readme

* add uid(s) arg for store/retrieve

* Add indexer endpoint for hotkey-specific data

* Fix double function name definition

* Fix get_specific_miner_stats route

* Remove apirouter definition

* Make start_time, end_time optional args with defaults of an hour, add offset argument

* Return empty array if query returns None

* Fix order by addition to sqlite queries

* fix store priority for whitelist

* remove print

* default whitelist key update

* Add total subnet emission to network stats table

* Add frontend whitelist back to default whitelisted hotkeys

* Change out wrong whitelisted hotkey

* add reamde to frontend

* Fix wrong hotkey in default whitelist

* Add hotkey emission to indexer database

* Add emission to indexer endpoint api

* removing the delete from storage at the moment. Taking way too long to process.

---------

Co-authored-by: eduardo <[email protected]>
Co-authored-by: Joshua Johnson <[email protected]>
Co-authored-by: Saevitus0 <[email protected]>
Co-authored-by: Maciej Urbanski <[email protected]>
Co-authored-by: peterbcarlson41 <[email protected]>
Co-authored-by: Ayden Brewer <[email protected]>
  • Loading branch information
7 people authored Apr 30, 2024
1 parent b92052e commit def46f8
Show file tree
Hide file tree
Showing 80 changed files with 4,464 additions and 394 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/*.env
**/.git
**/.github
**/.gitignore
**/.venv
**/__pycache__
8 changes: 6 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ name: Python package

on:
push:
branches: [ "main" ]
branches:
- main
pull_request:
branches: [ "main", "staging", "release/.*" ]
branches:
- main
- staging
- release/*

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ celerybeat.pid

# Environments
.env
**/*.env
.venv
env/
venv/
Expand Down
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
## 1.3.3 / 2024-01-18

## What's Changed
* Hotfix/validator subscrition handler by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/90
* Hotfix/validator subscription handler by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/90


**Full Changelog**: https://github.com/ifrit98/storage-subnet/commits/v1.3.3
Expand Down Expand Up @@ -389,7 +389,7 @@
* Release/1.1.1 by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/43
* hotfix challenge adjustment and reduce rewards vector size by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/47
* Validator fix block hash selection by @Rubberbandits in https://github.com/ifrit98/storage-subnet/pull/48
* Exploring storage/miner/run and setting weights logic. Enhacing logic to control more scenarios by @eduardogr in https://github.com/ifrit98/storage-subnet/pull/51
* Exploring storage/miner/run and setting weights logic. Enhancing logic to control more scenarios by @eduardogr in https://github.com/ifrit98/storage-subnet/pull/51
* Release/1.2.0 by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/53
* update to sigmoid reward scaling for latency by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/64
* Release/1.2.1 by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/67
Expand Down Expand Up @@ -425,7 +425,7 @@
## What's Changed
* hotfix challenge adjustment and reduce rewards vector size by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/47
* Validator fix block hash selection by @Rubberbandits in https://github.com/ifrit98/storage-subnet/pull/48
* Exploring storage/miner/run and setting weights logic. Enhacing logic to control more scenarios by @eduardogr in https://github.com/ifrit98/storage-subnet/pull/51
* Exploring storage/miner/run and setting weights logic. Enhancing logic to control more scenarios by @eduardogr in https://github.com/ifrit98/storage-subnet/pull/51
* Package by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/49
* Improve miner stats visibility in logging by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/44
* add migration script and database func to move filepaths of data index by @ifrit98 in https://github.com/ifrit98/storage-subnet/pull/50
Expand All @@ -451,5 +451,5 @@
* Fix broken imports and some typos
* up ping timeout limit, caused issues with incorrectly flagging UIDs as down
* bugfix in verify store with miners no longer returning data, verify on validator side with seed
* incresae challenge timeout
* increase challenge timeout
* update version key
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
ARG BASE_IMAGE=python:3.11-slim
FROM $BASE_IMAGE AS builder

# Set a non-interactive frontend to avoid any interactive prompts during the build
ARG DEBIAN_FRONTEND=noninteractive

# Create directory to copy files to
RUN mkdir -p /source/ /opt/filetao/
WORKDIR /source

# Install dependencies first, so source code changes don't invalidate the build cache
COPY requirements.txt /source/
RUN --mount=type=cache,target=/root/.cache/ \
python -m pip install --prefix=/opt/filetao -r requirements.txt

COPY ./README.md ./setup.py ./requirements-dev.txt /source/
COPY ./neurons /source/neurons
COPY ./storage /source/storage
RUN python -m pip install --prefix=/opt/filetao --no-deps .

# symlink lib/pythonVERSION to lib/python so path doesn't need to be hardcoded
RUN ln -rs /opt/filetao/lib/python* /opt/filetao/lib/python
COPY ./bin /opt/filetao/bin
COPY ./scripts /opt/filetao/scripts

FROM $BASE_IMAGE AS filetao

RUN mkdir -p ~/.bittensor/wallets && \
mkdir -p /etc/redis/

COPY --from=builder /opt/filetao /opt/filetao

ENV PATH="/opt/filetao/bin:${PATH}"
ENV LD_LIBRARY_PATH="/opt/filetao/lib:${LD_LIBRARY_PATH}"
ENV REBALANCE_SCRIPT_PATH=/opt/filetao/scripts/rebalance_deregistration.sh
ENV PYTHONPATH="/opt/filetao/lib/python/site-packages/:${PYTHONPATH}"

ENTRYPOINT ["/opt/filetao/scripts/docker/entrypoint.sh"]
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

web: PYTHONPATH=/app uvicorn webdev.main:app --host=0.0.0.0 --port=${PORT:-5000}
300 changes: 148 additions & 152 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
3.0.0
152 changes: 152 additions & 0 deletions config/redis-docker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf

bind 0.0.0.0

protected-mode yes

port 6379

requirepass CHANGEME4321

tcp-backlog 511

timeout 0

tcp-keepalive 300

daemonize no

supervised auto

pidfile /run/redis/redis-server.pid

loglevel notice

databases 16

always-show-logo no

set-proc-title yes

proc-title-template "{title} {listen-addr} {server-mode}"

locale-collate ""

#
#save 900 1
#save 300 10
#save 60 10000
#
# Snapshotting can be completely disabled with a single empty string argument
# as in following example:
#
save ""

stop-writes-on-bgsave-error yes

rdbcompression yes
rdbchecksum yes

# The filename where to dump the DB
dbfilename dump.rdb

rdb-del-sync-files no

dir /data

replica-serve-stale-data yes

replica-read-only yes
repl-diskless-sync yes
repl-diskless-sync-delay 5
repl-diskless-sync-max-replicas 0

repl-diskless-load disabled
repl-disable-tcp-nodelay no

replica-priority 100

acllog-max-len 128

lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no

lazyfree-lazy-user-del no

lazyfree-lazy-user-flush no

oom-score-adj no
oom-score-adj-values 0 200 800

disable-thp yes

appendonly yes

appendfilename "appendonly.aof"
appenddirname "appendonlydir"

# appendfsync always
appendfsync everysec
# appendfsync no

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

aof-load-truncated yes

aof-use-rdb-preamble yes

aof-timestamp-enabled no

slowlog-log-slower-than 10000

slowlog-max-len 128

latency-monitor-threshold 0

notify-keyspace-events ""

hash-max-listpack-entries 512
hash-max-listpack-value 64

list-max-listpack-size -2

list-compress-depth 0

set-max-intset-entries 512

set-max-listpack-entries 128
set-max-listpack-value 64

zset-max-listpack-entries 128
zset-max-listpack-value 64

hll-sparse-max-bytes 3000

stream-node-max-bytes 4096
stream-node-max-entries 100

activerehashing yes

client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

dynamic-hz yes

aof-rewrite-incremental-fsync yes

rdb-save-incremental-fsync yes

jemalloc-bg-thread yes
72 changes: 72 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
volumes:
redis-prod-data:
name: "filetao-redis-data"

x-filetao: &filetao
image: filetao
build:
context: .
dockerfile: Dockerfile
restart: always
depends_on:
redis:
condition: service_healthy
volumes:
- ${BT_WALLETS_PATH}:/root/.bittensor/wallets
- ./scripts:/install/scripts
env_file:
- .env
network_mode: host

services:
filetao-miner:
<<: *filetao
volumes:
- ${BT_WALLETS_PATH}:/root/.bittensor/wallets
- ${FILETAO_MINER_DATA_DIR}:/root/.data/
environment:
- FILETAO_NODE=miner
env_file:
- .env
- path: filetao-miner.env
required: false

filetao-validator:
<<: *filetao
depends_on:
filetao-api:
condition: service_started
environment:
- FILETAO_NODE=validator
env_file:
- .env
- path: filetao-validator.env
required: false

filetao-api:
<<: *filetao
environment:
- FILETAO_NODE=api
env_file:
- .env
- path: filetao-api.env
required: false

redis:
image: redis:7.2.4-alpine
restart: always
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "--raw", "incr", "ping"]
interval: 1s
timeout: 3s
retries: 5
command:
- redis-server
- /etc/redis/redis.conf
- --requirepass
- ${REDIS_PASSWORD}
ports:
- "${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}:6379"
volumes:
- redis-prod-data:/data
- ./redis/redis.conf:/etc/redis/redis.conf
Loading

0 comments on commit def46f8

Please sign in to comment.