Skip to content

Commit

Permalink
fixed iso_to_datetime function to handle z formatted strings
Browse files Browse the repository at this point in the history
  • Loading branch information
hayden-yuma committed Dec 9, 2024
1 parent cf13fc1 commit 3d21396
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion precog/miners/base_miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_prediction_interval(timestamp: str, point_estimate: float) -> Tuple[floa
return lower_bound, upper_bound


async def forward(synapse: Challenge) -> Challenge:
def forward(synapse: Challenge) -> Challenge:
bt.logging.info(
f"👈 Received prediction request from: {synapse.dendrite.hotkey} for timestamp: {synapse.timestamp}"
)
Expand Down
2 changes: 1 addition & 1 deletion precog/miners/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Miner:
def __init__(self, config=None):
args = parse_arguments()
config = Config(args)
self.forward_module = importlib.import_module(f"precog.miners.{config.forward_function}", package="forward")
self.forward_module = importlib.import_module(f"precog.miners.{config.forward_function}")
self.config = config
self.config.neuron.type = "Miner"
setup_bittensor_objects(self)
Expand Down
2 changes: 1 addition & 1 deletion precog/utils/timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def iso8601_to_datetime(timestamp: str) -> datetime:
"""
Convert iso 8601 string to datetime
"""
return datetime.fromisoformat(timestamp)
return datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%fZ")


def posix_to_datetime(timestamp: float) -> datetime:
Expand Down
13 changes: 10 additions & 3 deletions precog/validators/weight_setter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
from precog.utils.bittensor import check_uid_availability, print_info, setup_bittensor_objects
from precog.utils.classes import MinerHistory
from precog.utils.general import func_with_retry, loop_handler
from precog.utils.timestamp import elapsed_seconds, get_before, get_now, is_query_time, iso8601_to_datetime
from precog.utils.timestamp import (
datetime_to_iso8601,
elapsed_seconds,
get_before,
get_now,
is_query_time,
iso8601_to_datetime,
)
from precog.utils.wandb import log_wandb, setup_wandb
from precog.validators.reward import calc_rewards

Expand Down Expand Up @@ -106,7 +113,7 @@ async def resync_metagraph(self):
self.save_state()

def query_miners(self):
timestamp = get_now().isoformat()
timestamp = datetime_to_iso8601(get_now())
synapse = Challenge(timestamp=timestamp)
responses = self.dendrite.query(
# Send the query to selected miner axons in the network.
Expand Down Expand Up @@ -156,7 +163,7 @@ async def set_weights(self):

async def scheduled_prediction_request(self):
if not hasattr(self, "timestamp"):
self.timestamp = get_before(minutes=self.prediction_interval).isoformat()
self.timestamp = datetime_to_iso8601(get_before(minutes=self.prediction_interval))
query_lag = elapsed_seconds(get_now(), iso8601_to_datetime(self.timestamp))
if len(self.available_uids) == 0:
bt.logging.info("No miners available. Sleeping for 10 minutes...")
Expand Down

0 comments on commit 3d21396

Please sign in to comment.