Skip to content

Commit

Permalink
Closes #2: Don't pass an instance of RedashClient to construct dashbo…
Browse files Browse the repository at this point in the history
…ards.
  • Loading branch information
Marina Samuel committed Feb 5, 2018
1 parent a32289f commit 1081457
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
St. Moab
====================

A tool for automating a/b testing analysis using stmo dashboards (https://sql.telemetry.mozilla.org)
A tool for automating a/b testing analysis using stmo dashboards (https://sql.telemetry.mozilla.org)
4 changes: 2 additions & 2 deletions stmoab/ActivityStreamExperimentDashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ class ActivityStreamExperimentDashboard(SummaryDashboard):
DISABLE_TITLE = "Disable Rate"
RETENTION_DIFF_TITLE = "Daily Retention Difference (Experiment - Control)"

def __init__(self, redash_client, project_name, dash_name, exp_id,
def __init__(self, api_key, project_name, dash_name, exp_id,
start_date=None, end_date=None):
DASH_TITLE = "{project}: {dash}".format(
project=project_name, dash=dash_name)
super(ActivityStreamExperimentDashboard, self).__init__(
redash_client,
api_key,
DASH_TITLE,
self.DEFAULT_EVENTS_TABLE,
start_date, end_date)
Expand Down
4 changes: 2 additions & 2 deletions stmoab/StatisticalDashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class StatisticalDashboard(ActivityStreamExperimentDashboard):


def __init__(
self, redash_client, aws_access_key, aws_secret_key,
self, api_key, aws_access_key, aws_secret_key,
s3_bucket_id, project_name, dash_name, exp_id,
start_date=None, end_date=None
):
super(StatisticalDashboard, self).__init__(
redash_client,
api_key,
project_name,
dash_name,
exp_id,
Expand Down
5 changes: 3 additions & 2 deletions stmoab/SummaryDashboard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time

from redash_client.client import RedashClient
from redash_client.constants import (
VizWidth, VizType, ChartType, TimeInterval)

Expand Down Expand Up @@ -37,7 +38,7 @@ class SummaryDashboard(object):
class SummaryDashboardException(Exception):
pass

def __init__(self, redash_client, dash_name, events_table_name,
def __init__(self, api_key, dash_name, events_table_name,
start_date, end_date=None):
self._dash_name = dash_name
self._events_table = events_table_name
Expand All @@ -48,7 +49,7 @@ def __init__(self, redash_client, dash_name, events_table_name,
"end_date": self._end_date
}

self.redash = redash_client
self.redash = RedashClient(api_key)
self._dash_id = self.redash.create_new_dashboard(self._dash_name)
self.redash.publish_dashboard(self._dash_id)
self.public_url = self.redash.get_public_url(self._dash_id)
Expand Down
6 changes: 1 addition & 5 deletions stmoab/dashboard_instances/sample.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

from redash_client.client import RedashClient

from stmoab.StatisticalDashboard import StatisticalDashboard

'''
Expand Down Expand Up @@ -179,14 +177,12 @@
aws_secret_key = os.environ['AWS_SECRET_KEY']
s3_bucket_id_stats = os.environ['S3_BUCKET_ID_STATS']

redash_client = RedashClient(api_key)

PING_CENTRE_TTABLE = "Statistical Analysis - Ping Centre"
UT_TTABLE = "Statistical Analysis - UT"
UT_HOURLY_TTABLE = "Statistical Analysis (Per Active Hour) - UT"

dash = StatisticalDashboard(
redash_client,
api_key,
"Activity Stream System Addon Experiment",
"57 Release",
"pref-flip-activity-stream-57-release-enabled-existing-users-bug-1415966",
Expand Down
9 changes: 3 additions & 6 deletions stmoab/tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import json
import unittest

from redash_client.client import RedashClient
from stmoab.SummaryDashboard import SummaryDashboard


Expand Down Expand Up @@ -39,17 +38,15 @@ def get_dashboard(self, api_key):
self.mock_requests_post.return_value = self.get_mock_response()

dashboard = SummaryDashboard(
self.redash,
self.API_KEY,
DASH_NAME,
EVENTS_TABLE_NAME,
START_DATE,
)
return dashboard

def setUp(self):
API_KEY = "test_key"

self.redash = RedashClient(API_KEY)
self.API_KEY = "test_key"

mock_requests_post_patcher = mock.patch(
"redash_client.client.requests.post")
Expand All @@ -66,7 +63,7 @@ def setUp(self):
self.mock_requests_delete = mock_requests_delete_patcher.start()
self.addCleanup(mock_requests_delete_patcher.stop)

self.dash = self.get_dashboard(API_KEY)
self.dash = self.get_dashboard(self.API_KEY)

def get_mock_response(self, status=200, content='{}'):
mock_response = mock.Mock()
Expand Down
2 changes: 1 addition & 1 deletion stmoab/tests/test_activity_stream_experiment_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_dashboard(self, api_key):
self.mock_requests_post.return_value = self.get_mock_response()

dashboard = ActivityStreamExperimentDashboard(
self.redash,
self.API_KEY,
self.DASH_PROJECT,
self.DASH_NAME,
self.EXPERIMENT_ID,
Expand Down
2 changes: 1 addition & 1 deletion stmoab/tests/test_statistical_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_dashboard(self, api_key):
self.addCleanup(mock_boto_transfer_patcher.stop)

dashboard = StatisticalDashboard(
self.redash,
self.API_KEY,
self.AWS_ACCESS_KEY,
self.AWS_SECRET_KEY,
self.AWS_BUCKET_ID,
Expand Down

0 comments on commit 1081457

Please sign in to comment.