# Path: simulator/fortune_teller_factory.py
# def FortuneTellerFactory(config):
#     oracle_or_predictor = config.WhichOneof("teller")
#     if oracle_or_predictor == "oracle":
#         return Oracle(config)
# 
#     if oracle_or_predictor == "predictor":
#         return PredictorFactory().CreatePredictor(config.predictor)


import apache_beam as beam
import numpy as np
import json
from collections import deque
from simulator.fortune_teller_factory import FortuneTellerFactory


class _Snapshot:
    def __init__(self, time, measures):
        self.time = time
        self.measures = measures


def _FilterFutureSnapshot(current_snapshot, future_snapshot):
    current_VMs_list = [
        item["sample"]["info"]["unique_id"]
        for item in vars(current_snapshot)["measures"]
    ]
    filtered_future_snapshot = []
    for item in future_snapshot:
        filtered_measures = []
        for element in vars(item)["measures"]:
            if element["sample"]["info"]["unique_id"] in current_VMs_list:
                filtered_measures.append(element)
        filtered_future_snapshot.append(
            _Snapshot(vars(item)["time"], filtered_measures)
        )
    return current_snapshot, filtered_future_snapshot


class _FortuneTeller:
    def __init__(self, config):
        self.config = config
        self.name = self.config.name
        self.save_samples = self.config.save_samples

# Path: simulator/fortune_teller_factory.py
# def FortuneTellerFactory(config):
#     oracle_or_predictor = config.WhichOneof("teller")
#     if oracle_or_predictor == "oracle":
#         return Oracle(config)
# 
#     if oracle_or_predictor == "predictor":
#         return PredictorFactory().CreatePredictor(config.predictor)


# Path: simulator/fortune_teller.py
import apache_beam as beam
import numpy as np
import json
from collections import deque
from simulator.fortune_teller_factory import FortuneTellerFactory



class _Snapshot:
    def __init__(self, time, measures):
        self.time = time
        self.measures = measures


def _FilterFutureSnapshot(current_snapshot, future_snapshot):
    current_VMs_list = [
        item["sample"]["info"]["unique_id"]
        for item in vars(current_snapshot)["measures"]
    ]
    filtered_future_snapshot = []
    for item in future_snapshot:
        filtered_measures = []
        for element in vars(item)["measures"]:
            if element["sample"]["info"]["unique_id"] in current_VMs_list:
                filtered_measures.append(element)
        filtered_future_snapshot.append(
            _Snapshot(vars(item)["time"], filtered_measures)
        )
    return current_snapshot, filtered_future_snapshot


class _FortuneTeller:
    def __init__(self, config):
        self.config = config
        self.name = self.config.name
        self.save_samples = self.config.save_samples

        self.teller = FortuneTellerFactory(self.config)