Skip to content

Commit 2c5330e

Browse files
authored
gh: bump deps and use faasmctl (#19)
* gh: bump deps * docs: fix readme * gh: bump planner version * gh: correct faasm version * gha: fix error introduced when sed-ing * gh: properly bump faasm version * deps: bump again * nits: format python code * examples(kernels): fix native mpi kernels compilation * gha: only build wasm if needed * gha: use faasmctl * gha: fix syntax error * gha: use sudo to install * gha: faster submodule init * gha: correct cache key * faasmctl: bump to 0.19.0 * gha: install with sudo * gha: clone submodules * wasm: use the right directory * gha: fix submodule paths * gha: more cache fixes * gha: debug cache miss * data: not rely on lammps submodule being checked out * gha: attempt to fix mpi kernels * nits: self-review
1 parent 5998fcc commit 2c5330e

File tree

14 files changed

+459
-162
lines changed

14 files changed

+459
-162
lines changed

.github/workflows/tests.yml

+300-110
Large diffs are not rendered by default.

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ build
1010

1111
# WASM files
1212
wasm
13+
14+
# Faasm deployment config
15+
faasm.ini

FAASM_VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.9
1+
0.15.0

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ inv docker.build -c build -c run --nocache --push
8484
## Adding a new application
8585

8686
To add a new application, you first need to cross-compile it to WebAssembly.
87-
You can check the [`tasks/`]](./tasks) folder for examples of how we do it for
87+
You can check the [`tasks/`](./tasks) folder for examples of how we do it for
8888
existing applications. Most importantly, you will have to inidicate the right
8989
sysroot, and pass the environment variables that we read from `faasmtools`.
9090

data/in.controller.wall

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# 3d Lennard-Jones melt, thermostatted by fix controller
2+
3+
units lj
4+
atom_style atomic
5+
boundary p p m
6+
processors * * 1
7+
lattice fcc 0.8442
8+
region box block 0 10 0 10 -4 14
9+
region slab block 0 10 0 10 0 10
10+
create_box 1 box
11+
create_atoms 1 region slab
12+
mass 1 1.0
13+
14+
velocity all create 1.44 87287 loop geom
15+
16+
pair_style lj/cut 2.5
17+
pair_coeff 1 1 1.0 1.0 2.5
18+
19+
neighbor 0.3 bin
20+
neigh_modify delay 2 every 2 check yes
21+
22+
fix 1 all nve
23+
fix 3 all langevin 1.5 1.5 0.5 412513
24+
25+
variable zhi internal $(10.5*zlat)
26+
variable kwall equal 20.0
27+
fix 2 all wall/harmonic zlo -0.5 ${kwall} 0.0 2.5 zhi v_zhi ${kwall} 0.0 2.5
28+
29+
variable pzz equal pzz
30+
fix ave all ave/time 10 10 100 v_pzz
31+
# equilibrate
32+
33+
thermo_style custom step temp pxx pyy pzz f_ave v_zhi
34+
thermo 500
35+
run 2500
36+
37+
# use time averaged pressure for control
38+
#fix 10 all controller 100 -0.05 20.0 0.0 0.0 f_ave 1.5 zhi
39+
40+
# use instantaneous pressure for control
41+
fix 10 all controller 100 -0.05 50.0 0.0 0.0 v_pzz 1.5 zhi
42+
43+
# run with controller
44+
45+
run 5000
46+

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
image: faasm.azurecr.io/redis:${EXAMPLES_RUN_VERSION}
66

77
planner:
8-
image: faasm.azurecr.io/planner:0.4.4
8+
image: faasm.azurecr.io/planner:0.10.0
99
environment:
1010
- LOG_LEVEL=info
1111
- PLANNER_PORT=8081

requirements.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
black==22.3.0
2-
flake8==4.0.1
3-
invoke==1.7.1
1+
black>=22.3.0
2+
faasmctl>=0.19.0
3+
flake8>=4.0.1
4+
invoke>=1.7.1

tasks/data.py

+3-36
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,16 @@
1-
from faasmtools.build import FAASM_LOCAL_DIR
21
from invoke import task
32
from os import makedirs
4-
from os.path import dirname, exists, join
3+
from os.path import dirname, exists
54
from shutil import copyfile
6-
from tasks.env import EXAMPLES_DIR, PROJ_ROOT
7-
8-
DATA_BASE_DIR = join(FAASM_LOCAL_DIR, "shared")
9-
DATA_HOST_DIR = join(PROJ_ROOT, "data")
5+
from tasks.env import EXAMPLES_DATA_FILES
106

