A task in StarThinker is a python function that can be executed by the framework given a set of JSON parameters called a recipe. It is just python, with a thin project singleton wrapper that pulls parameters from the command line or passed in, saving developers the trouble of re-coding common tasks like scheduling, authentication, and UI integration.
starthinker/task/hello/__init__.py
starthinker/task/hello/run.py
def hello(config, task):
print(task)
scripts/hello.json
{
"tasks":[
{ "hello":{
"auth":"user",
"say":"Hello World"
}
}
]
}
{
"setup":{
"project":"",
"auth":{
"client":{}
"service":{}
"user":{}
}
},
"tasks":[
{ "hello":{
"auth":"user",
"say":"Hello World"
}
}
]
}
source starthinker_assets/development.sh
If autherntication supplied in recipe:
python starthinker/tool/recipe.py hello.json --verbose
If authentication supplied on command line:
python starthinker/tool/recipe.py hello.json -u $STARTHINKER_USER -s $STARTHINKER_SERVICE -p $STARTHINKER_PROJECT --verbose
5. Continue to the recipe tutorial...
- The @project.from_parameters decorator is StarThinker. Everything else is just python.
- Using the util library is optional but convenient.
- Always check starthinker/task folder for task samples.
- Always check scripts folder for script samples.
- New scopes for user authentication can be added at starthinker/config.py.
- You can remove scopes if you are not planning to use the tasks requiring them.
- The Google API helper can be extended by adding an endpoint at starthinker/util/google_api/__init__.py.
- It is best practice to provide at least one or more reference recipes for a task.
- When develoing a new task, the first script should be a test script.
- Even the credentials are optional, each script is pure python parameters not tied to any Cloud Service.
- A script may call the same task multiple times with the same or different parameters.
- A script may call multiple tasks.
- Each task must have a unique name.
© 2019 Google LLC - Apache License, Version 2.0