Skip to content

Commit 41c9d64

Browse files
committed
fix line limit
1 parent 5828ce4 commit 41c9d64

14 files changed

+209
-71
lines changed

language/automl/automl_natural_language_dataset.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ def get_dataset(project_id, compute_region, dataset_id):
122122
client = automl.AutoMlClient()
123123

124124
# Get the full path of the dataset
125-
dataset_full_id = client.dataset_path(project_id, compute_region, dataset_id)
125+
dataset_full_id = client.dataset_path(
126+
project_id, compute_region, dataset_id
127+
)
126128

127129
# Get complete detail of the dataset.
128130
dataset = client.get_dataset(dataset_full_id)
@@ -156,7 +158,9 @@ def import_data(project_id, compute_region, dataset_id, path):
156158
client = automl.AutoMlClient()
157159

158160
# Get the full path of the dataset.
159-
dataset_full_id = client.dataset_path(project_id, compute_region, dataset_id)
161+
dataset_full_id = client.dataset_path(
162+
project_id, compute_region, dataset_id
163+
)
160164

161165
# Get the multiple Google Cloud Storage URIs.
162166
input_uris = path.split(",")
@@ -185,7 +189,9 @@ def export_data(project_id, compute_region, dataset_id, output_uri):
185189
client = automl.AutoMlClient()
186190

187191
# Get the full path of the dataset.
188-
dataset_full_id = client.dataset_path(project_id, compute_region, dataset_id)
192+
dataset_full_id = client.dataset_path(
193+
project_id, compute_region, dataset_id
194+
)
189195

190196
# Set the output URI
191197
output_config = {"gcs_destination": {"output_uri_prefix": output_uri}}
@@ -212,7 +218,9 @@ def delete_dataset(project_id, compute_region, dataset_id):
212218
client = automl.AutoMlClient()
213219

214220
# Get the full path of the dataset.
215-
dataset_full_id = client.dataset_path(project_id, compute_region, dataset_id)
221+
dataset_full_id = client.dataset_path(
222+
project_id, compute_region, dataset_id
223+
)
216224

217225
# Delete a dataset.
218226
response = client.delete_dataset(dataset_full_id)
@@ -226,7 +234,8 @@ def delete_dataset(project_id, compute_region, dataset_id):
226234

227235
if __name__ == "__main__":
228236
parser = argparse.ArgumentParser(
229-
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
237+
description=__doc__,
238+
formatter_class=argparse.RawDescriptionHelpFormatter,
230239
)
231240
subparsers = parser.add_subparsers(dest="command")
232241

@@ -245,14 +254,20 @@ def delete_dataset(project_id, compute_region, dataset_id):
245254
"filter_", nargs="?", default="text_classification_dataset_metadata:*"
246255
)
247256

248-
get_dataset_parser = subparsers.add_parser("get_dataset", help=get_dataset.__doc__)
257+
get_dataset_parser = subparsers.add_parser(
258+
"get_dataset", help=get_dataset.__doc__
259+
)
249260
get_dataset_parser.add_argument("dataset_id")
250261

251-
import_data_parser = subparsers.add_parser("import_data", help=import_data.__doc__)
262+
import_data_parser = subparsers.add_parser(
263+
"import_data", help=import_data.__doc__
264+
)
252265
import_data_parser.add_argument("dataset_id")
253266
import_data_parser.add_argument("path")
254267

255-
export_data_parser = subparsers.add_parser("export_data", help=export_data.__doc__)
268+
export_data_parser = subparsers.add_parser(
269+
"export_data", help=export_data.__doc__
270+
)
256271
export_data_parser.add_argument("dataset_id")
257272
export_data_parser.add_argument("output_uri")
258273

@@ -268,14 +283,18 @@ def delete_dataset(project_id, compute_region, dataset_id):
268283