117

128
@task(default=True)
139
def prepare(ctx):
1410
"""
1511
Prepare data files to test WASM examples
1612
"""
17-
data_files = [
18-
[
19-
join(DATA_HOST_DIR, "faasm_logo.png"),
20-
join(DATA_BASE_DIR, "im", "sample_image.png"),
21-
],
22-
[
23-
join(
24-
EXAMPLES_DIR,
25-
"lammps",
26-
"examples",
27-
"controller",
28-
"in.controller.wall",
29-
),
30-
join(DATA_BASE_DIR, "lammps-data", "in.controller.wall"),
31-
],
32-
[
33-
join(DATA_HOST_DIR, "ffmpeg_video.mp4"),
34-
join(DATA_BASE_DIR, "ffmpeg", "sample_video.mp4"),
35-
],
36-
[
37-
join(DATA_HOST_DIR, "sample_model.tflite"),
38-
join(DATA_BASE_DIR, "tflite", "sample_model.tflite"),
39-
],
40-
[
41-
join(DATA_HOST_DIR, "grace_hopper.bmp"),
42-
join(DATA_BASE_DIR, "tflite", "grace_hopper.bmp"),
43-
],
44-
]
45-
46-
for p in data_files:
13+
for p in EXAMPLES_DATA_FILES:
4714
path_src = p[0]
4815
path_dst = p[1]
4916

tasks/env.py

+56
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from faasmtools.build import FAASM_LOCAL_DIR
12
from faasmtools.docker import ACR_NAME
23
from faasmtools.env import get_version as get_cpp_version
34
from os.path import dirname, abspath, join
5+
from re import search as re_search
6+
from subprocess import run
47

58
PROJ_ROOT = dirname(dirname(abspath(__file__)))
69
DOCKER_ROOT = join(PROJ_ROOT, "docker")
@@ -14,6 +17,32 @@
1417
EXAMPLES_RUN_IMAGE_NAME = "{}/examples-run".format(ACR_NAME)
1518
EXAMPLES_RUN_DOCKERFILE = join(DOCKER_ROOT, "run.dockerfile")
1619

20+
# Shared files data
21+
EXAMPLES_DATA_BASE_DIR = join(FAASM_LOCAL_DIR, "shared")
22+
EXAMPLES_DATA_HOST_DIR = join(PROJ_ROOT, "data")
23+
EXAMPLES_DATA_FILES = [
24+
[
25+
join(EXAMPLES_DATA_HOST_DIR, "faasm_logo.png"),
26+
join(EXAMPLES_DATA_BASE_DIR, "im", "sample_image.png"),
27+
],
28+
[
29+
join(EXAMPLES_DATA_HOST_DIR, "in.controller.wall"),
30+
join(EXAMPLES_DATA_BASE_DIR, "lammps-data", "in.controller.wall"),
31+
],
32+
[
33+
join(EXAMPLES_DATA_HOST_DIR, "ffmpeg_video.mp4"),
34+
join(EXAMPLES_DATA_BASE_DIR, "ffmpeg", "sample_video.mp4"),
35+
],
36+
[
37+
join(EXAMPLES_DATA_HOST_DIR, "sample_model.tflite"),
38+
join(EXAMPLES_DATA_BASE_DIR, "tflite", "sample_model.tflite"),
39+
],
40+
[
41+
join(EXAMPLES_DATA_HOST_DIR, "grace_hopper.bmp"),
42+
join(EXAMPLES_DATA_BASE_DIR, "tflite", "grace_hopper.bmp"),
43+
],
44+
]
45+
1746

1847
def get_submodule_version(submodule):
1948
"""
@@ -48,6 +77,33 @@ def get_faasm_version():
4877
return version
4978

5079

80+
def get_faabric_version(old_faasm_ver, new_faasm_ver):
81+
"""
82+
Get the faabric version by `wget`-ing the FAASM version file for the tagged
83+
Faasm version
84+
"""
85+
86+
def do_get_ver(faasm_ver):
87+
tmp_file = "/tmp/faabric_version"
88+
wget_cmd = [
89+
"wget",
90+
"-O {}".format(tmp_file),
91+
"https://raw.githubusercontent.com/faasm/faasm/v{}/.env".format(
92+
faasm_ver
93+
),
94+
]
95+
wget_cmd = " ".join(wget_cmd)
96+
out = run(wget_cmd, shell=True, capture_output=True)
97+
assert out.returncode == 0
98+
99+
with open(tmp_file, "r") as fh:
100+
ver = re_search(r"planner:([0-9\.]*)", fh.read()).groups(1)[0]
101+
102+
return ver
103+
104+
return do_get_ver(old_faasm_ver), do_get_ver(new_faasm_ver)
105+
106+
51107
def get_version(name="build"):
52108
"""
53109
Get version for the examples repository

