-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exception logging and cache cleaning (#34)
* devcontainer settings example * devcontainer example * upd sfk * upd sdk * devcontainer comments * added report parser to handle DialogWindowError * debug msg * process DialogWindowError * fix unmutable mutations bug * added agent exceptions handler and docker pull exceptions * rm import * change exception code * change host mkfile to agent * launch configurations for devcontainer * change paths from host to mounted agent paths * added nvsmi info: capability, cuda, driver * updates for development in devcontainer * added comments and all app folders * all folders size + comments * add paths descriptions * not reusable app data removal * auto clean constants * app sessions and agent logs clean by age functions * added AppDirCleaner for session/pip files remove * fix description * added cleaning for terminated tasks * files and folders separation * comments * files and folders separation * added autocleaner task * prevent raising exception in thread; fix bug * added new clean tasks * rm clean pip cache from app session cleaner * pytest config; test autocleaner * base test functions updated * upd device capability * just my code * rename weights * fix import * change log condition * age_limit typing * AppDirCleaner inplace initialization * rename node storage * fix test path * files removal for not existing in app_sessions * node_storage nodes naming * added removing of unknow sessions files * check unknown sessions * fix ValueError bug * upd auto clean range with env * upd sdk * upd sdk * upd docs * upd constant docs * upd sdk * prevent autoclean app files * allow manual clean for users (update apps once a day) * upd sdk * mv docker exceptions to sdk * fix comment * add comment * upd sdk
- Loading branch information
Showing
18 changed files
with
1,034 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM supervisely/agent:latest | ||
|
||
# use same name in devcontainer.json | ||
ARG USERNAME=fedor | ||
# execute `echo $UID` on host | ||
ARG USER_UID=1003 | ||
ARG USER_GID=$USER_UID | ||
# execute `getent group docker` on host | ||
ARG DOCKER_UID=999 | ||
|
||
RUN groupadd --gid $USER_GID $USERNAME \ | ||
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \ | ||
# | ||
# [Optional] Add sudo support. Omit if you don't need to install software after connecting. | ||
&& apt-get update \ | ||
&& apt-get install -y sudo \ | ||
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | ||
&& chmod 0440 /etc/sudoers.d/$USERNAME | ||
|
||
RUN groupadd -g $DOCKER_UID docker \ | ||
&& usermod -aG docker $USERNAME | ||
|
||
# AGENT_ROOT_DIR | ||
RUN mkdir /sly_agent | ||
# SUPERVISELY_AGENT_FILES_CONTAINER | ||
RUN mkdir -p /app/sly-files | ||
# uncomment and uninstall to debug sdk | ||
# RUN pip3 uninstall -y supervisely | ||
|
||
# if no User defined all files changed in devcontainer will have root as owner | ||
USER $USERNAME | ||
ENTRYPOINT ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
|
||
set -o pipefail | ||
|
||
WHITE='\033[1;37m' | ||
YELLOW='\033[1;33m' | ||
RED='\033[0;31m' | ||
NC='\033[0m' | ||
|
||
command_exists() { | ||
command -v "$@" > /dev/null 2>&1 | ||
} | ||
|
||
sudo_cmd=() | ||
|
||
if command_exists sudo; then | ||
sudo_cmd=(sudo -E bash -c) | ||
elif command_exists su; then | ||
sudo_cmd=(su -p -s bash -c) | ||
fi | ||
|
||
docker ps > /dev/null 2>&1 | ||
|
||
access_test_code=$? | ||
|
||
if [[ ${access_test_code} -ne 0 && ${EUID} -ne 0 && ${#sudo_cmd} -ne 0 ]]; then | ||
cur_fd="$(printf %q "$BASH_SOURCE")$((($#)) && printf ' %q' "$@")" | ||
cur_script=$(cat "${cur_fd}") | ||
${sudo_cmd[*]} "${cur_script}" | ||
|
||
exit 0 | ||
fi | ||
|
||
export SUPERVISELY_AGENT_IMAGE='supervisely/agent:dev' | ||
# same as in devcontainer.json and debug.env | ||
export AGENT_HOST_DIR="/home/fedor_lisin/agent_debug_dir/agent" | ||
|
||
# from secret.env ↓ | ||
export ACCESS_TOKEN='' | ||
export SERVER_ADDRESS='' | ||
export DOCKER_REGISTRY='' | ||
export DOCKER_LOGIN='' | ||
export DOCKER_PASSWORD='' | ||
# from secret.env ↑ | ||
|
||
secrets=("${ACCESS_TOKEN}" "${SERVER_ADDRESS}" "${DOCKER_REGISTRY}" "${DOCKER_LOGIN}" "${DOCKER_PASSWORD}") | ||
|
||
for value in "${secrets[@]}" | ||
do | ||
if [ -z $value ]; | ||
then | ||
echo "${RED}One of the required secrets is not defined${NC}" | ||
exit 1 | ||
fi | ||
done | ||
|
||
|
||
export DELETE_TASK_DIR_ON_FINISH='true' | ||
export DELETE_TASK_DIR_ON_FAILURE='true' | ||
export PULL_POLICY='ifnotpresent' | ||
# same as in devcontainer.json and debug.env | ||
export SUPERVISELY_AGENT_FILES=$(echo -n "/home/fedor_lisin/agent_debug_dir/files") | ||
|
||
|
||
echo 'Supervisely Net is enabled, starting client...' | ||
docker pull supervisely/sly-net-client:latest | ||
docker network create "supervisely-net-${ACCESS_TOKEN}" 2> /dev/null | ||
echo 'Remove existing Net Client container if any...' | ||
docker rm -fv $(docker ps -aq -f name="supervisely-net-client-${ACCESS_TOKEN}") 2> /dev/null | ||
docker run -it -d --name="supervisely-net-client-${ACCESS_TOKEN}" \ | ||
-e "SLY_NET_CLIENT_PING_INTERVAL=60" \ | ||
--privileged \ | ||
--network "supervisely-net-${ACCESS_TOKEN}" \ | ||
--restart=unless-stopped \ | ||
--log-driver=local \ | ||
--log-opt max-size=1m \ | ||
--log-opt max-file=1 \ | ||
--log-opt compress=false \ | ||
--cap-add NET_ADMIN \ | ||
--device /dev/net/tun:/dev/net/tun \ | ||
\ | ||
\ | ||
\ | ||
\ | ||
\ | ||
\ | ||
-v /var/run/docker.sock:/tmp/docker.sock:ro \ | ||
-v "${AGENT_HOST_DIR}:/app/sly" \ | ||
\ | ||
-v "/home/fedor_lisin/agent_debug_dir/files:/app/sly-files" \ | ||
"supervisely/sly-net-client:latest" \ | ||
"${ACCESS_TOKEN}" \ | ||
"https://dev.supervisely.com/net/" \ | ||
"dev.supervisely.com:51822" | ||
|
||
retVal=$? | ||
if [ $retVal -ne 0 ]; then | ||
echo -e " | ||
${RED}Couldn't start Supervisely Net. Agent is running fine. Please, contact support and attach the log above${NC}" | ||
fi | ||
|
||
echo -e "${WHITE}============ You can close this terminal safely now ============${NC}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
// "image": "agent_dev:latest", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"runArgs": [ | ||
"--gpus", | ||
"all", | ||
"--ipc=host", | ||
"--net=host", | ||
"--cap-add", | ||
"NET_ADMIN" | ||
], | ||
"containerEnv": { | ||
// access token from secret.env | ||
"DOCKER_NET": "supervisely-net-{access token}" | ||
}, | ||
"mounts": [ | ||
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind", | ||
// AGENT_HOST_DIR and AGENT_ROOT_DIR in env file; AGENT_ROOT_DIR should be created in Dockerfile | ||
"source=/home/fedor_lisin/agent_debug_dir/agent,target=/sly_agent,type=bind", | ||
// SUPERVISELY_AGENT_FILES and SUPERVISELY_AGENT_FILES_CONTAINER in env file; SUPERVISELY_AGENT_FILES_CONTAINER should be created in Dockerfile | ||
"source=/home/fedor_lisin/agent_debug_dir/files,target=/app/sly-files,type=bind" | ||
], | ||
"remoteUser": "fedor", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-python.python" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.