269284
if args.command == "create_dataset":
270285
multilabel = True if args.multilabel == "True" else False
271-
create_dataset(project_id, compute_region, args.dataset_name, multilabel)
286+
create_dataset(
287+
project_id, compute_region, args.dataset_name, multilabel
288+
)
272289
if args.command == "list_datasets":
273290
list_datasets(project_id, compute_region, args.filter_)
274291
if args.command == "get_dataset":
275292
get_dataset(project_id, compute_region, args.dataset_id)
276293
if args.command == "import_data":
277294
import_data(project_id, compute_region, args.dataset_id, args.path)
278295
if args.command == "export_data":
279-
export_data(project_id, compute_region, args.dataset_id, args.output_uri)
296+
export_data(
297+
project_id, compute_region, args.dataset_id, args.output_uri
298+
)
280299
if args.command == "delete_dataset":
281300
delete_dataset(project_id, compute_region, args.dataset_id)

language/automl/automl_natural_language_model.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ def list_model_evaluations(project_id, compute_region, model_id, filter_):
199199

200200

201201
# [START automl_natural_language_get_model_evaluation]
202-
def get_model_evaluation(project_id, compute_region, model_id, model_evaluation_id):
202+
def get_model_evaluation(
203+
project_id, compute_region, model_id, model_evaluation_id
204+
):
203205
"""Get model evaluation.
204206
Args:
205207
project_id: Id of the project.
@@ -322,7 +324,8 @@ def delete_model(project_id, compute_region, model_id):
322324

323325
if __name__ == "__main__":
324326
parser = argparse.ArgumentParser(
325-
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
327+
description=__doc__,
328+
formatter_class=argparse.RawDescriptionHelpFormatter,
326329
)
327330
subparsers = parser.add_subparsers(dest="command")
328331

@@ -337,7 +340,9 @@ def delete_model(project_id, compute_region, model_id):
337340
)
338341
get_operation_status_parser.add_argument("operation_full_id")
339342

340-
list_models_parser = subparsers.add_parser("list_models", help=list_models.__doc__)
343+
list_models_parser = subparsers.add_parser(
344+
"list_models", help=list_models.__doc__
345+
)
341346
list_models_parser.add_argument("filter_")
342347

343348
get_model_parser = subparsers.add_parser(
@@ -349,7 +354,9 @@ def delete_model(project_id, compute_region, model_id):
349354
"list_model_evaluations", help=list_model_evaluations.__doc__
350355
)
351356
list_model_evaluations_parser.add_argument("model_id")
352-
list_model_evaluations_parser.add_argument("filter_", nargs="?", default="")
357+
list_model_evaluations_parser.add_argument(
358+
"filter_", nargs="?", default=""
359+
)
353360

354361
get_model_evaluation_parser = subparsers.add_parser(
355362
"get_model_evaluation", help=get_model_evaluation.__doc__
@@ -374,20 +381,26 @@ def delete_model(project_id, compute_region, model_id):
374381
args = parser.parse_args()
375382

376383
if args.command == "create_model":
377-
create_model(project_id, compute_region, args.dataset_id, args.model_name)
384+
create_model(
385+
project_id, compute_region, args.dataset_id, args.model_name
386+
)
378387
if args.command == "get_operation_status":
379388
get_operation_status(args.operation_full_id)
380389
if args.command == "list_models":
381390
list_models(project_id, compute_region, args.filter_)
382391
if args.command == "get_model":
383392
get_model(project_id, compute_region, args.model_id)
384393
if args.command == "list_model_evaluations":
385-
list_model_evaluations(project_id, compute_region, args.model_id, args.filter_)
394+
list_model_evaluations(
395+
project_id, compute_region, args.model_id, args.filter_
396+
)
386397
if args.command == "get_model_evaluation":
387398
get_model_evaluation(
388399
project_id, compute_region, args.model_id, args.model_evaluation_id
389400
)
390401
if args.command == "display_evaluation":
391-
display_evaluation(project_id, compute_region, args.model_id, args.filter_)
402+
display_evaluation(
403+
project_id, compute_region, args.model_id, args.filter_
404+
)
392405
if args.command == "delete_model":
393406
delete_model(project_id, compute_region, args.model_id)

language/automl/automl_natural_language_predict.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def predict(project_id, compute_region, model_id, file_path):
4545
prediction_client = automl.PredictionServiceClient()
4646

4747
# Get the full path of the model.
48-
model_full_id = automl_client.model_path(project_id, compute_region, model_id)
48+
model_full_id = automl_client.model_path(
49+
project_id, compute_region, model_id
50+
)
4951

5052
# Read the file content for prediction.
5153
with open(file_path, "rb") as content_file:
@@ -69,7 +71,8 @@ def predict(project_id, compute_region, model_id, file_path):
6971

7072
if __name__ == "__main__":
7173
parser = argparse.ArgumentParser(
72-
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
74+
description=__doc__,
75+
formatter_class=argparse.RawDescriptionHelpFormatter,
7376
)
7477
subparsers = parser.add_subparsers(dest="command")
7578

language/automl/dataset_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,17 @@ def test_dataset_create_import_delete(capsys):
5353

5454
def test_dataset_list_get(capsys):
5555
# list datasets
56-
automl_natural_language_dataset.list_datasets(project_id, compute_region, "")
56+
automl_natural_language_dataset.list_datasets(
57+
project_id, compute_region, ""
58+
)
5759
out, _ = capsys.readouterr()
5860
list_dataset_output = out.splitlines()
5961
assert "Dataset id: " in list_dataset_output[2]
6062

6163
# get dataset
6264
dataset_id = list_dataset_output[2].split()[2]
63-
automl_natural_language_dataset.get_dataset(project_id, compute_region, dataset_id)
65+
automl_natural_language_dataset.get_dataset(
66+
project_id, compute_region, dataset_id
67+
)
6468
out, _ = capsys.readouterr()
6569
assert "Dataset name: " in out

language/automl/model_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def test_model_list_get_evaluate(capsys):
5555

5656
# get model
5757
model_id = list_models_output[2].split()[2]
58-
automl_natural_language_model.get_model(project_id, compute_region, model_id)
58+
automl_natural_language_model.get_model(
59+
project_id, compute_region, model_id
60+
)
5961
out, _ = capsys.readouterr()
6062
assert "Model name: " in out
6163

translate/automl/automl_translation_dataset.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ def create_dataset(project_id, compute_region, dataset_name, source, target):
4646
project_location = client.location_path(project_id, compute_region)
4747

4848
# Specify the source and target language.
49-
dataset_metadata = {"source_language_code": source, "target_language_code": target}
49+
dataset_metadata = {
50+
"source_language_code": source,
51+
"target_language_code": target,
52+
}
5053
# Set dataset name and dataset metadata
5154
my_dataset = {
5255
"display_name": dataset_name,
@@ -131,7 +134,9 @@ def get_dataset(project_id, compute_region, dataset_id):
131134
client = automl.AutoMlClient()
132135

133136
# Get the full path of the dataset
134-
dataset_full_id = client.dataset_path(project_id, compute_region, dataset_id)
137+
dataset_full_id = client.dataset_path(
138+
project_id, compute_region, dataset_id
139+
)
135140

136141
# Get complete detail of the dataset.
137142
dataset = client.get_dataset(dataset_full_id)
@@ -172,7 +177,9 @@ def import_data(project_id, compute_region, dataset_id, path):
172177
client = automl.AutoMlClient()
173178

174179
# Get the full path of the dataset.
175-
dataset_full_id = client.dataset_path(project_id, compute_region, dataset_id)
180+
dataset_full_id = client.dataset_path(
181+
project_id, compute_region, dataset_id
182+
)
176183

177184
# Get the multiple Google Cloud Storage URIs
178185
input_uris = path.split(",")
@@ -200,7 +207,9 @@ def delete_dataset(project_id, compute_region, dataset_id):
200207
client = automl.AutoMlClient()
201208

202209
# Get the full path of the dataset.
203-
dataset_full_id = client.dataset_path(project_id, compute_region, dataset_id)
210+
dataset_full_id = client.dataset_path(
211+
project_id, compute_region, dataset_id
212+
)
204213

205214
# Delete a dataset.
206215
response = client.delete_dataset(dataset_full_id)
@@ -214,7 +223,8 @@ def delete_dataset(project_id, compute_region, dataset_id):
214223

215224
if __name__ == "__main__":
216225
parser = argparse.ArgumentParser(
217-
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
226+
description=__doc__,
227+
formatter_class=argparse.RawDescriptionHelpFormatter,
218228
)
219229
subparsers = parser.add_subparsers(dest="command")
220230

@@ -230,7 +240,9 @@ def delete_dataset(project_id, compute_region, dataset_id):
230240
)
231241
list_datasets_parser.add_argument("filter", nargs="?", default="")
232242

233-
import_data_parser = subparsers.add_parser("import_data", help=import_data.__doc__)
243+
import_data_parser = subparsers.add_parser(
244+
"import_data", help=import_data.__doc__
245+
)
234246
import_data_parser.add_argument("dataset_id")
235247
import_data_parser.add_argument("path")
236248

@@ -239,7 +251,9 @@ def delete_dataset(project_id, compute_region, dataset_id):
239251
)
240252
delete_dataset_parser.add_argument("dataset_id")
241253

242-
get_dataset_parser = subparsers.add_parser("get_dataset", help=get_dataset.__doc__)
254+
get_dataset_parser = subparsers.add_parser(
255+
"get_dataset", help=get_dataset.__doc__
256+
)
243257
get_dataset_parser.add_argument("dataset_id")
244258

245259
project_id = os.environ["PROJECT_ID"]
@@ -249,7 +263,11 @@ def delete_dataset(project_id, compute_region, dataset_id):
249263

250264
if args.command == "create_dataset":
251265
create_dataset(
252-
project_id, compute_region, args.dataset_name, args.source, args.target
266+
project_id,
267+
compute_region,
268+
args.dataset_name,
269+
args.source,
270+
args.target,
253271
)
254272
if args.command == "list_datasets":
255273
list_datasets(project_id, compute_region, args.filter)

translate/automl/automl_translation_model.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ def list_model_evaluations(project_id, compute_region, model_id, filter_):
156156

157157

158158
# [START automl_translation_get_model_evaluation]
159-
def get_model_evaluation(project_id, compute_region, model_id, model_evaluation_id):
159+
def get_model_evaluation(
160+
project_id, compute_region, model_id, model_evaluation_id
161+
):
160162
"""Get model evaluation.
161163
Args:
162164
project_id: Id of the project.
@@ -224,7 +226,8 @@ def get_operation_status(operation_full_id):
224226

