def connect_to_ceph(ceph_bucket_prefix: str, environment: str, bucket: Optional[str] = None) -> CephStore: """Connect to Ceph to store SLI metrics for Thoth.""" prefix = _get_sli_metrics_prefix(ceph_bucket_prefix=ceph_bucket_prefix, environment=environment) ceph = CephStore(prefix=prefix, bucket=bucket) ceph.connect() return ceph
def connect_to_ceph( cls, ceph_bucket_prefix: str, processed_data_name: str, environment: str, bucket: Optional[str] = None, ) -> CephStore: """Connect to Ceph to store processed data.""" prefix = cls._get_processed_data_prefix( ceph_bucket_prefix=ceph_bucket_prefix, processed_data_name=processed_data_name, environment=environment, ) ceph = CephStore(prefix=prefix, bucket=bucket) ceph.connect() return ceph
import os from typing import List from thoth.storages import CephStore store = CephStore(prefix='data/thoth/ash-api/ETM/words') store.connect() def retrieve_n_most_similar(token, n) -> List: if not store.document_exists(token): return {'error': f'The token: {token} is not in the vocabulary.'}, 404 token_dict = store.retrieve_document(token) return [t for t in token_dict['most_similar'][:n]] def get(token): """ Retrieves the 25 most similar tokens to {token} path param """ return { 'token': token, 'most-similar-tokens': retrieve_n_most_similar(token, n=25), }, 200