tasks/git.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
from tasks.env import (
44
EXAMPLES_BUILD_IMAGE_NAME,
55
PROJ_ROOT,
6+
get_faabric_version,
67
get_faasm_version,
78
get_version,
89
)
910

1011
VERSIONED_FILES = {
1112
"faasm": ["FAASM_VERSION", ".github/workflows/tests.yml"],
13+
"faabric": ["docker-compose.yml", ".github/workflows/tests.yml"],
1214
"cpp": [".github/workflows/tests.yml"],
1315
"python": [".github/workflows/tests.yml"],
1416
}
@@ -52,16 +54,19 @@ def bump(ctx, submodule, ver=None):
5254
if ver:
5355
new_ver = ver
5456
else:
55-
# Just bump the last minor version part
56-
new_ver_parts = old_ver.split(".")
57-
new_ver_minor = int(new_ver_parts[-1]) + 1
58-
new_ver_parts[-1] = str(new_ver_minor)
59-
new_ver = ".".join(new_ver_parts)
57+
raise RuntimeError("Must provide a version with --ver flag!")
6058

6159
# Replace version in all files
6260
for f in VERSIONED_FILES["faasm"]:
6361
sed_cmd = "sed -i 's/{}/{}/g' {}".format(old_ver, new_ver, f)
6462
run(sed_cmd, shell=True, check=True)
63+
64+
# Also update the planner version accordingly
65+
old_fabric_ver, new_faabric_ver = get_faabric_version(old_ver, new_ver)
66+
for f in VERSIONED_FILES["faabric"]:
67+
sed_cmd = "sed -i 's/{}/{}/g' {}".format(old_ver, new_ver, f)
68+
run(sed_cmd, shell=True, check=True)
69+
6570
else:
6671
new_ver = get_version("build")
6772
grep_cmd = "grep '{}' .github/workflows/tests.yml".format(

tasks/wasm.py

+31-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
from distutils.dir_util import copy_tree
2+
from faasmctl.util.upload import upload_file, upload_wasm
23
from invoke import task
3-
from os import makedirs
4+
from os import listdir, makedirs
45
from os.path import exists, join
56
from shutil import copyfile, rmtree
6-
from tasks.env import EXAMPLES_DIR, WASM_DIR
7+
from tasks.env import (
8+
EXAMPLES_DIR,
9+
EXAMPLES_DATA_FILES,
10+
EXAMPLES_DATA_BASE_DIR,
11+
WASM_DIR,
12+
)
713

814

915
@task(default=True)
@@ -33,3 +39,26 @@ def copy(ctx, clean=False):
3339
wasm_dirs = [join(EXAMPLES_DIR, "Kernels", "build", "wasm")]
3440
for wasm_dir in wasm_dirs:
3541
copy_tree(wasm_dir, WASM_DIR)
42+
43+
44+
@task
45+
def upload(ctx):
46+
"""
47+
Upload all WASM and shared data to a Faasm cluster
48+
"""
49+
if not exists(WASM_DIR):
50+
print("Expected WASM files to be available in {}".format(WASM_DIR))
51+
raise RuntimeError("WASM directory not found!")
52+
53+
# Iterate over all dirs and upload
54+
for user in listdir(WASM_DIR):
55+
for name in listdir(join(WASM_DIR, user)):
56+
wasm_path = join(WASM_DIR, user, name, "function.wasm")
57+
if exists(wasm_path):
58+
upload_wasm(user, name, wasm_path)
59+
60+
# Iterate over all shared data files and upload
61+
for data_file in EXAMPLES_DATA_FILES:
62+
host_path = data_file[0]
63+
faasm_path = data_file[1].removeprefix(EXAMPLES_DATA_BASE_DIR + "/")
64+
upload_file(host_path, faasm_path)

0 commit comments

Comments
 (0)