Appendix : What is Experimental Plan
AI Contents 는 experimental_plan.yaml 에 기술된 pipeline 정보로 동작 됩니다. ML pipeline 은 데이터, asset 코드, 파이썬 패키지 등이 존재해야 실행 할 수 있는데, experimental_plan.yaml 구 성 요소들에 해당 사항들을 기술해야 합니다.
Topics
experimental_plan.yaml 구성 요소
name : AI Contents 명칭을 작성합니다. Mellerikat에 기록되어 관리 됩니다.
external_path : 학습과 추론에 사용될 데이터를 지정 합니다.
-
load_train/inference_data_path : 입력 데이터 위치를 작성 합니다.
- 상대 경로를 지원 합니다. main.py 를 현재 위치로 인식합니다. (ex: "../sample_data/train/")
- 절대 경로를 지원 합니다. (ex: "/home/user.name/alo/train/")
- S3 경로를 지원 합니다. (ex: "s3://ecr-repo-an2-cism-dev/ai-solutions/public/bolt_fastening/train/")
-
save_train/inference_artifacts_path : pipeline 결과물 저장 위치를 작성 합니다.
- load 와 동일하게 상대 경로, 절대 경로, S3 경로를 지원 합니다.
- 단, 결과물은 train_artifacts.tar.gz, infereence_artifacts.tar.gz, model.tar.gz 인 압축 형태로 저장 됩니다.
-
load_model_path : 동일한 contents 를 다른 경로에서 작업 한 경우, 모델만 load 하여 inference pipeline 을 실행할 수 있습니다.
Note:
- load_train/inference_data_path 에는 실험 할 때 데이터 폴더 경로를 여러 개 작성할 수도 있습니다. 이때는 아래와 같이 리스트 형태로 작성하면 됩니다. 마지막 폴더 하위에는 여러 폴더나 파일들이 존재해도 통째로 마지막 폴더 이름으로 복사해오게 됩니다.
load_train_data_path: [path1/folder1/, path2/folder2/]
- save_train/inference_artifacts_path 는 artifacts 폴더 및 models 폴더를 (학습 파이프라인 때만) 통째로 압축하여 전달하는 경로로써, 단일 경로만 작성 가능합니다.
external_path_permission : AWS S3 접근 키를 기록 합니다.
- aws_key_profile : aws configure profile 명을 입력 합니다.
- 먼저, aws configure --profile {profile_name} 을 작업환경에 설정 합니다. (참고 AWS 문서: https://docs.aws.amazon.com/ko_kr/cli/latest/userguide/cli-configure-files.html)
user_parameters : asset 내부에서 사용할 파라미터 값들을 지정합니다.
- {type}_pipeline : pipeline type 은 train, inference 만을 지원 합니다.
- "step: step_name" : Asset(=step) 명을 작성 합니다.
- "args: {key: value, key2: value2}" 해당 step 에서 사용될 parameter들을 작성합니다.
- parameter 의 value 는 yaml 에서 지원하는 format (int, float, bool, list, dict)을 모두 사용 가능합니다.
asset_source : asset 코드의 git 주소를 작성합니다.
-
{type}_pipeline : pipeline type 은 train, inference 만을 지원 합니다.
- "step: step_name" : step 명을 작성 합니다.
- "source: \code: git uri 혹은 local}" git 주소를 작성합니다. local에서 직접 asset 개발하는 경우 local로 작성합니다.
- "source: {branch: name}" branch 이름을 작성합니다.
- "source: {requirements: [package1, package2 ..]}" 설치할 파이썬 패키지 명을 작성해 줍니다. (ex:"pandas==1.5.3")
Note: 이미 작성된 패키지 리스트가 해당 Asset git repository에 requirements.txt 파일로써 존재할 경우, "requirements.txt" 로 작성 합니다.
Note: Asset 종속 패키지 설치는 pipeline 상에 연결된 Asset의 순서와 동일하게 설치 됩니다. 만약 input step에서 pandas==1.5.3이 필요한데, train step에서 pandas==1.5.4가 필요한 경우 train step에서는 이미 1.5.3 버전이 설치되어 있어서 1.5.4 버전 설치를 skip할 것입니다. 하지만 때로는 패키지 충돌 방지를 위해 1.5.4를 재설치 해야 할 경우도 있기 때문에 이런 경우에는 pandas==1.5.4 --force-reinstall 과 같은 형태로 명시해줍니다.
Note: 특정 Asset에서 필요한 종속 패키지가 존재하지 않으면 아래와 같이 빈 리스트로 비워둡니다.
requirements: []
```
control : ALO 설정 값을 실험 환경에 맞게 선택 합니다.
- get_asset_source : pipeline 실행 시 마다 git clone 여부를 결정합니다. once, every 를 지원합니다.
- Asset 코드를 매번 git clone 할지를 결정합니다.
- 참고로, Asset 에 사용되는 python 패키지 설치 여부는 항상 체크 하며, 추가 작성된 패키지는 파이프라인 실행 전에 설치 됩니다.
- backup_artifacts : pipeline 결과물을 history 에 backup 여부를 결정합니다. True, False 를 지원합니다.
- backup_log : pipeline log 를 history 에 backup 여부를 결정합니다. True, False 를 지원합니다. (TBD)
- backup_size : history 저장 용량을 MB 단위로 결정합니다. 용량 초과 시, 오래된 순으로 삭제 합니다.
- interface_mode : asset간의 파라미터 및 데이터를 어떤 방식으로 전달할지 결정 합니다. memory, file 를 지원 합니다.
- memory: asset 간의 파일 저장/로드 시간을 단축하여 실행을 빠르게 합니다.
- file: asset 결과물을 파일로 저장하여 실험 비교가 가능하게 합니다.
- check_resource : False로 하면 pipeline 기본 동작을 실행하며, True로 설정 시 각 Asset 후반부에 memory, cpu 리소스 usage를 로깅합니다.
- save_inference_format : external_path에 적힌 save_inference_artifacts_path에 inference artifacts를 압축하여 저장할 때 압축 포맷. zip 혹은 tar.gz을 지원합니다.
타이타닉 예제 experimental_plan.yaml
아래는 타이타닉 예제의 experimental_plan.yaml 입니다. 간단한 형태로 보여주기 위해 타이타닉 예제에는 ui args 관련 정보는 적혀있지 않습니다. ui args 관련해서는 Write UI Parameter 페이지를 참고합니다.
name: "demo-titanic"
version: "1.0.0"
## 외부에서 데이터 가져오기 / 결과 저장하는 경우 해당 위치에 지정
external_path:
- load_train_data_path: ./solution/sample_data/train_data/ # main.py 를 현재 위치로 인식합니다. solution 에 동봉된 sample_data path 를 입력 합니다.
- load_inference_data_path: ./solution/sample_data/inference_data/
- save_train_artifacts_path:
- save_inference_artifacts_path:
- load_model_path:
external_path_permission:
- aws_key_profile:
## 실험에 필요한 파라미터를 설정함
## - 해당 위치에서 삭제되면, code 상에 적힌 default 파라미터로 실행
user_parameters:
- train_pipeline:
- step: input
args:
- x_columns: ['Pclass', 'Sex', 'SibSp', 'Parch']
y_column: Survived
- step: train
args:
- n_estimators: 100
- inference_pipeline:
- step: input
args:
- x_columns: ['Pclass', 'Sex', 'SibSp', 'Parch']
y_column:
- step: inference
args:
- step: output
args: ## asset 의 설치 정보를 기록
asset_source:
- train_pipeline:
- step: input
source:
code: http://mod.lge.com/hub/dxadvtech/assets/alo-guide-input.git
branch: release_1.0
requirements:
- pandas==1.5.3
- step: train
source:
code: http://mod.lge.com/hub/dxadvtech/assets/alo-guide-train.git
branch: release_1.0
requirements:
- scikit-learn
- inference_pipeline:
- step: input
source:
code: http://mod.lge.com/hub/dxadvtech/assets/alo-guide-input.git
branch: release_1.0
requirements:
- pandas==1.5.3
- step: inference
source:
code: http://mod.lge.com/hub/dxadvtech/assets/alo-guide-inference.git
branch: release_1.0
requirements: []
- step: output
source:
code: http://mod.lge.com/hub/dxadvtech/assets/alo-guide-output.git
branch: release_1.0
requirements: []
control:
## 1. 패키지 설치 및 asset 존재 여부를 실험 시마다 체크할지, 한번만 할지 결정 / requirements.txt 및 종속 패키지들 한번만 설치할 지 매번 설치할지도 결정
- get_asset_source: once ## once, every
## 2. 생성된 artifacts 를 backup 할 지를 결정 True / False
- backup_artifacts: True
## 3. pipeline 로그를 backup 할 지를 결정 True / False
- backup_log: True
## 4. 저장 공간 사이즈를 결정 (단위 MB)
- backup_size: 1000
## 5. Asset 사이 데이터 전달 방법으로 memory, file 를 지원
- interface_mode: memory
## 6. inference artifacts 압축 format
- save_inference_format: tar.gz ## tar.gz, zip
## 7. resource check
- check_resource: False ## True: measure memory, cpu / False
ui_args_detail: []