225227
if __name__ == "__main__":
226228
parser = argparse.ArgumentParser(
227-
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
229+
description=__doc__,
230+
formatter_class=argparse.RawDescriptionHelpFormatter,
228231
)
229232
subparsers = parser.add_subparsers(dest="command")
230233

@@ -246,15 +249,19 @@ def get_operation_status(operation_full_id):
246249
get_model_evaluation_parser.add_argument("model_id")
247250
get_model_evaluation_parser.add_argument("model_evaluation_id")
248251

249-
get_model_parser = subparsers.add_parser("get_model", help=get_model.__doc__)
252+
get_model_parser = subparsers.add_parser(
253+
"get_model", help=get_model.__doc__
254+
)
250255
get_model_parser.add_argument("model_id")
251256

252257
get_operation_status_parser = subparsers.add_parser(
253258
"get_operation_status", help=get_operation_status.__doc__
254259
)
255260
get_operation_status_parser.add_argument("operation_full_id")
256261

257-
list_models_parser = subparsers.add_parser("list_models", help=list_models.__doc__)
262+
list_models_parser = subparsers.add_parser(
263+
"list_models", help=list_models.__doc__
264+
)
258265
list_models_parser.add_argument("filter", nargs="?", default="")
259266

260267
delete_model_parser = subparsers.add_parser(
@@ -268,13 +275,17 @@ def get_operation_status(operation_full_id):
268275
args = parser.parse_args()
269276

270277
if args.command == "create_model":
271-
create_model(project_id, compute_region, args.dataset_id, args.model_name)
278+
create_model(
279+
project_id, compute_region, args.dataset_id, args.model_name
280+
)
272281
if args.command == "list_models":
273282
list_models(project_id, compute_region, args.filter)
274283
if args.command == "get_model":
275284
get_model(project_id, compute_region, args.model_id)
276285
if args.command == "list_model_evaluations":
277-
list_model_evaluations(project_id, compute_region, args.model_id, args.filter)
286+
list_model_evaluations(
287+
project_id, compute_region, args.model_id, args.filter
288+
)
278289
if args.command == "get_model_evaluation":
279290
get_model_evaluation(
280291
project_id, compute_region, args.model_id, args.model_evaluation_id

0 commit comments

Comments
 (0)