-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #807 from isb-cgc/isb-cgc-prod-sp
Sprint 31
- Loading branch information
Showing
10 changed files
with
328 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
Copyright 2018, Institute for Systems Biology | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
|
||
import logging | ||
from django.conf import settings | ||
from bq_support import BigQuerySupport | ||
|
||
logger = logging.getLogger('main_logger') | ||
|
||
MAX_INSERT = settings.MAX_BQ_INSERT | ||
|
||
|
||
class BigQueryMetricsSupport(BigQuerySupport): | ||
|
||
def __init__(self, metrics_table): | ||
super(BigQueryMetricsSupport, self).__init__(settings.BIGQUERY_PROJECT_NAME, settings.METRICS_BQ_DATASET, metrics_table) | ||
|
||
# Add rows to the metrics table specified by table | ||
# Note that this is a class method therefor the rows must be supplied formatted ready | ||
# for insertion, build_row will not be called! | ||
@classmethod | ||
def add_rows_to_table(cls, rows, table): | ||
bqs = cls(table) | ||
return bqs._streaming_insert(rows) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__author__ = 'spaquett@systemsbiology.org' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Copyright 2019, Institute for Systems Biology | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
|
||
from abc import ABCMeta, abstractmethod | ||
|
||
|
||
# Base Abstract class which defines the shared methods and properties for interaction with BigQuery | ||
class SheetsABC: | ||
__metaclass__ = ABCMeta | ||
|
||
@abstractmethod | ||
def __init__(self): | ||
pass | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
Copyright 2015-2019, Institute for Systems Biology | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
|
||
from oauth2client.client import GoogleCredentials | ||
from django.conf import settings | ||
import httplib2 | ||
from .utils import build_with_retries | ||
|
||
|
||
def get_sheet_service(): | ||
|
||
SHEETS_SCOPES = [ | ||
'https://www.googleapis.com/auth/spreadsheets' | ||
] | ||
|
||
credentials = GoogleCredentials.from_stream( | ||
settings.GOOGLE_APPLICATION_CREDENTIALS).create_scoped(SHEETS_SCOPES) | ||
http = httplib2.Http() | ||
http = credentials.authorize(http) | ||
service = build_with_retries('sheets', 'v4', None, 2, http=http) | ||
return service |
Oops, something went wrong.