Exemple #1
0
def output_data(ctx, **kwargs):
    """
    \b
    - DESCRIPTION:
        Download the Output Data of A Specified Component.

    \b
    - USAGE:
        flow component output-data -j $JOB_ID -r host -p 10000 -cpn hetero_feature_binning_0 --output-path ./examples/
    """
    config_data, dsl_data = preprocess(**kwargs)
    tar_file_name = 'job_{}_{}_{}_{}_output_data.tar.gz'.format(config_data['job_id'],
                                                                config_data['component_name'],
                                                                config_data['role'],
                                                                config_data['party_id'])
    extract_dir = os.path.join(config_data['output_path'], tar_file_name.replace('.tar.gz', ''))
    with closing(access_server('get', ctx, 'tracking/component/output/data/download',
                               config_data, False, stream=True)) as response:
        if response.status_code == 200:
            try:
                download_from_request(http_response=response, tar_file_name=tar_file_name, extract_dir=extract_dir)
                res = {'retcode': 0,
                       'directory': os.path.abspath(extract_dir),
                       'retmsg': 'Download successfully, please check {} directory'.format(os.path.abspath(extract_dir))}
            except:
                res = {'retcode': 100,
                       'retmsg': 'Download failed, please check if the parameters are correct.'}
        else:
            try:
                res = response.json() if isinstance(response, requests.models.Response) else response
            except Exception:
                res = {'retcode': 100,
                       'retmsg': 'Download failed, for more details please check logs/fate_flow/fate_flow_stat.log.'}
    prettify(res)
Exemple #2
0
def log(ctx, **kwargs):
    """
    \b
    - DESCRIPTION:
        Download Log Files of A Specified Job.

    \b
    - USAGE:
        flow job log -j JOB_ID --output-path ./examples/
    """
    config_data, dsl_data = preprocess(**kwargs)
    job_id = config_data['job_id']
    tar_file_name = 'job_{}_log.tar.gz'.format(job_id)
    extract_dir = os.path.join(config_data['output_path'],
                               'job_{}_log'.format(job_id))
    with closing(
            access_server('get',
                          ctx,
                          'job/log',
                          config_data,
                          False,
                          stream=True)) as response:
        if response.status_code == 200:
            download_from_request(http_response=response,
                                  tar_file_name=tar_file_name,
                                  extract_dir=extract_dir)
            res = {
                'retcode':
                0,
                'directory':
                extract_dir,
                'retmsg':
                'download successfully, please check {} directory'.format(
                    extract_dir)
            }
        else:
            res = response.json() if isinstance(
                response, requests.models.Response) else response
    prettify(res)
Exemple #3
0
def download(ctx, **kwargs):
    """
    \b
    - DESCRIPTION:
        Download template conf/dsl/data files

    \b
    - USAGE:
        flow template download --min-data 1 --output-path ./examples/
    """
    config_data, dsl_data = preprocess(**kwargs)
    tar_file_name = 'template.tar.gz'
    extract_dir = config_data['output_path']
    with closing(
            access_server('post',
                          ctx,
                          'template/download',
                          config_data,
                          False,
                          stream=True)) as response:
        if response.status_code == 200:
            download_from_request(http_response=response,
                                  tar_file_name=tar_file_name,
                                  extract_dir=extract_dir)
            res = {
                'retcode':
                0,
                'directory':
                extract_dir,
                'retmsg':
                'download successfully, please check {} directory'.format(
                    extract_dir)
            }
        else:
            res = response.json() if isinstance(
                response, requests.models.Response) else response
    prettify(res)