Core utilities and models for keynet packages
Project description
keynet-core
Keynet 패키지들의 핵심 유틸리티와 공통 모델
설치
pip install keynet-core
주요 기능
🔧 공통 유틸리티
- 환경 변수 관리
- 설정 파일 처리
- 로깅 설정
📦 공유 모델
- 데이터 검증 모델
- API 응답 모델
- 설정 스키마
🔌 의존성
- 최소한의 의존성 유지
- 다른 Keynet 패키지의 기반
🔒 Security Features
자동 민감정보 마스킹 (Automatic Sensitive Data Redaction)
keynet-core는 stdout/stderr에 출력되는 민감정보를 자동으로 마스킹합니다.
보호되는 정보:
- AWS Access Keys (AKIA...)
- KEYNET_ prefix credentials (KEYNET_minio, KEYNET_storage 등)
- Passwords, tokens, API keys (key=value 형태, 최소 3자)
- Private keys (PEM format)
- MLflow URIs with credentials
- 환경변수 (AWS_, MLFLOW_, RABBIT_, KEYNET_, APP_API_KEY 등)
자동 활성화:
keynet-core를 설치하면 자동으로 redaction이 활성화됩니다:
pip install keynet-core
# Python 시작 시 자동으로 redaction 활성화!
# import 순서와 무관하게 보호됨
import os
# 환경변수 형태로 출력하면 자동 마스킹
os.environ["AWS_ACCESS_KEY_ID"] = "KEYNET_myaccess"
print(f"AWS_ACCESS_KEY_ID={os.getenv('AWS_ACCESS_KEY_ID')}")
# 출력: AWS_ACCESS_KEY_ID=***ENV_VAR_xxxx***
# KEYNET_ prefix 사용 시 명시적 감지
print("Using credential: KEYNET_myaccess")
# 출력: Using credential: ***KEYNET_KEY_xxxx***
권장사항: KEYNET_ Prefix 사용
개발 환경에서 MinIO credential에 KEYNET_ prefix를 사용하세요:
export AWS_ACCESS_KEY_ID=KEYNET_myaccess
export AWS_SECRET_ACCESS_KEY=KEYNET_mysecret
- ✅ 자동 감지 보장
- ✅ keynet 프로젝트 credential임을 명시
예외 메시지 sanitization:
from keynet_core.security import sanitize_exception
try:
raise ValueError("Error: AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE")
except ValueError as e:
sanitized = sanitize_exception(e)
print(sanitized)
# 출력: Error: AWS_ACCESS_KEY_ID=***ENV_VAR_xxxx***
디버깅 시 비활성화:
export KEYNET_DISABLE_REDACTION=1
python train.py
사용 예제
from keynet_core import Config, check_env
# 환경 변수 검증
if check_env():
print("필수 환경 변수 설정 완료")
# 설정 로드
config = Config()
print(f"MLflow URI: {config.mlflow_tracking_uri}")
API 문서
자세한 API 문서는 GitHub Wiki 참조
라이선스
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keynet_core-0.8.5.tar.gz.
File metadata
- Download URL: keynet_core-0.8.5.tar.gz
- Upload date:
- Size: 29.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c69ebc8aa85f4d7e3c78793f3860301345873a0917dcf99b369f3b5f1e123a0
|
|
| MD5 |
94aa3e686c39620e87a58466b5cd42e8
|
|
| BLAKE2b-256 |
644b094303669e7e5ef9b4d5a70b3cfe7bfe8ffdd7219fd181a54c0bfd1fb073
|
File details
Details for the file keynet_core-0.8.5-py3-none-any.whl.
File metadata
- Download URL: keynet_core-0.8.5-py3-none-any.whl
- Upload date:
- Size: 26.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36cc38f1eeb53db9228a2ed7aa4c5e80dea81da6d2a321bf58c7ab7b25484215
|
|
| MD5 |
2e3253cfafd130f766ab84bf83f37381
|
|
| BLAKE2b-256 |
439403e29116ed7030d38bbabce6304c566d229751ad6abd92ac67a7e6ddcf0a
|