Example #1
0
def cmd_build(args, remainder):
    with open('ci/plan.yml') as file_:
        plan = yaml.safe_load(file_)

    env = os.environ.copy()
    variant = plan['VARIANTS'][args.variant]
    for key, value in variant.get('env', {}).items():
        env[key] = str(value)

    build_root = variant.get('build_root', 'build-x86_64')
    build_type = variant.get('build_type', 'Release')
    check = variant.get('check', 'smoke')
    system = variant.get('system', 'Linux')

    temp_dir = Path('/tmp') / os.getenv('BUILDKITE_AGENT_NAME')
    build_dir = Path(build_root) / build_type
    logs_dir = Path('logs').resolve()
    logs_dir.mkdir(parents=True, exist_ok=True)

    util.printf('--- :building_construction: configure')
    configure_log = logs_dir / 'configure.log'
    with configure_log.open('wb') as fp:
        util.check_call([
            'python', 'configure', '--ci', f'--temp={temp_dir}',
            f'--type={build_type}'
        ],
                        env=env,
                        stdout=fp,
                        stderr=subprocess.STDOUT)

    util.printf('--- :hammer_and_wrench: ninja')
    util.check_call(['ninja', '-C', build_dir], env=env)

    util.printf('--- :hammer_and_wrench: ninja package')
    util.check_call(['ninja', '-C', build_dir, 'package'], env=env)

    util.printf(f'--- :hammer_and_wrench: ninja check-{check}')
    check_log = logs_dir / f'check-{check}.log'
    with check_log.open('wb') as fp:
        util.check_call(['ninja', '-C', build_dir, f'check-{check}'],
                        env=env,
                        stdout=fp,
                        stderr=subprocess.STDOUT)

    util.printf('--- Test devkit')
    devkit_dir = build_dir / '_CPack_Packages' / system / 'TGZ' / f'PlaidML-1.0.0-{system}' / 'devkit'
    devkit_build_dir = devkit_dir / 'build'
    cmd = ['cmake']
    cmd += ['-S', devkit_dir]
    cmd += ['-B', devkit_build_dir]
    cmd += ['-G', 'Ninja']
    util.check_call(cmd, env=env)
    util.check_call(['ninja', '-C', devkit_build_dir], env=env)
    util.check_call([devkit_build_dir / 'edsl_test'], env=env)

    if 'dbg' not in args.variant:
        util.buildkite_upload(build_dir / '*.whl')
        util.buildkite_upload(build_dir / '*.tar.gz')
Example #2
0
def make_all_wheels(workdir):
    util.printf('clearing workdir: {}'.format(workdir))
    shutil.rmtree(workdir, ignore_errors=True)
    workdir.mkdir(parents=True, exist_ok=True)

    util.printf('downloading wheels...')
    util.buildkite_download('*.whl', str(workdir), cwd=workdir)

    tarball = 'all_wheels.tar.gz'
    util.printf('creating {}'.format(tarball))
    with tarfile.open(tarball, "w:gz") as tar:
        for whl in workdir.glob('*.whl'):
            util.printf('adding {}'.format(whl))
            tar.add(whl, arcname=whl.name)

    util.printf('uploading {}'.format(tarball))
    util.buildkite_upload(tarball)
Example #3
0
def cmd_build(args, remainder):
    import yaml
    with open('ci/plan.yml') as file_:
        plan = yaml.safe_load(file_)

    env = os.environ.copy()
    variant = plan['VARIANTS'][args.variant]
    for key, value in variant['env'].items():
        env[key] = str(value)

    explain_log = 'explain.log'
    profile_json = 'profile.json.gz'
    bazel_config = variant.get('bazel_config')
    startup_args = ['--output_base={}'.format(output_base())]

    common_args = []
    if bazel_config:
        common_args += ['--config={}'.format(bazel_config)]
    common_args += ['--define=version={}'.format(args.version)]
    common_args += ['--experimental_generate_json_trace_profile']
    common_args += ['--experimental_json_trace_compression']
    common_args += ['--experimental_profile_cpu_usage']
    common_args += ['--explain={}'.format(explain_log)]
    common_args += ['--profile={}'.format(profile_json)]
    common_args += ['--verbose_failures']
    common_args += ['--verbose_explanations']

    util.printf('--- :bazel: Running Build...')
    if platform.system() == 'Windows':
        util.check_call(['git', 'config', 'core.symlinks', 'true'])
        cenv = util.CondaEnv(pathlib.Path('.cenv'))
        cenv.create('environment-windows.yml')
        env.update(cenv.env())
    util.check_call(['bazelisk'] + startup_args + ['test', '...'] +
                    common_args,
                    env=env)

    util.printf('--- :buildkite: Uploading artifacts...')
    util.buildkite_upload(explain_log)
    util.buildkite_upload(profile_json)

    shutil.rmtree('tmp', ignore_errors=True)
    tarball = os.path.join('bazel-bin', 'pkg.tar.gz')
    with tarfile.open(tarball, "r") as tar:
        wheels = []
        for item in tar.getmembers():
            if item.name.endswith('.whl'):
                wheels.append(item)
        tar.extractall('tmp', members=wheels)
    util.buildkite_upload('*.whl', cwd='tmp')

    variant_dir = os.path.join('tmp', 'build', args.variant)
    os.makedirs(variant_dir)
    shutil.copy(tarball, variant_dir)