checker / config.py
khoa-klaytn's picture
refactor(train): change objective from finetuning to downtuning
b21242e
Raw History Blame Contribute Delete
1.15 kB
from dotenv import load_dotenv
import os
load_dotenv("/notebooks/models/checker/.env", override=True)
def getEnv(key: str) -> str:
val = os.getenv(key)
if val is None:
raise Exception(f"{key} is not set")
return val
ROOT_DIR = getEnv("ROOT_DIR")
def p(*path: str) -> str:
return os.path.join(ROOT_DIR, *path)
DS_DIR = getEnv("DS_DIR")
import torch
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
import random
import numpy as np
SEED = getEnv("SEED")
def seed():
int_SEED = int(SEED)
os.environ['PYTHONHASHSEED'] = SEED
random.seed(int_SEED)
np.random.seed(int_SEED)
torch.manual_seed(int_SEED)
import json
def ActionDict():
with open(os.path.join(DS_DIR, "actions.json")) as f:
action_dict = json.loads(f.read())
for action in action_dict:
action_description = action_dict[action]["description"]
action_description = f"{action_description}" # interpret escape characters
action_dump = json.dumps({"name": action, "description": action_description})
action_dict[action] = action_dump
return action_dict
action_dict = ActionDict()
num_actions = len(action_dict)