-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
[AIRFLOW-3049] Add extra operations for Mongo hook #3890
Conversation
This commit adds update, replace and delete operations for the Mongo hook.
The Travis build seems to have failed for one of the environments. It runs on my own branch though: https://travis-ci.org/dlebech/incubator-airflow/builds/427786725 |
airflow/contrib/hooks/mongo_hook.py
Outdated
|
||
def replace_many(self, mongo_collection, docs, | ||
filter_docs=None, mongo_db=None, upsert=False, collation=None, | ||
**bulk_kwargs): |
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.
Maybe call this one just kwargs
as well, to make it congruent with the other calls.
:type filter_docs: list(dict) | ||
:param mongo_db: The name of the database to use. | ||
Can be omitted; then the database from the connection string is used. | ||
:type mongo_db: str |
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.
The upsert
and collation
are missing from the docstring.
@Fokko thanks for the feedback. I've updated the parameter name and added tweaks to the documentation. |
LGTM, one minor think. Recently we've moved to a Docker-compose based CI pipeline. Instead of mocking the requests, there is also a real mongo instance running. What are your opinions on mocking, or talking to a real mongo instance? |
@Fokko Thanks! Regarding mocking vs real instance, I'm not sure I'm in the best position to answer that since I basically just built this PR upon the pre-existing setup, so I cannot say why But it looks like a pretty good library for this kind of thing, and since Travis is already taking a very long time to run, I assume mocking speeds thing up a bit in this case. I don't know how much that matters, but at least from my perspective, it feels like mocking is an ok thing to do 🙂 Perhaps the original author @andscoop has a better opinion than mine? |
@dlebech @Fokko When I was originally writing unit tests, I don't believe that we were using docker-compose, or if we were I was not aware of it. I'm not familiar with all the reasons for moving to docker-compose, but idk if I see a compelling reason to move away from mocking the responses in the hook as all responses are known before hand. |
@Fokko is this ready to merge? |
Thanks, @dlebech. Merging to master! |
This commit adds update, replace and delete operations for the Mongo hook.
This commit adds update, replace and delete operations for the Mongo hook.
This commit adds update, replace and delete operations for the Mongo hook.
This commit adds update, replace and delete operations for the Mongo hook.
Make sure you have checked all steps below.
Jira
Description
This PR adds six extra operations to the Mongo hook:
update
,replace
anddelete
as well as a*_many
version for each of those.Tests
test_update_one
test_update_one_with_upsert
test_update_many
test_update_many_with_upsert
test_replace_one
test_replace_one_with_filter
test_replace_one_with_upsert
test_replace_many
test_replace_many_with_upsert
test_delete_one
test_delete_many
Commits
Documentation
Code Quality
git diff upstream/master -u -- "*.py" | flake8 --diff