Skip to content

Commit

Permalink
replace hard-coded tournament numbers with api call
Browse files Browse the repository at this point in the history
  • Loading branch information
ndharasz committed Jul 1, 2024
1 parent fe4b718 commit fad168d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
8 changes: 1 addition & 7 deletions numerai/cli/constants.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Constants for Numerai CLI"""

import os
import json
from pathlib import Path

TOURNAMENT_NUMERAI = 8
TOURNAMENT_SIGNALS = 11
PACKAGE_PATH = os.path.dirname(__file__)
CONFIG_PATH = os.path.join(str(Path.home()), ".numerai")
KEYS_PATH = os.path.join(CONFIG_PATH, ".keys")
Expand Down Expand Up @@ -65,11 +64,6 @@
}

CONSTANTS_STR = f"""Default values (not your configured node values):
---Tournament Numbers---
TOURNAMENT_NUMERAI: {TOURNAMENT_NUMERAI}
TOURNAMENT_SIGNALS: {TOURNAMENT_SIGNALS}
---Paths---
PACKAGE_PATH: {PACKAGE_PATH}
CONFIG_PATH: {CONFIG_PATH}
Expand Down
32 changes: 18 additions & 14 deletions numerai/cli/node/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Init for node"""

import json
import logging
import click
Expand All @@ -15,22 +16,23 @@
# Setting azure's logging level "ERROR" to avoid spamming the terminal


def get_models(signals):
if signals:
tournament = TOURNAMENT_SIGNALS
name_prefix = "signals"
else:
tournament = TOURNAMENT_NUMERAI
name_prefix = "numerai"
def tournaments_dict():
napi = base_api.Api()
tournaments = napi.raw_query('query { tournaments { name tournament } }')
return {t["tournament"]: t["name"] for t in tournaments["data"]["tournaments"]}


def get_models(tournament):
napi = base_api.Api(*get_numerai_keys())
models = napi.get_models(tournament)

tournaments = napi.raw_query('query { tournaments { name tournament } }')
name_prefix = tournaments_dict()[tournament]
model_dict = {}
for model_name, model_id in models.items():
model_dict[model_name] = {
"id": model_id,
"name": f"{name_prefix}-{model_name}",
"is_signals": signals,
"tournament": tournament,
}
return model_dict

Expand All @@ -43,13 +45,15 @@ def get_models(signals):
type=str,
prompt=True,
help="The name of one of your models to configure the Prediction Node for."
"It defaults to the first model returned from your account.",
" It defaults to the first model returned from your account.",
)
@click.option(
"--signals",
"-s",
is_flag=True,
help="Target a signals model with this name. Defaults to false.",
"--tournament",
"-t",
default=TOURNAMENTS["numerai"],
help="Target a specific tournament number."
" Defaults to Numerai Tournament/Classic."
f" Available tournaments: {json.dumps(tournaments_dict(), indent=2)}",
)
@click.pass_context
def node(ctx, verbose, model_name, signals):
Expand Down
3 changes: 1 addition & 2 deletions numerai/cli/node/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test(ctx, local, command, verbose):
ctx.ensure_object(dict)
model = ctx.obj["model"]
node = model["name"]
is_signals = model["is_signals"]
tournament = model["tournament"]
node_config = load_or_init_nodes(node)
provider = node_config["provider"]

Expand Down Expand Up @@ -143,7 +143,6 @@ def test(ctx, local, command, verbose):
variables={"modelId": node_config["model_id"]},
authorization=True,
)
tournament = TOURNAMENT_SIGNALS if is_signals else TOURNAMENT_NUMERAI
curr_round = api.get_current_round(tournament)
latest_subs = sorted(
filter(
Expand Down

0 comments on commit fad168d

Please sign in to comment.