Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keynet_core-0.8.4.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keynet_core-0.8.4-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file keynet_core-0.8.4.tar.gz.

File metadata

  • Download URL: keynet_core-0.8.4.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for keynet_core-0.8.4.tar.gz
Algorithm Hash digest
SHA256 2259b200f4fe41919ec84e6c52b1867bad0cd6e032cdef44ac7362554a13fecd
MD5 5cf65f900d8129b50581e09fd37860ca
BLAKE2b-256 5b27469d7033ccd519a9e9bee048741ef8b03cde8ab4ec4c8442adb7b4a9b8b1

See more details on using hashes here.

File details

Details for the file keynet_core-0.8.4-py3-none-any.whl.

File metadata

  • Download URL: keynet_core-0.8.4-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

Hashes for keynet_core-0.8.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2e5e65e717dd4b39c58fe4a7480cf787dd3cef6bcb96252f92ce011b6f6687f9
MD5 9144ed7ca80284b93bcf59f9b9bb74ee
BLAKE2b-256 f9b044956ae0f973c20c048b3141822c9e04e85f05538f9fb419acf6e963cf77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page