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

Adds alternative to use a mongodb backend #202

Closed
wants to merge 6 commits into from
Closed

Conversation

moonso
Copy link
Contributor

@moonso moonso commented Oct 24, 2018

No description provided.

@adrosenbaum adrosenbaum self-requested a review August 28, 2019 12:46
Copy link
Contributor

@adrosenbaum adrosenbaum 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 to me, although with some few comments. Do you think we need to test this on stage, assuring that none of these changes interfere with the existing functionality using sql as backend?

One of the builds failed on travis, if you want I can look into this. All tests seem to run fine when I run them locally.

@@ -23,7 +24,12 @@ def dump_json(data, pretty=False):
@click.pass_context
def calculate(context):
"""Calculate statistics across samples."""
context.obj['db'] = ChanjoDB(uri=context.obj['database'])
backend = context.obj['backend']
if backend == 'mongodb':
Copy link
Contributor

Choose a reason for hiding this comment

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

This block of code is repeated several times. Would it be possible to move this to change.cli.base and add the database object to context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, could you suggest with a code snippet how you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

'chanjo' was autocorrected to 'change' in comment above it seems...

I'm just thinking something like this in chanjo.cli.base

    if backend == 'mongodb':
        chanjo_db = ChanjoMongoDB(uri=context.obj['database'])
    else:
        chanjo_db = ChanjoDB(uri=context.obj['database'])
    
    context.obj['db'] = chanjo_db

and in chanjo.cli.load, calculate, etc.

    chanjo_db = context.obj['db']

'$avg': '$completeness_20'
},
'completeness_50': {
'$avg': '$completeness_20'
Copy link
Contributor

Choose a reason for hiding this comment

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

$completeness_50 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

'$avg': '$completeness_20'
},
'completeness_100': {
'$avg': '$completeness_20'
Copy link
Contributor

Choose a reason for hiding this comment

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

$completeness_100

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍
I guess these would need tests so that this type of error would not pass

context.obj['database'] = (database or context.obj.get('database'))

context.obj['backend'] = 'sql'
if (context.obj['database'] and 'mongo' in context.obj['database']):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the type of backend is something that should passed in the config, rather than searching the substring 'mongo' in the uri?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I think you are right

@moonso moonso mentioned this pull request Apr 20, 2020
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.

None yet

3 participants