#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jul  6 06:48:29 2023

@author: chen
"""
import numpy as np

class UserOracle(object):
    """User defined oracle. Receive inputs from MG and generate ground truth."""
    def __init__(self, rank, result_dir):
        """
        Initilize the model.
        
        Args:
            rank (int): current process rank (PID).
            result_dir (str): path to directory to save metadata and results.
        """
        self.rank = rank
        self.result_dir = result_dir
        
    def run_calc(self, input_for_orcl):
        """
        Run Oracle computation.
        Args:
            input_for_orcl (1-D numpy.ndarray): input for oracle computation.
                                                Source: element of input_to_orcl_list from utils.prediction_check()

        Returns:
            orcl_calc_res (1-D numpy.ndarray): results generated by Oracle.
                                               Destination: element of datapoints at UserModel.add_trainingset().
        """
        orcl_calc_res = None
        ##### User Part #####
        orcl_calc_res = np.random.randn(4,)
        
        # orcl_calc_res should be returned as an 1-D numpy array
        return orcl_calc_res
    
    def stop_run(self):
        """
        Called before the Oracle process terminating when active learning workflow shuts down.
        """
        ##### User Part #####
        pass