opentensor / validators

Repository for bittensor validators
https://www.bittensor.com/
MIT License
14 stars 9 forks source link

JSON decode error when pulling wandb runs with invalid characters #131

Open steffencruz opened 1 year ago

steffencruz commented 1 year ago

This appears to happen when the run summary metrics contains characters that are not JSON decodable. An example substring is

...ve decision making allows homogeneous feedbaÐJ57\"bckfor corrective drive and completional effort wi...

We should sanitize completions and prompts to ensure that there are no characters of this type and add unit tests

surcyf123 commented 1 year ago

This fixes it.

import json
# Store the original json.loads
original_json_loads = json.loads

def relaxed_json_loads(s, *args, **kwargs):
    kwargs.pop("strict", None)  # remove the strict argument if it exists
    return original_json_loads(s, strict=False, *args, **kwargs)

# Patch the library's json.loads
json.loads = relaxed_json_loads

This way we can keep the original data and it won't throw the error and we can still pull all runs.