Skip to content

Commit

Permalink
allowing to initialize es with id and key
Browse files Browse the repository at this point in the history
  • Loading branch information
yanaiela committed Aug 31, 2024
1 parent 56d9c5d commit 1f6395e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from setuptools import setup, find_packages

setup(
name='wimbd', # Name of your package
version='0.1.0', # Initial version
name='wimbd',
version='0.1.1',
author='Yanai Elazar, Akshita Bhagia, Ian Magnusson, Abhilasha Ravichander, Dustin Schwenk, Alane Suhr, Pete Walsh, Dirk Groeneveld, Luca Soldaini, Sameer Singh, Hanna Hajishirzi, Noah A. Smith, Jesse Dodge',
author_email='yanaiela@gmail.com',
description='An elasticsearch wrapper that allows to query ES indices',
long_description=open('wimbd/es/README.md').read(),
long_description_content_type='text/markdown',
url='https://wimbd.apps.allenai.org/', # Project's URL
packages=find_packages(include=['wimbd.es']), # Automatically find packages in the directory # include=['wimbd', 'wimbd.es']
url='https://wimbd.apps.allenai.org/',
packages=find_packages(include=['wimbd.es']), # Automatically find packages in the directory # include=['wimbd.es']
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: Apache Software License',
Expand Down
12 changes: 9 additions & 3 deletions wimbd/es/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@


@cache
def es_init(config: Path = DEFAULT_CONFIG_LOCATION, timeout: int = 30) -> Elasticsearch:
def es_init(config: Path = DEFAULT_CONFIG_LOCATION, cloud_id: str = None, api_key: str=None, timeout: int = 30) -> Elasticsearch:
"""
:param config: Path to the config yaml file, containing `cloud_id` and `api_key` fields.
:return: Authenticated ElasticSearch client.
"""
with open(config) as file_ref:
config = yaml.safe_load(file_ref)
if config:
with open(config) as file_ref:
config = yaml.safe_load(file_ref)
else:
config = {
"cloud_id": cloud_id,
"api_key": api_key
}

if config == DEFAULT_CONFIG_LOCATION:
logger.warning("Using default config file. This will unlikely work unless you're the creator of this library. Please make sure to specify the ES config file and provide it to the function you are using.")
Expand Down

0 comments on commit 1f6395e

Please sign in to comment.