/
super_class.py
43 lines (34 loc) · 1.63 KB
/
super_class.py
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
"""Base class for other models."""
# NOTE: Currently works only with S3DataStore
import os
from analytics_platform.kronos.src.config import (
AWS_BUCKET_NAME,
KRONOS_MODEL_PATH)
from analytics_platform.kronos.pgm.src.offline_training import load_eco_to_kronos_dependency_dict_s3
from evaluation_platform.uranus.src.uranus_constants import URANUS_OUTPUT_PATH
class Accuracy(object):
"""Base class for other models."""
def __init__(self):
"""Initialize this class, load Kronos dependency list from the S3."""
self.eco_to_kronos_dependency_dict = load_eco_to_kronos_dependency_dict_s3(
bucket_name=AWS_BUCKET_NAME, additional_path=KRONOS_MODEL_PATH)
self.search_set = set()
self.search_set_length = 0
def check_present(self, check_set):
"""Check if a given set is a subset of our manifest search set or not.
:param check_set: The set to checked for within the manifest set.
"""
for each_set in self.search_set:
if check_set.issubset(each_set):
return True
return False
def load_search_set(self, input_data_store, additional_path):
"""Load the manifets search set from the given source.
:param input_data_store: The datastore where search set is present.
:param additional_path: The directory where search set is loaded from.
"""
input_filename = os.path.join(
additional_path, URANUS_OUTPUT_PATH, "search_set.pickle")
self.search_set = input_data_store.load_pickle_file(
filename=input_filename)
self.search_set_length = len(self.search_set)