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

SanityBot #435

Merged
merged 14 commits into from
Jan 22, 2018
Merged

SanityBot #435

merged 14 commits into from
Jan 22, 2018

Conversation

marcua
Copy link
Member

@marcua marcua commented Jan 4, 2018

Addresses #434

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
Copy link
Member Author

Choose a reason for hiding this comment

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

won't merge this---will wait for @paopow 's PR, rebase, and rebuild migrations.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine really. :-D

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine really. :D



def _workflow_versions_with_sanity_checks():
# TODO(marcua): make more specific.
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't incur serious performance issues in practice, so I'm tempted to leave as-is :)

@coveralls
Copy link

coveralls commented Jan 18, 2018

Coverage Status

Coverage increased (+0.07%) to 91.562% when pulling ad53b62 on sanitybot into e2bc33f on master.

Makefile Outdated
flake8 . && isort --check-only --recursive .
# TODO(marcua): reenable isort when it works the same in dev and
# on CircleCI
flake8 . # && isort --check-only --recursive .
Copy link
Contributor

Choose a reason for hiding this comment

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

Yay!

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine really. :-D

@@ -64,13 +65,16 @@ class WorkflowVersion(WorkflowVersionMixin, models.Model):
A longer description of the workflow version.
workflow (orchestra.models.Workflow):
The workflow that this is a version of.
sanity_checks (str):
A JSON blob used to define the sanity checks we run.
Copy link
Contributor

Choose a reason for hiding this comment

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

Where do I find an example of the format of this blob?

Copy link
Member Author

Choose a reason for hiding this comment

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

reasonable question, updated docstring

}],
"repetition_seconds": 86400
},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use this as an example of the sanity_checks blob? What would it look like with multiple checks? What happens to "deleted" checks?

.filter(project=project)
.values('check_slug')
.annotate(max_created_at=Max('created_at')))
latest_check_creation = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Reusing the variable name is OK?

Copy link
Member Author

@marcua marcua Jan 18, 2018

Choose a reason for hiding this comment

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

it's nasty! fixed!:)

check['check_slug']: check['max_created_at']
for check in latest_check_creation}
for check in checks:
max_created_at = latest_check_creation.get(check.check_slug)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the different between check['check_slug'] and check.check_slug?

Copy link
Member Author

Choose a reason for hiding this comment

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

check is of type SanityCheck (we both miss typed languages :)), which has a property called check_slug

latest_check_creation is a dictionary, which has keys defined by the set of distinct check_slug

Makefile Outdated
flake8 . && isort --check-only --recursive .
# TODO(marcua): reenable isort when it works the same in dev and
# on CircleCI
flake8 . # && isort --check-only --recursive .
Copy link
Contributor

Choose a reason for hiding this comment

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

Yay

"""
created_at = models.DateTimeField(default=timezone.now)
slug = models.CharField(max_length=200)
name = models.CharField(max_length=200)
description = models.TextField()
workflow = models.ForeignKey(
Workflow, related_name='versions', on_delete=models.CASCADE)
sanity_checks = JSONField(default={})
Copy link
Contributor

Choose a reason for hiding this comment

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

Why storing a lot of information here instead of the SanityCheck itself?

.filter(project=project)
.values('check_slug')
.annotate(max_created_at=Max('created_at')))
latest_check_creation = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same variable name OK?

check['check_slug']: check['max_created_at']
for check in latest_check_creation}
for check in checks:
max_created_at = latest_check_creation.get(check.check_slug)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference between check['check_slug'] and check.check_slug?

.get('path'))
check_configurations = sanity_checks.get('check_configurations')
if sanity_check_path and check_configurations:
sanity_check_function = locate(sanity_check_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

What if locate fail?

Copy link
Member Author

Choose a reason for hiding this comment

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

it will throw an exception, which will stop the world. this has been how we've handled all *_function paths.

longer-term, we should consider 'statically analyzing' workflow configurations on load.

check_configurations = sanity_checks.get('check_configurations')
if sanity_check_path and check_configurations:
sanity_check_function = locate(sanity_check_path)
sanity_checks = sanity_check_function(project)
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the function return an invalid value?

Copy link
Member Author

Choose a reason for hiding this comment

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

in general it gets "sanity checked" in _handle_sanity_checks(. Can you think of ways it'd break?

sanity_check.save()


def create_and_handle_sanity_checks():
Copy link
Contributor

Choose a reason for hiding this comment

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

In a deployed instance, when is this function called? How do we automatically check and handle the SanityCheck?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added docs!

@marcua marcua merged commit 448c9c5 into master Jan 22, 2018
@marcua marcua deleted the sanitybot branch January 22, 2018 18:14
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