in src/utils.py [0:0]
def build_setup(framework, device_types=None, image_types=None, py_versions=None):
"""
Setup the appropriate environment variables depending on whether this is a PR build
or a dev build
Parameters:
framework: str
device_types: [str]
image_types: [str]
py_versions: [str]
Returns:
None
"""
# Set necessary environment variables
to_build = {
"device_types": constants.DEVICE_TYPES,
"image_types": constants.IMAGE_TYPES,
"py_versions": constants.PYTHON_VERSIONS,
}
build_context = os.environ.get("BUILD_CONTEXT")
enable_build = is_build_enabled()
if build_context == "PR":
pr_number = os.getenv("PR_NUMBER")
LOGGER.info(f"pr number: {pr_number}")
if pr_number is not None:
pr_number = int(pr_number)
device_types, image_types, py_versions = pr_build_setup(pr_number, framework)
if device_types != constants.ALL:
to_build["device_types"] = constants.DEVICE_TYPES.intersection(
set(device_types)
)
if image_types != constants.ALL:
to_build["image_types"] = constants.IMAGE_TYPES.intersection(set(image_types))
if py_versions != constants.ALL:
to_build["py_versions"] = constants.PYTHON_VERSIONS.intersection(
set(py_versions)
)
for device_type in to_build["device_types"]:
for image_type in to_build["image_types"]:
for py_version in to_build["py_versions"]:
env_variable = f"{framework.upper()}_{device_type.upper()}_{image_type.upper()}_{py_version.upper()}"
if enable_build or build_context != "PR":
os.environ[env_variable] = "true"