diff --git a/controller.py b/controller.py index 5e293d6..32936a5 100644 --- a/controller.py +++ b/controller.py @@ -19,7 +19,6 @@ import zlib from spacy.tokens import DocBin, Doc from spacy.vocab import Vocab -from data import doc_ock from embedders import Transformer from typing import Any, Dict, Iterator, List, Optional @@ -157,7 +156,6 @@ def __prepare_encoding(project_id: str, embedding_id: str) -> None: f"notification_created:{user_id}", True, ) - doc_ock.post_embedding_failed(user_id, f"{model}-{platform}") raise Exception(message) return ( project_id, @@ -244,7 +242,6 @@ def run_encoding( project_id, f"embedding:{embedding_id}:state:{enums.EmbeddingState.FAILED.value}", ) - doc_ock.post_embedding_failed(user_id, f"{model}-{platform}") notification_message = f"Error while getting model - {e}" notification.create( project_id, @@ -276,7 +273,6 @@ def run_encoding( project_id, f"embedding:{embedding_id}:state:{enums.EmbeddingState.ENCODING.value}", ) - doc_ock.post_embedding_encoding(user_id, f"{model}-{platform}") notification.create( project_id, user_id, @@ -346,7 +342,6 @@ def run_encoding( enums.NotificationType.EMBEDDING_CREATION_FAILED.value, True, ) - doc_ock.post_embedding_failed(user_id, f"{model}-{platform}") return status.HTTP_500_INTERNAL_SERVER_ERROR except Exception as e: error_message = str(e) @@ -409,7 +404,6 @@ def run_encoding( True, ) send_project_update(project_id, f"notification_created:{user_id}", True) - doc_ock.post_embedding_failed(user_id, f"{model}-{platform}") return status.HTTP_500_INTERNAL_SERVER_ERROR if embedding.get(project_id, embedding_id) and not embedding_canceled: @@ -471,7 +465,6 @@ def run_encoding( True, ) send_project_update(project_id, f"notification_created:{user_id}", True) - doc_ock.post_embedding_finished(user_id, f"{model}-{platform}") general.commit() general.remove_and_refresh_session(session_token) return status.HTTP_200_OK diff --git a/data/doc_ock.py b/data/doc_ock.py deleted file mode 100644 index aafdb42..0000000 --- a/data/doc_ock.py +++ /dev/null @@ -1,69 +0,0 @@ -import os -import requests -import re - -from dataclasses import dataclass -from submodules.model import enums -from typing import Any - -from util import daemon - -BASE_URI = os.getenv("DOC_OCK") - - -@dataclass -class Event: - ConfigString: str - State: str - - @classmethod - def event_name(cls) -> str: - # transforms the class name so that it is better readable in MixPanel, - # e.g. CreateProject becomes "Create Project" - matches = re.finditer( - ".+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)", cls.__name__ - ) - return " ".join([m.group(0) for m in matches]) - - -def post_embedding_creation(user_id: str, config_string: str) -> Any: - return __post_event_threaded(user_id, config_string, enums.EmbeddingState.INITIALIZING.value) - - -def post_embedding_encoding(user_id: str, config_string: str) -> Any: - return __post_event_threaded(user_id, config_string, enums.EmbeddingState.ENCODING.value) - - -def post_embedding_finished(user_id: str, config_string: str) -> Any: - return __post_event_threaded(user_id, config_string, enums.EmbeddingState.FINISHED.value) - - -def post_embedding_failed(user_id: str, config_string: str) -> Any: - return __post_event_threaded(user_id, config_string, enums.EmbeddingState.FAILED.value) - - -def __post_event_threaded(user_id: str, config_string: str, state: str) -> Any: - daemon.run(__post_event, user_id, config_string, state) - -def __post_event(user_id: str, config_string: str, state: str) -> Any: - try: - if not user_id: - return # migration is without user id (None) - url = f"{BASE_URI}/track/{user_id}/Create Embedding" - data = { - "ConfigString": config_string, - "State": state, - "Host": os.getenv("S3_ENDPOINT"), - } - - response = requests.post(url, json=data) - - if response.status_code != 200: - raise Exception("Could not send data to Doc Ock") - - if response.headers.get("content-type") == "application/json": - return response.json() - else: - return response.text - except Exception as e: - print("Sending of message failed.", str(e), flush=True) \ No newline at end of file diff --git a/start b/start index 6579528..ef5d653 100755 --- a/start +++ b/start @@ -49,7 +49,6 @@ docker run -d --rm \ -e S3_ACCESS_KEY=kern \ -e S3_SECRET_KEY=r6ywtR33!DMlaL*SUUdy \ -e POSTGRES=postgresql://postgres:kern@graphql-postgres:5432 \ --e DOC_OCK=http://refinery-doc-ock:80 \ -e MODEL_PROVIDER=http://refinery-model-provider:80 \ -e WS_NOTIFY_ENDPOINT="http://refinery-websocket:8080" \ -e NEURAL_SEARCH=http://refinery-neural-search:80 \