def label_dataset(dataset_id, label_key, label_value, project_id=None):
 (credentials, default_project_id) = google.auth.default(scopes=['https://www.googleapis.com/auth/bigquery'])
 session = google.auth.transport.requests.AuthorizedSession(credentials)
 if (project_id is None):
  project_id = default_project_id
 url_format = 'https://www.googleapis.com/bigquery/v2/projects/{project_id}/datasets/{dataset_id}'
 response = session.patch(url_format.format(project_id=project_id, dataset_id=dataset_id), params={'fields': 'labels'}, json={'labels': {label_key: label_value}})
 response.raise_for_status()
 labels = response.json()['labels']
 print 'Updated label "{}" with value "{}"'.format(label_key, labels[label_key])

def label_dataset ( dataset_id , label_key , label_value , project_id = None ) : ( credentials , default_project_id ) = google . auth . default ( scopes = [ 'https://www.googleapis.com/auth/bigquery' ] ) session = google . auth . transport . requests . AuthorizedSession ( credentials ) if ( project_id is None ) : project_id = default_project_id url_format = 'https://www.googleapis.com/bigquery/v2/projects/{project_id}/datasets/{dataset_id}' response = session . patch ( url_format . format ( project_id = project_id , dataset_id = dataset_id ) , params = { 'fields' : 'labels' } , json = { 'labels' : { label_key : label_value } } ) response . raise_for_status ( ) labels = response . json ( ) [ 'labels' ] print 'Updated label "{}" with value "{}"' . format ( label_key , labels [ label_key ] )
add or modify a label on a dataset .