ML-TANGO / TANGO

public repo for TANGO (Target Aware No-code neural network Generation and Operation framework)
Other
68 stars 20 forks source link

Need to enhance REST API: status_report() #55

Closed ML-TANGO closed 1 year ago

ML-TANGO commented 1 year ago

status_report() 는 다음과 같이 정의되어 있다.

URI format HTTP GET Message calling from Member Containers.

http://<DOCKER_HOST_IP>:<PROJECT_MANAGER_PORT>/status_report?container_id=<container_id>&user_id=<user_id>&project_id=<project_id>&status=<status>

Equivalent route function form in Python Web Framework (e.g, Django)

status_report(container_id=<container_id>, user_id=<user_id>, project_id=<project_id>, status=<status>)

Arguments:

container_id indicates the container id who reports the status. possible values for <container_id> are as follows:

  • 'labelling' : Dataset Labeling Tool Container
  • 'bms' : Base Model Select Container
  • 'vis2code' : Model Visualizer Container
  • 'backbone_nas' : Backbone NAS Container
  • 'neck_nas' : Neck NAS Container
  • 'code_gen' : Code Generation Container
  • 'cloud_deploy' : Deployment Container for Cloud target
  • 'ondevice_deploy' : Deployment Container for OnDevice target

user_id, project_id indicate the project user's ID and project ID respectively, which were delivered parameters via start() from Leader Container (Project Manager) to the Member Containers. status indicates whether the task in the Member Container is success or failed possible values for <status> are as follows:

  • 'success' : successful completion of the task in the member container
  • 'failed' : failure of the task in the member container

Returns:

The Leader Container (Project Manager) should respond with the following HTTP response message;

  • 200 OK, when it receive the status report normally.

container_id는 Project Manager로 상태를 보고하는 컨테이너들간에 컨테이너 구분을 위한 용도로 정의되었으나, 위의 정의에 보듯이 고정된 갯수의 문자열값의 리스트이다. 문제는 컨테이너용 코드가 추가될때마다, 컨테이너 구분용 문자열들을 계속해서 status_report()추가해야 된다는 것이다.

도커 컨테이너로 실행중인 TANGO용 컨테이너가 자신의 idenity를 유일하게 표현할 방법(tango container id)과 Project Manager에서 프로젝트에 참여하는 컨테이너(tango contain id)들을 사용하여 워크플로우에 참여할 멤버 컨테이너들을 선정하고 그들간의 순서 관계를 정의하는 기능들이 추가되어야 할 것이다.

도커 컨테이너로 실행중인 TANGO용 컨테이너가 자신의 idenity를 유일하게 표현할 방법(tango container id)

그러면 컨테이너로 실행중인 Project Manager내부에서도 docker container ls 또는 docker ps 명령의 결과로 표시되는 TANGO 컨테이너들의 컨테이너 ID를 확인할 방법은?

ML-TANGO commented 1 year ago

TANGO 컨테이너 리스트 확인하기

컨테이너 내부에서 docker 엔진 기능을 사용할 수 있도록 해주는 docker engine API를 사용하면 실행중인 컨테이너들의 리스트를 확인할 수 있다.

컨테이너 내부에서 pip install dockerdocker패키지 설치후 아래와 같은 코드를 실행

# file name: test_docker_api.py
import docker
client = docker.from_env()
for container in client.containers.list():
    print(f"ID: {container.id}, Name: {container.name}" )

실행 결과:

# python ./test_docker_api.py
ID: e6612eeff02f0a029c4a2e2746c212de926b2e8e619466a56383a0913f004ee2, Name: tango-project_manager-1
ID: 408b4032d37063b73b66da4122664f824d88558d94914b19e9b5a6eafcd6adb6, Name: tango-code_gen-1
ID: 4bfd47ea47a40d22ba9b54ba92c80d26758c3e18df5c17a77b540f70073fcb60, Name: tango-autonn_yoloe-1
ID: b41ef5389a6c005f23a33057ab10c0c651d8c78d6679872af0bd3a0c1b474b3a, Name: tango-postgresql-1
ID: 50240fe1f508cb2bd54287173e171882b05a7f05251b1c0435f8b77d6d065c1a, Name: tango-bms-1
ID: e4420aad14b8e8887cc7e04861ee8b5fda63ec82b190e8b8476db9244d30f473, Name: tango-target_image_build-1
ID: d54ab73a645ffa4d851a5f758a562b8007e96848e41158908b18acf554a6d15e, Name: tango-ondevice_deploy-1

” 위의 결과중 Name에서 prefix 'tango-'와 suffix인 '-1' 을 제거하면 docker-compose.yml 파일에서 services: 아래에 지정한 해당 서비스의 이름이 된다.

docker-compose.yml 파일 내부에서 service 별로 hostaname의 값을 설정하면 컨테이너내부에서 /etc/hostname 파일에 저장된다.