(ctx, **kwargs)
\b
    - DESCRIPTION:
        Download summary of a specified component and save it as a json file.

    \b
    - USAGE:
        flow component get-summary -j $JOB_ID -r host -p 10000 -cpn hetero_feature_binning_0
        flow component get-summary -j $JOB_ID -r host -p 10000 -cpn hetero_feature_binning_0 -o ./examples/
\b
    - DESCRIPTION:
        Download summary of a specified component and save it as a json file.
\ b - DESCRIPTION : Download summary of a specified component and save it as a json file .
def get_summary(ctx, **kwargs):
    """
    \b
    - DESCRIPTION:
        Download summary of a specified component and save it as a json file.

    \b
    - USAGE:
        flow component get-summary -j $JOB_ID -r host -p 10000 -cpn hetero_feature_binning_0
        flow component get-summary -j $JOB_ID -r host -p 10000 -cpn hetero_feature_binning_0 -o ./examples/
    """
    config_data, dsl_data = preprocess(**kwargs)
    if config_data.get("output_path"):
        if not os.path.isdir(config_data.get("output_path")):
            res = {
                "retcode": 100,
                "retmsg": "Please input a valid directory path."
            }
        else:
            config_data["filename"] = "summary_{}_{}.json".format(config_data['component_name'],
                                                                  datetime.now().strftime('%Y%m%d%H%M%S'))
            config_data["output_path"] = os.path.join(check_abs_path(config_data["output_path"]), config_data["filename"])
            with closing(access_server("post", ctx, "tracking/component/summary/download",
                                       config_data, False, stream=True)) as response:
                if response.status_code == 200:
                    with open(config_data["output_path"], "wb") as fout:
                        for chunk in response.iter_content(1024):
                            if chunk:
                                fout.write(chunk)
                    res = {
                        "retcode": 0,
                        "retmsg": "The summary of component <{}> has been stored successfully. "
                                  "File path is: {}.".format(config_data["component_name"],
                                                             config_data["output_path"])
                    }
                else:
                    try:
                        res = response.json() if isinstance(response, requests.models.Response) else response
                    except Exception:
                        res = {"retcode": 100,
                               "retmsg": "Download component summary failed, "
                                         "for more details, please check logs/fate_flow/fate_flow_stat.log."}
        prettify(res)
    else:
        access_server("post", ctx, "tracking/component/summary/download", config_data)
def get_summary ( ctx , * * kwargs ) : config_data , dsl_data = preprocess ( * * kwargs ) if config_data . get ( "output_path" ) : if not os . path . isdir ( config_data . get ( "output_path" ) ) : res = { "retcode" : 100 , "retmsg" : "Please input a valid directory path." } else : config_data [ "filename" ] = "summary_{}_{}.json" . format ( config_data [ 'component_name' ] , datetime . now ( ) . strftime ( '%Y%m%d%H%M%S' ) ) config_data [ "output_path" ] = os . path . join ( check_abs_path ( config_data [ "output_path" ] ) , config_data [ "filename" ] ) with closing ( access_server ( "post" , ctx , "tracking/component/summary/download" , config_data , False , stream = True ) ) as response : if response . status_code == 200 : with open ( config_data [ "output_path" ] , "wb" ) as fout : for chunk in response . iter_content ( 1024 ) : if chunk : fout . write ( chunk ) res = { "retcode" : 0 , "retmsg" : "The summary of component <{}> has been stored successfully. " "File path is: {}." . format ( config_data [ "component_name" ] , config_data [ "output_path" ] ) } else : try : res = response . json ( ) if isinstance ( response , requests . models . Response ) else response except Exception : res = { "retcode" : 100 , "retmsg" : "Download component summary failed, " "for more details, please check logs/fate_flow/fate_flow_stat.log." } prettify ( res ) else : access_server ( "post" , ctx , "tracking/component/summary/download" , config_data )