Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Istrati committed Oct 31, 2024
1 parent af86e54 commit 6d99c3f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/anomaly-detector/anomaly_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from kubernetes import client as k8s_client, config as k8s_config

# Global variable for the model
model = None
MODEL = None

def get_config_map_values(config_map_name = "config-map"):
"""
Expand Down Expand Up @@ -151,15 +151,15 @@ def process_dataframe(df):
return combined_features, df[textual_features]

def initialize_model():
global model
if model is None:
model = SentenceTransformer("sentence-transformers/all-mpnet-base-v2")
global MODEL
if MODEL is None:
MODEL = SentenceTransformer("sentence-transformers/all-mpnet-base-v2")

def encode_batch(batch):
global model
if model is None:
global MODEL
if MODEL is None:
initialize_model()
return model.encode(batch)
return MODEL.encode(batch)

def create_embeddings(textual_features, batch_size=1000, num_workers=3):
"""
Expand Down

0 comments on commit 6d99c3f

Please sign in to comment.