batch_job.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:uncover-ml 作者: GeoscienceAustralia 项目源码 文件源码
def convert_files(files, output_dir, opt, mask_file):
    comm = MPI.COMM_WORLD
    rank = comm.rank
    size = comm.size

    if mask_file:
        # temporary cropped mask file
        cropped_mask_file = tempfile.mktemp(suffix='.tif', dir=TMPDIR)

        # crop/reproject/resample the mask
        crop_reproject_resample(opt.mask_file,
                                cropped_mask_file,
                                sampling='near',
                                extents=opt.extents,
                                reproject=opt.reproject)
    else:
        cropped_mask_file = opt.mask_file

    for i in range(rank, len(files), size):
        in_file = files[i]
        print('============file no: {} of {}==========='.format(i, len(files)))
        log.info("operating on {file} in process {rank}".format(file=in_file,
                                                                rank=rank))
        out_file = join(output_dir, basename(in_file))
        log.info('Output file: {}'.format(out_file))
        do_work(input_file=in_file,
                mask_file=cropped_mask_file,
                output_file=out_file,
                options=options)

    if mask_file:
        os.remove(cropped_mask_file)
        log.info('removed intermediate cropped '
                 'mask file {}'.format(cropped_mask_file))

    comm.Barrier()


# TODO: use click here
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号