-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add component to index aws opensearch #740
Add component to index aws opensearch #740
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @shub-kris! Looks already quite promising. Could you try to add a component test as well? You could have a look into the write to Qdrant component. There was something similar implemented.
Args: | ||
index_body (Dict[str, Any]): Parameters that specify index settings, mappings, and aliases for newly created index. | ||
""" | ||
response = self.client.indices.create(self.index_name, body=index_body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the index already exists? Will the index be overwritten? Maybe we add a check if an index exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me check what it does if an index already exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :)
I think you still need to modify the Docker image to be able to run the test with it similar to this so that you can run tests using
docker build . --target test
Could you please update and test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing it out. I almost missed it. But now, Updated and tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great :)
did you manage to fix the failing pipelines?
after installing pre-commit you should run
pre-commit run --all-files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yupp
Args: | ||
dataframe (dd.DataFrame): The Dask DataFrame containing the data to be written. | ||
""" | ||
if not self.client.indices.exists(index=self.index_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could call the create_index
here if the index doesn't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not needed anymore as I am doing it inside the __init__
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the Exception too
region: str, | ||
index_name: str, | ||
index_body: Dict[str, Any], | ||
port: int = 443, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not include the default types here for the optional argument since you already define them in the spec and it can be misleading (they are not actually used here it will always default to the ones defined in the spec). You can instead define their types as optional just so that it's clear that they do have default values and they don't need to be explicitly defined. Similar to here
"""Creates an index in AWS OpenSearch. | ||
|
||
Args: | ||
index_body (Dict[str, Any]): Parameters that specify index settings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
index_body (Dict[str, Any]): Parameters that specify index settings, | |
index_body: Parameters that specify index settings, |
Our convention, we only define data types in the argument and not the docstring (single source of truth)
Writes the data from the given Dask DataFrame to AWS OpenSearch Index. | ||
|
||
Args: | ||
dataframe (dd.DataFrame): The Dask DataFrame containing the data to be written. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dataframe (dd.DataFrame): The Dask DataFrame containing the data to be written. | |
dataframe: The Dask DataFrame containing the data to be written. |
msg = f"Index: {self.index_name} doesn't exist. Please Create" | ||
raise ValueError(msg) | ||
|
||
for part in dataframe.partitions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for part in dataframe.partitions: | |
for part in tqdm( | |
dataframe.partitions, | |
desc="Processing partitions", | |
total=dataframe.npartitions, | |
): |
Useful to add logs in case the dataset is large. Similar to https://github.com/ml6team/fondant/blob/main/components/index_weaviate/src/main.py
Don't forget to add tqdm to the list of requirements
FYI, there's another test example in the You can install
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @shub-kris! Nice first contribution
""" | ||
index_name = "pytest-index" | ||
aws_os_comp = IndexAWSOpenSearchComponent( | ||
host="search-genai-vectordb-domain-f7vxqkogveaie2qdrivnkr66om.eu-west-1.es.amazonaws.com", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to test this locally instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise it might be better to mock this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mocking is the only solution to test it without having access to AWS OpenSearch Cluster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes indeed, so I would prefer that. Currently I cannot test this component myself. The goal of these tests is to be unit tests, we have other mechanism for integration testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do that and update the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RobbeSneyders updated
…b-kris/fondant into feature/index-aws-opensearch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @shub-kris!
This PR aims to add support for indexing to AWS OpenSearch.