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

Metrics utilization #25

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

samanvp
Copy link
Contributor

@samanvp samanvp commented Jul 18, 2019

We define a decorator to utilize metrics module and collect anonymous usage
metrics from deepvariant_runner.

samanvp added 6 commits July 18, 2019 14:23
This PR contains the implementation of a decorator to collect metrics from DeepVariant Runner.

A second PR will utilize the newly defined decorator to collect usage metrics.
We define a decorator to utilize metrics module and collect usage
metrics from deepvariant_runner.
@samanvp
Copy link
Contributor Author

samanvp commented Jul 18, 2019

Please note this PR is the continuation of #19 meaning that metrics.py and metrics_test.py is branched from that PR.

Copy link

@allieychen allieychen left a comment

Choose a reason for hiding this comment

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

Thanks Saman, it looks great!

@@ -1040,10 +1102,57 @@ def run(argv=None):
'jobs. By default, the pipeline runs all 3 jobs (make_examples, '
'call_variants, postprocess_variants) in sequence. '
'This option may be used to run parts of the pipeline.'))
parser.add_argument(
'--stop_collecting_anonymous_usage_metrics',

Choose a reason for hiding this comment

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

I think add the argument collecting_anonymous_usage_metrics would be easier to read. Especially it is used as if not pipeline_args.stop_collecting_anonymous_usage_metrics:. And the action and help seem not relevant?

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 agree the if statement would be more readable if this flag was not 'negative'. However, I really like this flag to explicitly indicate it stops metrics collection.

Please let me know if this does not make sense.


if not pipeline_args.stop_collecting_anonymous_usage_metrics:
metrics.add(
_get_project_number(pipeline_args.project),

Choose a reason for hiding this comment

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

I am not sure whether it still makes sense to collect the metrics when getting the project number failed (-1).

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 it does. Ideally we like to know how many unique users we have and getting their project_id is needed for that. But in case we cannot get the project_id still it will be informative if we find out other information about the run (how many workers, failure or success, ...).

Choose a reason for hiding this comment

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

Do you know in which case it may fail to get the project_id?

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 can imagine there might be some GCP IAM settings that prevents a service account from reading the project's metadata, I am guessing in those cases it will also raise an error.
It is also possible we can successfully fetch the project_id in all runs and never return -1. But in any case in _get_project_number() we have to run the gcloud projects describe command in a try-catch block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to gcloud projects describe --help:

This command can fail for the following reasons:

  • The project specified does not exist.
  • The active account does not have permission to access the given project

The first case does not occur to us (otherwise the gcloud alpha genomics pipelines run would't go through). So we will not log the right project_id when serviceaccount does not have enough permission.

Choose a reason for hiding this comment

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

In general we aren't allowed to log project ID (it's PII). I think we got approval to log a SHA1 hash of the project ID.

Note that the permissions required to get the project ID are non-trivial and so it might be likely that the SA doesn't have them.

Choose a reason for hiding this comment

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

Thank you Saman for the detailed explanation! I think the second case should not occur to us neither, since the user is running the pipeline in that project, which they must have access to. So I agree that it probably will never return -1 :).

Choose a reason for hiding this comment

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

Sorry I misread this as ID not number for some reason. Project number is fine :)

if pipeline_args.stop_collecting_anonymous_usage_metrics:
func(pipeline_args, *args, **kwargs)
else:
success = False

Choose a reason for hiding this comment

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

super nit: How about status = '_Failure', and after the func succeeds, having status = '_Success', so you can avoid if else below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@samanvp samanvp force-pushed the metrics_utilization branch from 0a677df to f05ca90 Compare July 23, 2019 14:33
Copy link
Contributor Author

@samanvp samanvp left a comment

Choose a reason for hiding this comment

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

Thank Allie for your comments.

if pipeline_args.stop_collecting_anonymous_usage_metrics:
func(pipeline_args, *args, **kwargs)
else:
success = False
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -1040,10 +1102,57 @@ def run(argv=None):
'jobs. By default, the pipeline runs all 3 jobs (make_examples, '
'call_variants, postprocess_variants) in sequence. '
'This option may be used to run parts of the pipeline.'))
parser.add_argument(
'--stop_collecting_anonymous_usage_metrics',
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 agree the if statement would be more readable if this flag was not 'negative'. However, I really like this flag to explicitly indicate it stops metrics collection.

Please let me know if this does not make sense.


if not pipeline_args.stop_collecting_anonymous_usage_metrics:
metrics.add(
_get_project_number(pipeline_args.project),
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 it does. Ideally we like to know how many unique users we have and getting their project_id is needed for that. But in case we cannot get the project_id still it will be informative if we find out other information about the run (how many workers, failure or success, ...).

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