Skip to content
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

JDE: Added MongoDB insert action + example #81

Merged
merged 14 commits into from
Jan 21, 2025
Merged

Conversation

cyrus2281
Copy link

@cyrus2281 cyrus2281 commented Jan 20, 2025

What is the purpose of this change?

The purpose of this change is to enhance the MongoDB component of the project to support the insertion of data with specified data types. This is important for improving data handling capabilities and ensuring that inserted data conforms to expected formats.

How is this accomplished?

  • JDE: Added MongoDB insert action + example

Anything reviews should focus on/be aware of?

Reviewers should ensure that the type conversion implementation is robust, especially the handling of non-JSON types. Also, verify that the MongoDB insert feature is functioning as expected in various scenarios.

@cyrus2281 cyrus2281 self-assigned this Jan 20, 2025
Copy link

gitstream-cm bot commented Jan 20, 2025

Please mark whether you used Copilot to assist coding in this PR

  • Copilot Assisted

@cyrus2281 cyrus2281 changed the title JDE: Added Options for Custom Keys in Request-Response, Updated MongoDB Insert and Added Search Component JDE: Added MongoDB insert action + example Jan 20, 2025


class MongoDBInsertComponent(MongoDBBaseComponent):
"""Component for handling MongoDB database operations."""

def __init__(self, **kwargs):
super().__init__(info, **kwargs)
self.data_types_map = self.get_config("data_types")

def invoke(self, message, data):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please give some examples of data_types and data. Since the data variable may include any complex data structure (e.g., List[List[List]]), would your code expect to handle all possible combinations?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added proper validation.
As for example, you can find some here

@cyrus2281 cyrus2281 requested a review from alimosaed January 20, 2025 19:36
Copy link
Collaborator

@gregmeldrum gregmeldrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about Mongo, but the code itself looks sound.

@cyrus2281 cyrus2281 removed their assignment Jan 20, 2025
"Invalid data types provided for MongoDB insert. Expected a dictionary."
)
for key, field_type in self.data_types_map.items():
if not isinstance(key, str) or not isinstance(field_type, str):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SUG] you can make an enumeration of known data types and compare the filed_type with them. If the type is not know, either raise and error or a warning.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a list with all possible values and a checklist

@cyrus2281 cyrus2281 requested a review from alimosaed January 20, 2025 21:07
Copy link

Copy link

@alimosaed alimosaed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@cyrus2281 cyrus2281 merged commit 2ab4d63 into main Jan 21, 2025
6 of 9 checks passed
@cyrus2281 cyrus2281 deleted the cyrus/jde/mongodb branch January 21, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants