File size: 1,200 Bytes
6c2e259 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
print('import start')
import os
import pickle
from pathlib import Path
# These utilities must be part of submission repo
from batteryswap_public.utils import make_submissions
from batteryswap_public.interfaces import Planner
# ensure classes that might be referenced in pickle is imported
from batteryswap_example.train import *
def pickle_loader(path : str):
def load() -> Planner:
with open(path, "rb") as f:
return pickle.load(f)
return load
def main():
print('main start')
# Load a trained model from repo
default_planner_path = 'batteryswap_example/planners/best.pickle'
planner_path = Path(os.environ.get('BATTERYSWAP_PLANNER_PATH', default_planner_path))
loader = pickle_loader(planner_path)
# NOTE: On HuggingFace the dataset will be in /tmp/data
dataset_path = Path(os.environ.get('BATTERYSWAP_DATASET_PATH', '/tmp/data'))
splits = os.environ.get('BATTERYSWAP_SPLITS', 'public,private').split(',')
make_submissions(loader, dataset_path=dataset_path, splits=splits)
# NOTE: On HuggingFace the output must be submission.csv
assert os.path.exists('submission.csv')
if __name__ == '__main__':
main()
|