Skip to content

Commit

Permalink
add apps cache dir env var to the app task container
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaiPetukhov committed Feb 29, 2024
1 parent 75c3e7d commit 3e3fdbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions agent/worker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def TOKEN():
_CONTAINER_NAME = "CONTAINER_NAME"
_FORCE_CPU_ONLY = "FORCE_CPU_ONLY"
_LOG_LEVEL = "LOG_LEVEL"
_APPS_CACHE_DIR = "APPS_CACHE_DIR"

_NET_CLIENT_DOCKER_IMAGE = "NET_CLIENT_DOCKER_IMAGE"
_NET_SERVER_PORT = "NET_SERVER_PORT"
Expand Down Expand Up @@ -169,6 +170,7 @@ def TOKEN():
_SLY_EXTRA_CA_CERTS_VOLUME_NAME: f"supervisely-agent-ca-certs-{TOKEN()[:8]}",
_FORCE_CPU_ONLY: "false",
_LOG_LEVEL: "INFO",
_APPS_CACHE_DIR: "/apps_cache",
}


Expand Down Expand Up @@ -449,6 +451,14 @@ def AGENT_APPS_CACHE_DIR():
return os.path.join(AGENT_ROOT_DIR(), "apps_cache")


def APPS_CACHE_DIR():
"""
Is used to access AGENT_APPS_CACHE_DIR from the app container.
default: /apps_cache
"""
return read_optional_setting(_APPS_CACHE_DIR)


def GITHUB_TOKEN():
return read_optional_setting(_GITHUB_TOKEN)

Expand Down
3 changes: 2 additions & 1 deletion agent/worker/task_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def init_task_dir(self):
self.dir_task_container = "/app"

self.dir_task_src_container = os.path.join(self.dir_task_container, "repo")
self.dir_apps_cache_container = "/apps_cache"
self.dir_apps_cache_container = constants.APPS_CACHE_DIR()
self.app_info = self.info["appInfo"]

def download_or_get_repo(self):
Expand Down Expand Up @@ -690,6 +690,7 @@ def main_step_envs(self):
"icon": self.app_config.get("icon", "https://cdn.supervise.ly/favicon.ico"),
"PIP_ROOT_USER_ACTION": "ignore",
"AGENT_ID": self.agent_id,
"APPS_CACHE_DIR": self.dir_apps_cache_container,
}

if "context.workspaceId" in envs:
Expand Down

0 comments on commit 3e3fdbc

Please sign in to comment.