@@ -106,7 +106,7 @@ def drop_tables(tables, datasource):
106106 if table != "" :
107107 drop_sql = "DROP TABLE IF EXISTS %s" % table
108108 db .execute (conn , drop_sql )
109- except :
109+ except : # noqa: E722
110110 # odps will clear table itself, so even fail here, we do
111111 # not need to raise error
112112 print ("Encounter error on drop tmp table" )
@@ -311,7 +311,8 @@ def get_pai_tf_cmd(cluster_config, tarball, params_file, entry_file,
311311 job_name = "_" .join (["sqlflow" , model_name ]).replace ("." , "_" )
312312 cf_quote = json .dumps (cluster_config ).replace ("\" " , "\\ \" " )
313313
314- # submit table should format as: odps://<project>/tables/<table >,odps://<project>/tables/<table > ...
314+ # submit table should format as: odps://<project>/tables/<table >,
315+ # odps://<project>/tables/<table > ...
315316 submit_tables = max_compute_table_url (train_table )
316317 if train_table != val_table and val_table :
317318 val_table = max_compute_table_url (val_table )
@@ -321,7 +322,8 @@ def get_pai_tf_cmd(cluster_config, tarball, params_file, entry_file,
321322 table = max_compute_table_url (res_table )
322323 output_tables = "-Doutputs=%s" % table
323324
324- # NOTE(typhoonzero): use - DhyperParameters to define flags passing OSS credentials.
325+ # NOTE(typhoonzero): use - DhyperParameters to define flags passing
326+ # OSS credentials.
325327 # TODO(typhoonzero): need to find a more secure way to pass credentials.
326328 cmd = ("pai -name tensorflow1150 -project algo_public_dev "
327329 "-DmaxHungTimeBeforeGCInSeconds=0 -DjobName=%s -Dtags=dnn "
@@ -333,8 +335,8 @@ def get_pai_tf_cmd(cluster_config, tarball, params_file, entry_file,
333335 oss_checkpoint_configs = os .getenv ("SQLFLOW_OSS_CHECKPOINT_CONFIG" )
334336 if not oss_checkpoint_configs :
335337 raise SQLFlowDiagnostic (
336- "need to configure SQLFLOW_OSS_CHECKPOINT_CONFIG when submitting to PAI "
337- )
338+ "need to configure SQLFLOW_OSS_CHECKPOINT_CONFIG when "
339+ "submitting to PAI" )
338340 ckpt_conf = json .loads (oss_checkpoint_configs )
339341 model_url = get_oss_model_url (oss_model_path )
340342 role_name = get_project_role_name (project )
@@ -406,7 +408,8 @@ def submit_pai_train(datasource, estimator_string, select, validation_select,
406408
407409 Args:
408410 datasource: string
409- Like: odps://access_id:access_key@service.com/api?curr_project=test_ci&scheme=http
411+ Like: odps://access_id:access_key@service.com/api?
412+ curr_project=test_ci&scheme=http
410413 estimator_string: string
411414 Tensorflow estimator name, Keras class name, or XGBoost
412415 select: string
@@ -489,8 +492,9 @@ def get_oss_saved_model_type_and_estimator(model_name, project):
489492 If model is TensorFlow model, return type and estimator name
490493 If model is XGBoost, or other PAI model, just return model type
491494 """
492- # FIXME(typhoonzero): if the model not exist on OSS, assume it's a random forest model
493- # should use a general method to fetch the model and see the model type.
495+ # FIXME(typhoonzero): if the model not exist on OSS, assume it's a random
496+ # forest model should use a general method to fetch the model and see the
497+ # model type.
494498 bucket = oss .get_models_bucket ()
495499 tf = bucket .object_exists (model_name + "/tensorflow_model_desc" )
496500 if tf :
@@ -529,9 +533,10 @@ def get_pai_predict_cmd(cluster_conf, datasource, project, oss_model_path,
529533 Returns:
530534 The command to submit PAI prediction task
531535 """
532- # NOTE(typhoonzero): for PAI machine learning toolkit predicting, we can not load the TrainStmt
533- # since the model saving is fully done by PAI. We directly use the columns in SELECT
534- # statement for prediction, error will be reported by PAI job if the columns not match.
536+ # NOTE(typhoonzero): for PAI machine learning toolkit predicting, we can
537+ # not load the TrainStmt since the model saving is fully done by PAI.
538+ # We directly use the columns in SELECT statement for prediction, error
539+ # will be reported by PAI job if the columns not match.
535540 conn = db .connect_with_data_source (datasource )
536541 if model_type == EstimatorType .PAIML :
537542 schema = db .get_table_schema (conn , predict_table )
@@ -621,13 +626,13 @@ def submit_pai_predict(datasource, select, result_table, label_column,
621626 params = dict (locals ())
622627
623628 cwd = tempfile .mkdtemp (prefix = "sqlflow" , dir = "/tmp" )
624- # TODO(typhoonzero): Do **NOT** create tmp table when the select statement is like:
625- # "SELECT fields,... FROM table"
629+ # TODO(typhoonzero): Do **NOT** create tmp table when the select statement
630+ # is like: "SELECT fields,... FROM table"
626631 data_table = create_tmp_table_from_select (select , datasource )
627632 params ["data_table" ] = data_table
628633
629- # format resultTable name to "db.table" to let the codegen form a submitting
630- # argument of format "odps://project/tables/table_name"
634+ # format resultTable name to "db.table" to let the codegen form a
635+ # submitting argument of format "odps://project/tables/table_name"
631636 project = get_project (datasource )
632637 if result_table .count ("." ) == 0 :
633638 result_table = "%s.%s" % (project , result_table )
@@ -740,9 +745,10 @@ def get_explain_random_forests_cmd(datasource, model_name, data_table,
740745 Returns:
741746 a PAI cmd to explain the data using given model
742747 """
743- # NOTE(typhoonzero): for PAI random forests predicting, we can not load the TrainStmt
744- # since the model saving is fully done by PAI. We directly use the columns in SELECT
745- # statement for prediction, error will be reported by PAI job if the columns not match.
748+ # NOTE(typhoonzero): for PAI random forests predicting, we can not load
749+ # the TrainStmt since the model saving is fully done by PAI. We directly
750+ # use the columns in SELECT statement for prediction, error will be
751+ # reported by PAI job if the columns not match.
746752 if not label_column :
747753 raise SQLFlowDiagnostic ("must specify WITH label_column when using "
748754 "pai random forest to explain models" )
@@ -752,11 +758,12 @@ def get_explain_random_forests_cmd(datasource, model_name, data_table,
752758 db .execute (conn , "DROP TABLE IF EXISTS %s;" % result_table )
753759 schema = db .get_table_schema (conn , data_table )
754760 fields = [f [0 ] for f in schema if f [0 ] != label_column ]
755- return (
756- '''pai -name feature_importance -project algo_public '''
757- '''-DmodelName="%s" -DinputTableName="%s" '''
758- '''-DoutputTableName="%s" -DlabelColName="%s" -DfeatureColNames="%s" '''
759- ) % (model_name , data_table , result_table , label_column , "," .join (fields ))
761+ return ('''pai -name feature_importance -project algo_public '''
762+ '''-DmodelName="%s" -DinputTableName="%s" '''
763+ '''-DoutputTableName="%s" -DlabelColName="%s" '''
764+ '''-DfeatureColNames="%s" ''' ) % (model_name , data_table ,
765+ result_table , label_column ,
766+ "," .join (fields ))
760767
761768
762769def submit_pai_explain (datasource , select , result_table , model_name ,
@@ -774,13 +781,13 @@ def submit_pai_explain(datasource, select, result_table, model_name,
774781 params = dict (locals ())
775782
776783 cwd = tempfile .mkdtemp (prefix = "sqlflow" , dir = "/tmp" )
777- # TODO(typhoonzero): Do **NOT** create tmp table when the select statement is like:
778- # "SELECT fields,... FROM table"
784+ # TODO(typhoonzero): Do **NOT** create tmp table when the select statement
785+ # is like: "SELECT fields,... FROM table"
779786 data_table = create_tmp_table_from_select (select , datasource )
780787 params ["data_table" ] = data_table
781788
782- # format resultTable name to "db.table" to let the codegen form a submitting
783- # argument of format "odps://project/tables/table_name"
789+ # format resultTable name to "db.table" to let the codegen form a
790+ # submitting argument of format "odps://project/tables/table_name"
784791 project = get_project (datasource )
785792 if result_table .count ("." ) == 0 :
786793 result_table = "%s.%s" % (project , result_table )
0 commit comments