마이그레이션 CLI
potato migrate로 Potato 구성을 v1에서 v2로 마이그레이션합니다. 적용하는 다섯 가지 규칙과, 아무것도 쓰기 전에 각 변경 사항을 보여 주는 드라이런을 다룹니다.
potato migrate는 v1 구성을 v2 형식으로 업그레이드하며, 인식하는 각 규칙을 적용하고 바꾼 내용을 보고합니다. 먼저 --dry-run으로 실행하십시오. 변경 사항을 적용할 생각이더라도 보고서가 유용한 부분이기 때문입니다.
사용법
# Print the migrated config to stdout
potato migrate config.yaml --to-v2
# Write it to a new file
potato migrate config.yaml --to-v2 --output new_config.yaml
# Rewrite the original in place
potato migrate config.yaml --to-v2 --in-place
# Show what would change, without writing
potato migrate config.yaml --to-v2 --dry-run명령 옵션
| 옵션 | 약어 | 설명 |
|---|---|---|
--to-v2 | 필수. v2 형식으로 마이그레이션 | |
--output FILE | -o | 마이그레이션된 구성을 stdout 대신 이 파일에 기록 |
--in-place | -i | 원본 구성 파일을 다시 기록 |
--dry-run | 아무것도 쓰지 않고 변경 사항만 보고 | |
--quiet | -q | 안내 출력을 숨김 |
--in-place와 --output은 함께 사용할 수 없습니다.
마이그레이션 규칙
이 도구는 다섯 가지 규칙을 적용하며, 각 규칙은 출력에 이름으로 보고됩니다.
1. highlight를 span으로
스팬 어노테이션 유형은 v1에서 highlight라고 불렸습니다. v2에서는 span이며, highlight는 부팅 시 "Unknown annotation type: highlight"와 함께 거부됩니다. 이는 v1에서 v2로 넘어갈 때 가장 흔한 호환성 파괴 변경이며, 이를 건너뛴 구성은 마이그레이션 후에도 시작되지 않습니다.
변경 전:
annotation_schemes:
- annotation_type: highlight
name: entities
description: "Mark the named entities"
labels: [PERSON, ORG]변경 후:
annotation_schemes:
- annotation_type: span
name: entities
description: "Mark the named entities"
labels: [PERSON, ORG]2. textarea를 multiline으로
v1의 텍스트 스키마는 여러 줄 동작을 textarea 블록에 구성했습니다. v2에서는 이 설정이 스키마에 직접 놓이고 textarea 블록은 제거됩니다.
변경 전:
annotation_schemes:
- annotation_type: text
name: feedback
description: "Explain your reasoning"
textarea:
on: true
rows: 4
cols: 60변경 후:
annotation_schemes:
- annotation_type: text
name: feedback
description: "Explain your reasoning"
multiline: true
rows: 4
cols: 60이전 블록이 rows와 cols를 설정했다면 둘은 그대로 이어집니다.
3. 레거시 사용자 구성
user_config가 있지만 login 블록이 없는 구성에는 블록이 하나 추가됩니다. user_config 블록 자체는 v2에서 유효하므로 유지됩니다.
변경 전:
user_config:
allow_all_users: true변경 후:
user_config:
allow_all_users: true
login:
type: openallow_all_users 대신 users 목록이 있으면 추가되는 블록은 type: password입니다.
추가된 블록에 의존하기 전에 확인하십시오. 마이그레이션 도구는 type: open을 쓰지만 Potato의 라우팅이 인식하는 로그인 유형은 standard, url_direct, prolific이므로, 공개 접근 작업에는 대개 user_config.allow_all_users: true가 그 역할을 하도록 두는 편이 낫습니다.
4. 레거시 레이블 요구 사항
label_requirement는 v1에서 불리언을 받았고 v2에서는 매핑을 받으므로, 이 규칙이 변환합니다.
변경 전:
annotation_schemes:
- annotation_type: radio
name: sentiment
description: "What is the sentiment?"
labels: [Positive, Negative]
label_requirement: true변경 후:
annotation_schemes:
- annotation_type: radio
name: sentiment
description: "What is the sentiment?"
labels: [Positive, Negative]
label_requirement:
required: true5. 출력 형식
output_annotation_format은 v2 저장소 재작성 이후 아무것도 읽지 않습니다. 어노테이션은 이 값과 관계없이 <output_annotation_dir>/<user>/user_state.json에 저장됩니다. 이 규칙은 이를 export_annotation_format으로 옮기며, 이 키는 해당 형식으로 주기적인 내보내기를 씁니다.
변경 전:
output_annotation_dir: "output/"
output_annotation_format: "json"변경 후:
output_annotation_dir: "output/"
export_annotation_format: jsonl예시: 드라이런
$ potato migrate old_config.yaml --to-v2 --dry-run
Migration changes:
[highlight_to_span] Rename the legacy highlight annotation type to span:
- Renamed annotation_type: highlight -> span in scheme 'entities'
[textarea_to_multiline] Convert textarea.on to multiline format in textbox schemas:
- Converted textarea.on to multiline in schema 'feedback'
[legacy_user_config] Migrate legacy user_config to login format:
- Added login.type: open (from allow_all_users: true)
- Note: user_config is still valid, login section added for clarity
Dry run - no changes written.마이그레이션 후
서버를 시작하기 전에 검증기를 실행하십시오. 마이그레이션 도구는 아는 형태를 고치고 검증기가 나머지를 잡아내기 때문입니다.
potato validate new_config.yaml --strict--strict는 인식되지 않는 키 같은 경고를 출력만 하고 통과시키는 대신 실패로 바꿉니다.
사용해야 할 때
- 이전 Potato용으로 작성된 프로젝트를 업그레이드하는 경우
- 시작 시 지원 중단 경고가 나타나는 경우
- 구성 옵션이 무시되는데 이유를 모르겠는 경우
문제 해결
"Configuration file is empty"
파일을 구문 분석할 수 없거나 아무것도 담고 있지 않습니다. 파일이 존재하고, 읽을 수 있으며, YAML을 담고 있는지 확인하십시오.
"Invalid YAML in configuration file"
구문 오류입니다. 흔한 원인은 일관되지 않은 들여쓰기, 누락된 콜론, 콜론이 들어 있는데 따옴표로 묶이지 않은 값입니다.
"No migrations needed"
다섯 가지 규칙 중 어느 것도 적용되지 않았으므로, 구성이 이미 이 규칙들이 다루는 v2 형태를 사용하고 있다는 뜻입니다. 이는 구성이 유효하다는 것과 같지 않으므로 potato validate --strict도 실행하십시오.
더 읽어보기
- v2의 새로운 기능 - 버전 간 변경 사항
- 구성 기초 - 현재 구성 형식
구현 세부 사항은 소스 문서를 참조하십시오.