Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving docs, fixing settings #514

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .env.api.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
API_PORT = "8005"
API_HOST = "0.0.0.0"
# SCORING_KEY = "YOUR_SCORING_API_KEY_GOES_HERE"
API_PORT = "42170" # Port for the API server
API_HOST = "0.0.0.0" # Host for the API server
SCORING_KEY = "123" # The scoring key for the validator (must match the scoring key in the .env.validator file)
SCORE_ORGANICS = True # Whether to score organics
VALIDATOR_API = "0.0.0.0:8094" # The validator API to forward responses to for scoring
12 changes: 12 additions & 0 deletions api.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
apps: [
{
name: 'api_server',
script: 'poetry',
interpreter: 'none',
args: ['run', 'python', 'validator_api/api.py'],
min_uptime: '5m',
max_restarts: 5
}
]
};
2 changes: 1 addition & 1 deletion api_keys.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
2 changes: 1 addition & 1 deletion run_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ echo "module.exports = {
name: 'api_server',
script: 'poetry',
interpreter: 'none',
args: ['run', 'python', 'api/api.py'],
args: ['run', 'python', 'validator_api/api.py'],
min_uptime: '5m',
max_restarts: 5
}
Expand Down
27 changes: 0 additions & 27 deletions shared/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def load(cls, mode: Literal["miner", "validator", "mock", "api"]) -> "SharedSett
def complete_settings(cls, values: dict[str, Any]) -> dict[str, Any]:
mode = values["mode"]
netuid = values.get("NETUID", 61)

if netuid is None:
raise ValueError("NETUID must be specified")
values["TEST"] = netuid != 1
Expand All @@ -224,32 +223,6 @@ def complete_settings(cls, values: dict[str, Any]) -> dict[str, Any]:
logger.info("Running in mock mode. Bittensor objects will not be initialized.")
return values

# load slow packages only if not in mock mode
import torch

if not values.get("NEURON_DEVICE"):
values["NEURON_DEVICE"] = "cuda" if torch.cuda.is_available() else "cpu"

# Ensure SAVE_PATH exists.
save_path = values.get("SAVE_PATH", "./storage")
if not os.path.exists(save_path):
os.makedirs(save_path)
if values.get("SN19_API_KEY") is None or values.get("SN19_API_URL") is None:
logger.warning(
"It is strongly recommended to provide an SN19 API KEY + URL to avoid incurring OpenAI API costs."
)
if mode == "validator":
if values.get("OPENAI_API_KEY") is None:
raise Exception(
"You must provide an OpenAI API key as a backup. It is recommended to also provide an SN19 API key + url to avoid incurring API costs."
)
if values.get("SCORING_ADMIN_KEY") is None and values.get("DEPLOY_SCORING_API"):
logger.warning("You must provide a SCORING_ADMIN_KEY to access the API. Disabling scoring endpoint")
values["DEPLOY_SCORING_API"] = False
if values.get("PROXY_URL") is None:
logger.warning(
"You must provide a proxy URL to use the DuckDuckGo API - your vtrust might decrease if no DDG URL is provided."
)
return values

@cached_property
Expand Down
9 changes: 7 additions & 2 deletions validator_api/API_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ This document describes the API endpoints available for [Subnet 1](https://githu

## Getting Started

Follow these steps to set up and run the API server:
SN1 can run either in validator mode or in API mode. Both modes will require the validator hotkey.

As a validator, you MUST be running one instance in validator mode and can launch an arbitrary number of API instances. These API instances will proxy the responses from miners to the validator for scoring.

To set up and run the API server:

1. **Install dependencies**: Ensure all required dependencies are installed using Poetry.
2. **Run the API server**: Start the server to access the API endpoints.
2. **Set up the .env.api file**: Copy the .env.api.example file to .env.api and fill in the validator hotkey.
3. **Run the API server**: Start the server to access the API endpoints.

Use the following command:

Expand Down
Loading