!pip install git+https://github.com/google/starthinker


"""
Explanation: 1. Install Dependencies
First install the libraries needed to execute recipes, this only needs to be done once, then click play.
End of explanation
"""


CLOUD_PROJECT = 'PASTE PROJECT ID HERE'

print("Cloud Project Set To: %s" % CLOUD_PROJECT)


"""
Explanation: 2. Get Cloud Project ID
To run this recipe requires a Google Cloud Project, this only needs to be done once, then click play.
End of explanation
"""


CLIENT_CREDENTIALS = 'PASTE CREDENTIALS HERE'

print("Client Credentials Set To: %s" % CLIENT_CREDENTIALS)


"""
Explanation: 3. Get Client Credentials
To read and write to various endpoints requires downloading client credentials, this only needs to be done once, then click play.
End of explanation
"""


FIELDS = {
  'auth': 'service',  # Credentials used for writing function.
  'dataset': '',  # Existing BigQuery dataset.
}

print("Parameters Set To: %s" % FIELDS)


"""
Explanation: 4. Enter Pearson Significance Test Function Parameters
Add function to dataset for checking if correlation is significant.
 1. Specify the dataset, and the function will be added and available.
Modify the values below for your use case, can be done multiple times, then click play.
End of explanation
"""


from starthinker.util.project import project
from starthinker.script.parse import json_set_fields

USER_CREDENTIALS = '/content/user.json'

TASKS = [
  {
    'bigquery': {
      'auth': 'user',
      'function': 'pearson_significance_test',
      'to': {
        'dataset': {'field': {'name': 'dataset','kind': 'string','order': 1,'default': '','description': 'Existing BigQuery dataset.'}}
      }
    }
  }
]

json_set_fields(TASKS, FIELDS)

project.initialize(_recipe={ 'tasks':TASKS }, _project=CLOUD_PROJECT, _user=USER_CREDENTIALS, _client=CLIENT_CREDENTIALS, _verbose=True, _force=True)
project.execute(_force=True)


"""
Explanation: 5. Execute Pearson Significance Test Function
This does NOT need to be modified unles you are changing the recipe, click play.
End of explanation
"""


