<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 DV360 Bulk Editor
Allows bulk editing DV360 through Sheets and BigQuery.
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
Step1:  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
Step2:  3. Enter DV360 Bulk Editor Recipe Parameters
Select Load Partners, then click Save + Run, then a sheet called DV Editor  will be created.
In the Partners sheet tab, fill in Filter column then select Load Advertisers, click Save + Run.
In the Advertisers sheet tab, fill in Filter column then select Load Campaigns, click Save + Run.
In the Campaigns sheet tab, fill in Filter column, optional.
Then select Load Insertion Orders And Line Items, click Save + Run.
To update values, make changes on all Edit columns.
Select Preview, then Save + Run.
Check the Audit and Preview tabs to verify commit.
To commit changes, select Update, then Save + Run.
Check the Success and Error tabs.
Update can be run multiple times.
Update ONLY changes fields that do not match their original value.
Insert operates only on Edit columns, ignores orignal value columns.
Carefull when using drag to copy rows, values are incremented automatically.
Modify audit logic by visting BigQuery and changing the views.
Modify the values below for your use case, can be done multiple times, then click play.
Step3:  4. Execute DV360 Bulk Editor
This does NOT need to be modified unless you are changing the recipe, click play.
<ASSISTANT_TASK:>
Python Code:
!pip install git+https://github.com/google/starthinker
Explanation: DV360 Bulk Editor
Allows bulk editing DV360 through Sheets and BigQuery.
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_dv':'user',  # Credentials used for dv.
  'auth_sheet':'user',  # Credentials used for sheet.
  'auth_bigquery':'service',  # Credentials used for bigquery.
  'recipe_name':'',  # Name of Google Sheet to create.
  'recipe_slug':'',  # Name of Google BigQuery dataset to create.
  'command':'Load Partners',  # Action to take.
}
print("Parameters Set To: %s" % FIELDS)
Explanation: 3. Enter DV360 Bulk Editor Recipe Parameters
Select Load Partners, then click Save + Run, then a sheet called DV Editor  will be created.
In the Partners sheet tab, fill in Filter column then select Load Advertisers, click Save + Run.
In the Advertisers sheet tab, fill in Filter column then select Load Campaigns, click Save + Run.
In the Campaigns sheet tab, fill in Filter column, optional.
Then select Load Insertion Orders And Line Items, click Save + Run.
To update values, make changes on all Edit columns.
Select Preview, then Save + Run.
Check the Audit and Preview tabs to verify commit.
To commit changes, select Update, then Save + Run.
Check the Success and Error tabs.
Update can be run multiple times.
Update ONLY changes fields that do not match their original value.
Insert operates only on Edit columns, ignores orignal value columns.
Carefull when using drag to copy rows, values are incremented automatically.
Modify audit logic by visting BigQuery and changing the views.
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 = [
  {
    'dataset':{
      '__comment__':'Ensure dataset exists.',
      'auth':{'field':{'name':'auth_bigquery','kind':'authentication','order':1,'default':'service','description':'Credentials used for writing data.'}},
      'dataset':{'field':{'name':'recipe_slug','prefix':'DV_Editor_','kind':'string','order':2,'default':'','description':'Name of Google BigQuery dataset to create.'}}
    }
  },
  {
    'drive':{
      '__comment__':'Copy the default template to sheet with the recipe name',
      'auth':{'field':{'name':'auth_sheet','kind':'authentication','order':1,'default':'user','description':'Credentials used for reading data.'}},
      'copy':{
        'source':'https://docs.google.com/spreadsheets/d/18G6cGo4j5SsY08H8P53R22D_Pm6m-zkE6APd3EDLf2c/',
        'destination':{'field':{'name':'recipe_name','prefix':'DV Editor ','kind':'string','order':3,'default':'','description':'Name of Google Sheet to create.'}}
      }
    }
  },
  {
    'dv_editor':{
      '__comment':'Depending on users choice, execute a different part of the solution.',
      'auth_dv':{'field':{'name':'auth_dv','kind':'authentication','order':1,'default':'user','description':'Credentials used for dv.'}},
      'auth_sheets':{'field':{'name':'auth_sheet','kind':'authentication','order':2,'default':'user','description':'Credentials used for sheet.'}},
      'auth_bigquery':{'field':{'name':'auth_bigquery','kind':'authentication','order':3,'default':'service','description':'Credentials used for bigquery.'}},
      'sheet':{'field':{'name':'recipe_name','prefix':'DV Editor ','kind':'string','order':4,'default':'','description':'Name of Google Sheet to create.'}},
      'dataset':{'field':{'name':'recipe_slug','prefix':'DV_Editor_','kind':'string','order':5,'default':'','description':'Name of Google BigQuery dataset to create.'}},
      'command':{'field':{'name':'command','kind':'choice','choices':['Clear Partners','Clear Advertisers','Clear Campaigns','Clear Insertion Orders And Line Items','Clear Preview','Clear Update','Load Partners','Load Advertisers','Load Campaigns','Load Insertion Orders And Line Items','Preview','Update'],'order':6,'default':'Load Partners','description':'Action to take.'}}
    }
  }
]
json_set_fields(TASKS, FIELDS)
execute(CONFIG, TASKS, force=True)
Explanation: 4. Execute DV360 Bulk Editor
This does NOT need to be modified unless you are changing the recipe, click play.
End of explanation
<END_TASK>