-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathenv.py
106 lines (90 loc) · 2.99 KB
/
env.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
from faasmtools.build import FAASM_LOCAL_DIR
from faasmtools.docker import ACR_NAME
from faasmtools.env import get_version as get_cpp_version
from os import environ
from os.path import dirname, abspath, join
from yaml import safe_load
PROJ_ROOT = dirname(dirname(abspath(__file__)))
EXAMPLES_IN_DOCKER_ROOT = "/code/examples"
DOCKER_ROOT = join(PROJ_ROOT, "docker")
EXAMPLES_DIR = join(PROJ_ROOT, "examples")
DEV_FAASM_LOCAL = join(PROJ_ROOT, "dev", "faasm-local")
WASM_DIR = join(PROJ_ROOT, "wasm")
# Docker variables
EXAMPLES_BUILD_IMAGE_CTR = "examples-build-workon"
EXAMPLES_BUILD_IMAGE_NAME = "{}/examples-build".format(ACR_NAME)
EXAMPLES_BUILD_DOCKERFILE = join(DOCKER_ROOT, "build.dockerfile")
EXAMPLES_BASE_IMAGE_NAME = "{}/examples-base".format(ACR_NAME)
EXAMPLES_BASE_DOCKERFILE = join(DOCKER_ROOT, "base.dockerfile")
# Shared files data
EXAMPLES_DATA_BASE_DIR = join(FAASM_LOCAL_DIR, "shared")
EXAMPLES_DATA_HOST_DIR = join(PROJ_ROOT, "data")
EXAMPLES_DATA_FILES = [
[
join(EXAMPLES_DATA_HOST_DIR, "faasm_logo.png"),
join("im", "sample_image.png"),
],
[
join(EXAMPLES_DATA_HOST_DIR, "in.controller.wall"),
join("lammps-data", "in.controller.wall"),
],
[
join(EXAMPLES_DATA_HOST_DIR, "ffmpeg_video.mp4"),
join("ffmpeg", "sample_video.mp4"),
],
[
join(EXAMPLES_DATA_HOST_DIR, "sample_model.tflite"),
join("tflite", "sample_model.tflite"),
],
[
join(EXAMPLES_DATA_HOST_DIR, "grace_hopper.bmp"),
join("tflite", "grace_hopper.bmp"),
],
[
join(EXAMPLES_DATA_HOST_DIR, "bus_photo.bmp"),
join("opencv", "bus_photo.bmp"),
],
[
join(EXAMPLES_DATA_HOST_DIR, "tchaikovsky.bmp"),
join("opencv", "composers", "tchaikovsky.bmp"),
],
[
join(EXAMPLES_DATA_HOST_DIR, "wagner.bmp"),
join("opencv", "composers", "wagner.bmp"),
],
[
join(EXAMPLES_DATA_HOST_DIR, "beethoven.bmp"),
join("opencv", "composers", "beethoven.bmp"),
],
]
def get_submodule_version(submodule):
"""
Get the version of a submodule as indicated in the VERSION file
"""
ver_file = join(PROJ_ROOT, submodule, "VERSION")
with open(ver_file, "r") as fh:
version = fh.read()
version = version.strip()
return version
def get_python_version():
"""
Get the version of the python submodule
"""
return get_submodule_version("python")
def get_faasm_version():
"""
Get the version of the Faasm dependency
"""
yaml_path = join(PROJ_ROOT, ".github", "workflows", "tests.yml")
return safe_load(open(yaml_path, "r"))["jobs"]["run-examples-faasmctl"][
"env"
]["FAASM_VERSION"]
def get_version():
"""
Get version for the examples repository
The version depends only on the version of the different cross-compilation
toolchains we use, in this case CPP and Python
"""
return "{}_{}".format(get_cpp_version(), get_python_version())
def in_docker():
return "IN_DOCKER" in environ