Upload folder using huggingface_hub
Browse files
config/__init__.py
ADDED
|
File without changes
|
config/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (162 Bytes). View file
|
|
|
config/__pycache__/constants.cpython-311.pyc
ADDED
|
Binary file (1.6 kB). View file
|
|
|
config/__pycache__/settings.cpython-311.pyc
ADDED
|
Binary file (2.6 kB). View file
|
|
|
config/constants.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Application constants for Chronos 2 Forecasting App
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
# Chronos-2 Model from https://huggingface.co/papers/2510.15821
|
| 6 |
+
# The official Chronos-2 model with group attention mechanism
|
| 7 |
+
# Supports: univariate, multivariate, and covariate-informed forecasting
|
| 8 |
+
CHRONOS2_MODEL = 's3://autogluon/chronos-2'
|
| 9 |
+
|
| 10 |
+
# Forecast horizons with labels
|
| 11 |
+
FORECAST_HORIZONS = {
|
| 12 |
+
'1D': 1,
|
| 13 |
+
'1W': 7,
|
| 14 |
+
'1M': 30,
|
| 15 |
+
'3M': 90,
|
| 16 |
+
'6M': 180,
|
| 17 |
+
'1Y': 365
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
# Confidence levels
|
| 21 |
+
CONFIDENCE_LEVELS = [80, 90, 95, 99]
|
| 22 |
+
|
| 23 |
+
# File upload settings
|
| 24 |
+
MAX_FILE_SIZE = 100 * 1024 * 1024 # 100MB
|
| 25 |
+
ALLOWED_EXTENSIONS = ['csv', 'xlsx', 'xls']
|
| 26 |
+
|
| 27 |
+
# Data processing settings
|
| 28 |
+
MAX_MISSING_PERCENT = 10
|
| 29 |
+
MIN_DATA_POINTS_MULTIPLIER = 2
|
| 30 |
+
MAX_CHART_POINTS = 10000
|
| 31 |
+
MAX_PREDICTION_HISTORY = 10
|
| 32 |
+
|
| 33 |
+
# UI colors
|
| 34 |
+
COLORS = {
|
| 35 |
+
'primary': '#0066CC',
|
| 36 |
+
'secondary': '#5C6BC0',
|
| 37 |
+
'success': '#4CAF50',
|
| 38 |
+
'warning': '#FF9800',
|
| 39 |
+
'danger': '#F44336',
|
| 40 |
+
'info': '#2196F3',
|
| 41 |
+
'historical': '#0066CC',
|
| 42 |
+
'forecast': '#FFD700',
|
| 43 |
+
'separator': '#999999',
|
| 44 |
+
'confidence': {
|
| 45 |
+
80: 'rgba(255, 215, 0, 0.4)',
|
| 46 |
+
90: 'rgba(255, 215, 0, 0.3)',
|
| 47 |
+
95: 'rgba(255, 215, 0, 0.2)',
|
| 48 |
+
99: 'rgba(255, 215, 0, 0.1)'
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
# Chart configuration
|
| 53 |
+
CHART_CONFIG = {
|
| 54 |
+
'displayModeBar': True,
|
| 55 |
+
'displaylogo': False,
|
| 56 |
+
'modeBarButtonsToRemove': ['lasso2d', 'select2d'],
|
| 57 |
+
'toImageButtonOptions': {
|
| 58 |
+
'format': 'png',
|
| 59 |
+
'filename': 'chronos_forecast',
|
| 60 |
+
'height': 800,
|
| 61 |
+
'width': 1200,
|
| 62 |
+
'scale': 2
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
# Performance settings
|
| 67 |
+
DEBOUNCE_DELAY = 500 # milliseconds
|
| 68 |
+
LARGE_DATASET_THRESHOLD = 100000
|
| 69 |
+
|
| 70 |
+
# Date format patterns to try
|
| 71 |
+
DATE_FORMATS = [
|
| 72 |
+
'%Y-%m-%d',
|
| 73 |
+
'%Y/%m/%d',
|
| 74 |
+
'%d-%m-%Y',
|
| 75 |
+
'%d/%m/%Y',
|
| 76 |
+
'%m-%d-%Y',
|
| 77 |
+
'%m/%d/%Y',
|
| 78 |
+
'%Y-%m-%d %H:%M:%S',
|
| 79 |
+
'%Y/%m/%d %H:%M:%S',
|
| 80 |
+
'%d-%m-%Y %H:%M:%S',
|
| 81 |
+
'%d/%m/%Y %H:%M:%S'
|
| 82 |
+
]
|
config/settings.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Configuration settings for different deployment environments
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
|
| 8 |
+
# Base directory
|
| 9 |
+
BASE_DIR = Path(__file__).parent.parent
|
| 10 |
+
|
| 11 |
+
# Detect environment
|
| 12 |
+
ENVIRONMENT = os.environ.get('ENVIRONMENT', 'local')
|
| 13 |
+
IS_DATABRICKS = os.environ.get('DATABRICKS_RUNTIME_VERSION') is not None
|
| 14 |
+
|
| 15 |
+
# Local development settings
|
| 16 |
+
LOCAL_CONFIG = {
|
| 17 |
+
'host': '127.0.0.1',
|
| 18 |
+
'port': 8050,
|
| 19 |
+
'debug': True,
|
| 20 |
+
'model_cache': str(BASE_DIR / 'cache'),
|
| 21 |
+
'upload_folder': str(BASE_DIR / 'uploads'),
|
| 22 |
+
'datasets_folder': str(BASE_DIR / 'datasets'),
|
| 23 |
+
'max_workers': 1,
|
| 24 |
+
'use_reloader': True
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
# Databricks deployment settings
|
| 28 |
+
DATABRICKS_CONFIG = {
|
| 29 |
+
'host': '0.0.0.0',
|
| 30 |
+
'port': int(os.environ.get('DATABRICKS_APP_PORT', 8080)),
|
| 31 |
+
'debug': False,
|
| 32 |
+
'model_cache': '/tmp/model_cache',
|
| 33 |
+
'upload_folder': '/tmp/uploads',
|
| 34 |
+
'datasets_folder': '/dbfs/datasets',
|
| 35 |
+
'max_workers': 4,
|
| 36 |
+
'use_reloader': False
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
# Select configuration based on environment
|
| 40 |
+
CONFIG = DATABRICKS_CONFIG if IS_DATABRICKS else LOCAL_CONFIG
|
| 41 |
+
|
| 42 |
+
# Device configuration - defaults to CUDA with automatic CPU fallback
|
| 43 |
+
DEVICE = os.environ.get('DEVICE', 'cuda') # 'cuda' (with CPU fallback), 'cpu', or 'auto'
|
| 44 |
+
|
| 45 |
+
# Logging configuration
|
| 46 |
+
LOG_LEVEL = os.environ.get('LOG_LEVEL', 'INFO' if not CONFIG['debug'] else 'DEBUG')
|
| 47 |
+
LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
| 48 |
+
LOG_FILE = str(BASE_DIR / 'logs' / 'chronos2_app.log')
|
| 49 |
+
|
| 50 |
+
# Create required directories
|
| 51 |
+
def setup_directories():
|
| 52 |
+
"""Create required directories if they don't exist"""
|
| 53 |
+
for key in ['model_cache', 'upload_folder', 'datasets_folder']:
|
| 54 |
+
path = Path(CONFIG[key])
|
| 55 |
+
path.mkdir(parents=True, exist_ok=True)
|
| 56 |
+
|
| 57 |
+
# Create logs directory
|
| 58 |
+
Path(LOG_FILE).parent.mkdir(parents=True, exist_ok=True)
|
| 59 |
+
|
| 60 |
+
# Model configuration
|
| 61 |
+
MODEL_CONFIG = {
|
| 62 |
+
'warmup_enabled': True,
|
| 63 |
+
'warmup_length': 100,
|
| 64 |
+
'warmup_horizon': 10,
|
| 65 |
+
'cache_enabled': True,
|
| 66 |
+
'memory_limit_gb': 6
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
# App metadata
|
| 70 |
+
APP_METADATA = {
|
| 71 |
+
'title': 'Chronos 2 Time Series Forecasting',
|
| 72 |
+
'subtitle': 'Production-Ready ML Model Testing Interface',
|
| 73 |
+
'version': '1.0.0',
|
| 74 |
+
'author': 'Your Organization'
|
| 75 |
+
}
|