Ejemplo n.º 1
0
def get_release_body():
    """
    Generate body for release with detailed changelog
    """
    if is_git_submodule():
        docker_cmd = [
            "docker run -t -v",
            "{}/..:/app/".format(PROJ_ROOT),
            "orhunp/git-cliff:latest",
            "--config ./faabric/cliff.toml",
            "--repository ./faabric",
            "{}..v{}".format(get_release().tag_name, get_version()),
        ]
    else:
        docker_cmd = [
            "docker run -t -v",
            "{}:/app/".format(PROJ_ROOT),
            "orhunp/git-cliff:latest",
            "--config cliff.toml",
            "--repository .",
            "{}..v{}".format(get_release().tag_name, get_version()),
        ]

    cmd = " ".join(docker_cmd)
    print("Generating release body...")
    print(cmd)
    result = run(cmd, shell=True, stdout=PIPE, stderr=PIPE)

    return result.stdout.decode("utf-8")
Ejemplo n.º 2
0
def _do_container_build(name, nocache=False, push=False):
    tag_name = _get_docker_tag(name)
    ver = get_version()

    if nocache:
        no_cache_str = "--no-cache"
    else:
        no_cache_str = ""

    dockerfile = join(PROJ_ROOT, "docker", "{}.dockerfile".format(name))

    build_cmd = [
        "docker build",
        no_cache_str,
        "-t {}".format(tag_name),
        "-f {}".format(dockerfile),
        "--build-arg FAABRIC_VERSION={}".format(ver),
        ".",
    ]
    build_cmd = " ".join(build_cmd)

    print(build_cmd)
    run(build_cmd, shell=True, check=True, env={"DOCKER_BUILDKIT": "1"})

    if push:
        _do_push(name)
Ejemplo n.º 3
0
def build(ctx, c, nocache=False, push=False):
    """
    Build container images
    """
    this_version = get_version()

    for container in c:
        tag_name = "faabric/{}:{}".format(container, this_version)

        if nocache:
            no_cache_str = "--no-cache"
        else:
            no_cache_str = ""

        dockerfile = join(PROJ_ROOT, "docker", "{}.dockerfile".format(container))
        if not exists(dockerfile):
            raise Failure("Invalid container: {}".format(container))

        cmd = "docker build {} -t {} --build-arg FAABRIC_VERSION={} -f {} .".format(no_cache_str, tag_name,
                                                                                    this_version,
                                                                                    dockerfile)
        print(cmd)
        run(cmd, shell=True, check=True, env={
            "DOCKER_BUILDKIT": "1"
        })

        if push:
            run("docker push faabric/{}:{}".format(container, this_version),
                shell=True, check=True)
Ejemplo n.º 4
0
def build(ctx):
    """
    Build the WASM functions needed for the makespan experiment: mpi/migration,
    and lammps/main
    """
    tmp_image_name = "granny_build_container"
    # First, start the container in the background
    docker_cmd = [
        "docker run -d",
        "-v {}:/code/experiment-mpi".format(PROJ_ROOT),
        "--name {}".format(tmp_image_name),
        "faasm/{}:{}".format(MAKESPAN_IMAGE_NAME, get_version()),
    ]
    docker_cmd = " ".join(docker_cmd)
    print(docker_cmd)
    run(docker_cmd, check=True, shell=True, cwd=PROJ_ROOT)

    # Second, build the wasm for LAMMPS
    docker_cmd = [
        "docker exec",
        tmp_image_name,
        "inv lammps.wasm",
    ]
    docker_cmd = " ".join(docker_cmd)
    print(docker_cmd)
    run(docker_cmd, check=True, shell=True, cwd=PROJ_ROOT)

    # Third, build the wasm for the migrate function
    docker_cmd = [
        "docker cp",
        join(MAKESPAN_WASM_DIR, "mpi_migrate.cpp"),
        "{}:/code/cpp/func/mpi/migrate.cpp".format(tmp_image_name),
    ]
    docker_cmd = " ".join(docker_cmd)
    print(docker_cmd)
    run(docker_cmd, check=True, shell=True, cwd=PROJ_ROOT)
    docker_cmd = [
        "docker exec",
        "--workdir /code/cpp",
        tmp_image_name,
        "inv func mpi migrate",
    ]
    docker_cmd = " ".join(docker_cmd)
    print(docker_cmd)
    run(docker_cmd, check=True, shell=True, cwd=PROJ_ROOT)
    docker_cmd = [
        "docker cp",
        "{}:/code/cpp/build/func/mpi/migrate.wasm".format(tmp_image_name),
        join(MAKESPAN_WASM_DIR, "migrate.wasm"),
    ]
    docker_cmd = " ".join(docker_cmd)
    print(docker_cmd)
    run(docker_cmd, check=True, shell=True, cwd=PROJ_ROOT)

    # Lastly, remove the container
    docker_cmd = "docker rm -f {}".format(tmp_image_name)
    print(docker_cmd)
    run(docker_cmd, check=True, shell=True, cwd=PROJ_ROOT)
Ejemplo n.º 5
0
def tag(ctx, force=False):
    """
    Creates git tag from the current tree
    """
    git_tag = "v{}".format(get_version())
    run(
        "git tag {} {}".format("--force" if force else "", git_tag),
        shell=True,
        check=True,
        cwd=PROJ_ROOT,
    )

    run(
        "git push origin {} {}".format("--force" if force else "", git_tag),
        shell=True,
        check=True,
        cwd=PROJ_ROOT,
    )
Ejemplo n.º 6
0
def release_create(ctx):
    """
    Create a draft release on Github
    """
    # Work out the tag
    faabric_ver = get_version()
    tag_name = get_tag_name(faabric_ver)

    # Create a release in github from this tag
    r = get_repo()
    r.create_git_release(
        tag_name,
        "Faabric {}".format(faabric_ver),
        get_release_body(),
        draft=True,
    )

    print("You may now review the draft release in:")
    print("https://github.com/faasm/faabric/releases")
Ejemplo n.º 7
0
def build(ctx, nocache=False, push=False):
    """
    Build the container image used for makespan experiment
    """
    shell_env = copy(environ)
    shell_env["DOCKER_BUILDKIT"] = "1"
    img_tag = get_docker_tag(MAKESPAN_IMAGE_NAME)

    cmd = [
        "docker",
        "build",
        "-f {}".format(MAKESPAN_DOCKERFILE),
        "--no-cache" if nocache else "",
        "--build-arg EXPERIMENT_VERSION={}".format(get_version()),
        "-t {}".format(img_tag),
        ".",
    ]

    cmd_str = " ".join(cmd)
    print(cmd_str)
    run(cmd_str, shell=True, check=True, cwd=PROJ_ROOT)

    if push:
        push_docker_image(img_tag)
Ejemplo n.º 8
0
def _get_docker_tag(img_name):
    ver = get_version()
    return "faasm/{}:{}".format(img_name, ver)