コード例 #1
0

cmd_parser = argparse.ArgumentParser()
cmd_parser.add_argument('-c','--compiler', help='compiler suite and version')
cmd_parser.add_argument('--spack_base_image', help='spack base image')
cmd_parser.add_argument('-i', '--input_dir', help='input directory')
cmd_parser.add_argument('--arch_family', help='target image arch family e.g., amd64, arm64, ppc64le')
cmd_parser.add_argument('-o', '--output_dir', help='output directory')
args = cmd_parser.parse_args()


if not os.path.exists(args.input_dir):
    raise RuntimeError('Cannot open directory with templates')

template_loader = jinja2.FileSystemLoader(searchpath=args.input_dir)
template_env = jinja2.Environment(loader=template_loader)

# concretize custom builder image
Aux.print_bar()
template = template_env.get_template('Dockerfile.spack.t')
custom_builder = template.render(compiler=args.compiler,
                                 spack_base_image=args.spack_base_image,
                                 arch_family=Aux.adjust_arch_family(args.arch_family))
print(custom_builder)

if not os.path.exists(args.output_dir):
    raise RuntimeError('Cannot open the output directory')


Aux.write_to_file(file_path=os.path.join(args.output_dir, f'custom-spack-{args.arch_family}.dockerfile'), 
                  content=custom_builder)
コード例 #2
0
os_map = {
    'ubuntu-1804': 'ubuntu:18.04',
    'ubuntu-1604': 'ubuntu:16.04',
    'centos-7': 'centos:7',
    'centos-6': 'centos:6'
}

package_manager = {
    'ubuntu-1804': 'apt',
    'ubuntu-1604': 'apt',
    'centos-7': 'yum',
    'centos-6': 'yum'
}

spack_spec = template.render(
    compiler=args.compiler,
    mpi=args.mpi,
    gpu=args.gpu,
    arch_family=Aux.adjust_arch_family(args.arch_family),
    arch=args.arch,
    builder_image=args.builder_image,
    target_image=os_map[args.target_image],
    install_command=package_manager[args.target_image])
print(spack_spec)

if not os.path.exists(args.output_dir):
    raise RuntimeError('Cannot open the output directory')

Aux.write_to_file(file_path=os.path.join(args.output_dir, 'spack.yaml'),
                  content=spack_spec)