(ctx, **kwargs)
\b
    - DESCRIPTION:
        A predict dsl generator.
        Before using predict dsl generator, users should prepare:
            1. name list of component which you are going to use in predict progress,
            2. the train dsl file path you specified in train progress.
        \b
        Notice that users can choose to specify the component name list by using a text file,
        or, by typing in terminal. We, however, strongly recommend users using prepared files
        to specify the component list in order to avoid some unnecessary mistakes.

    \b
    - USAGE:
        flow job dsl --cpn-path fate_flow/examples/component_list.txt --train-dsl-path fate_flow/examples/test_hetero_lr_job_dsl.json -o fate_flow/examples/
        flow job dsl --cpn-list "dataio_0, hetero_feature_binning_0, hetero_feature_selection_0, evaluation_0" --train-dsl-path fate_flow/examples/test_hetero_lr_job_dsl.json -o fate_flow/examples/
        flow job dsl --cpn-list [dataio_0,hetero_feature_binning_0,hetero_feature_selection_0,evaluation_0] --train-dsl-path fate_flow/examples/test_hetero_lr_job_dsl.json -o fate_flow/examples/
\b
    - DESCRIPTION:
        A predict dsl generator.
        Before using predict dsl generator, users should prepare:
            1. name list of component which you are going to use in predict progress,
            2. the train dsl file path you specified in train progress.
        \b
        Notice that users can choose to specify the component name list by using a text file,
        or, by typing in terminal. We, however, strongly recommend users using prepared files
        to specify the component list in order to avoid some unnecessary mistakes.
\ b - DESCRIPTION : A predict dsl generator . Before using predict dsl generator users should prepare : 1 . name list of component which you are going to use in predict progress 2 . the train dsl file path you specified in train progress . \ b Notice that users can choose to specify the component name list by using a text file or by typing in terminal . We however strongly recommend users using prepared files to specify the component list in order to avoid some unnecessary mistakes .
def dsl_generator(ctx, **kwargs):
    """
    \b
    - DESCRIPTION:
        A predict dsl generator.
        Before using predict dsl generator, users should prepare:
            1. name list of component which you are going to use in predict progress,
            2. the train dsl file path you specified in train progress.
        \b
        Notice that users can choose to specify the component name list by using a text file,
        or, by typing in terminal. We, however, strongly recommend users using prepared files
        to specify the component list in order to avoid some unnecessary mistakes.

    \b
    - USAGE:
        flow job dsl --cpn-path fate_flow/examples/component_list.txt --train-dsl-path fate_flow/examples/test_hetero_lr_job_dsl.json -o fate_flow/examples/
        flow job dsl --cpn-list "dataio_0, hetero_feature_binning_0, hetero_feature_selection_0, evaluation_0" --train-dsl-path fate_flow/examples/test_hetero_lr_job_dsl.json -o fate_flow/examples/
        flow job dsl --cpn-list [dataio_0,hetero_feature_binning_0,hetero_feature_selection_0,evaluation_0] --train-dsl-path fate_flow/examples/test_hetero_lr_job_dsl.json -o fate_flow/examples/
    """
    if kwargs.get("cpn_list"):
        cpn_str = kwargs.get("cpn_list")
    elif kwargs.get("cpn_path"):
        with open(kwargs.get("cpn_path"), "r") as fp:
            cpn_str = fp.read()
    else:
        cpn_str = ""

    with open(kwargs.get("train_dsl_path"), "r") as ft:
        train_dsl = ft.read()

    config_data = {
        "cpn_str": cpn_str,
        "train_dsl": train_dsl,
        "version": "2",
    }

    if kwargs.get("output_path"):
        dsl_filename = "predict_dsl_{}.json".format(datetime.now().strftime('%Y%m%d%H%M%S'))
        output_path = os.path.join(check_abs_path(kwargs.get("output_path")), dsl_filename)
        config_data["filename"] = dsl_filename

        with closing(access_server('post', ctx, 'job/dsl/generate', config_data, False, stream=True)) as response:
            if response.status_code == 200:
                os.makedirs(os.path.dirname(output_path), exist_ok=True)
                with open(output_path, "wb") as fw:
                    for chunk in response.iter_content(1024):
                        if chunk:
                            fw.write(chunk)
                res = {'retcode': 0,
                       'retmsg': "New predict dsl file has been generated successfully. "
                                 "File path is: {}".format(output_path)}
            else:
                try:
                    res = response.json() if isinstance(response, requests.models.Response) else response
                except Exception:
                    res = {'retcode': 100,
                           'retmsg': "New predict dsl file generated failed."
                                     "For more details, please check logs/fate_flow/fate_flow_stat.log"}
        prettify(res)
    else:
        access_server('post', ctx, 'job/dsl/generate', config_data)
def dsl_generator ( ctx , * * kwargs ) : if kwargs . get ( "cpn_list" ) : cpn_str = kwargs . get ( "cpn_list" ) elif kwargs . get ( "cpn_path" ) : with open ( kwargs . get ( "cpn_path" ) , "r" ) as fp : cpn_str = fp . read ( ) else : cpn_str = "" with open ( kwargs . get ( "train_dsl_path" ) , "r" ) as ft : train_dsl = ft . read ( ) config_data = { "cpn_str" : cpn_str , "train_dsl" : train_dsl , "version" : "2" , } if kwargs . get ( "output_path" ) : dsl_filename = "predict_dsl_{}.json" . format ( datetime . now ( ) . strftime ( '%Y%m%d%H%M%S' ) ) output_path = os . path . join ( check_abs_path ( kwargs . get ( "output_path" ) ) , dsl_filename ) config_data [ "filename" ] = dsl_filename with closing ( access_server ( 'post' , ctx , 'job/dsl/generate' , config_data , False , stream = True ) ) as response : if response . status_code == 200 : os . makedirs ( os . path . dirname ( output_path ) , exist_ok = True ) with open ( output_path , "wb" ) as fw : for chunk in response . iter_content ( 1024 ) : if chunk : fw . write ( chunk ) res = { 'retcode' : 0 , 'retmsg' : "New predict dsl file has been generated successfully. " "File path is: {}" . format ( output_path ) } else : try : res = response . json ( ) if isinstance ( response , requests . models . Response ) else response except Exception : res = { 'retcode' : 100 , 'retmsg' : "New predict dsl file generated failed." "For more details, please check logs/fate_flow/fate_flow_stat.log" } prettify ( res ) else : access_server ( 'post' , ctx , 'job/dsl/generate' , config_data )