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


"""
Explanation: Say Hello
Recipe template for say hello.
License
Copyright 2020 Google LLC,
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
https://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.
Disclaimer
This is not an officially supported Google product. It is a reference implementation. There is absolutely NO WARRANTY provided for using this code. The code is Apache Licensed and CAN BE fully modified, white labeled, and disassembled by your team.
This code generated (see starthinker/scripts for possible source):
  - Command: "python starthinker_ui/manage.py colab"
  - Command: "python starthinker/tools/colab.py [JSON RECIPE]"
1. Install Dependencies
First install the libraries needed to execute recipes, this only needs to be done once, then click play.
End of explanation
"""


from starthinker.util.configuration import Configuration


CONFIG = Configuration(
  project="",
  client={},
  service={},
  user="/content/user.json",
  verbose=True
)



"""
Explanation: 2. Set Configuration
This code is required to initialize the project. Fill in required fields and press play.

If the recipe uses a Google Cloud Project:

Set the configuration project value to the project identifier from these instructions.


If the recipe has auth set to user:

If you have user credentials:
Set the configuration user value to your user credentials JSON.



If you DO NOT have user credentials:

Set the configuration client value to downloaded client credentials.



If the recipe has auth set to service:

Set the configuration service value to downloaded service credentials.
End of explanation
"""


FIELDS = {
  'auth_read':'user',  # Credentials used for reading data.
  'say_first':'Hello Once',  # Type in a greeting.
  'say_second':'Hello Twice',  # Type in a greeting.
  'error':'',  # Optional error for testing.
  'sleep':0,  # Seconds to sleep.
}

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


"""
Explanation: 3. Enter Say Hello Recipe Parameters

This should be called for testing only.
Modify the values below for your use case, can be done multiple times, then click play.
End of explanation
"""


from starthinker.util.configuration import execute
from starthinker.util.recipe import json_set_fields

TASKS = [
  {
    'hello':{
      'auth':{'field':{'name':'auth_read','kind':'authentication','order':1,'default':'user','description':'Credentials used for reading data.'}},
      'say':{'field':{'name':'say_first','kind':'string','order':1,'default':'Hello Once','description':'Type in a greeting.'}},
      'error':{'field':{'name':'error','kind':'string','order':3,'default':'','description':'Optional error for testing.'}},
      'sleep':{'field':{'name':'sleep','kind':'integer','order':4,'default':0,'description':'Seconds to sleep.'}}
    }
  },
  {
    'hello':{
      'auth':{'field':{'name':'auth_read','kind':'authentication','order':1,'default':'user','description':'Credentials used for reading data.'}},
      'say':{'field':{'name':'say_second','kind':'string','order':1,'default':'Hello Twice','description':'Type in a greeting.'}},
      'sleep':{'field':{'name':'sleep','kind':'integer','order':4,'default':0,'description':'Seconds to sleep.'}}
    }
  }
]

json_set_fields(TASKS, FIELDS)

execute(CONFIG, TASKS, force=True)


"""
Explanation: 4. Execute Say Hello
This does NOT need to be modified unless you are changing the recipe, click play.
End of explanation
"""


