petter2025 commited on
Commit
68150cc
Β·
verified Β·
1 Parent(s): 2502f74

Update config/settings.py

Browse files
Files changed (1) hide show
  1. config/settings.py +60 -30
config/settings.py CHANGED
@@ -1,6 +1,6 @@
1
  """
2
  Configuration management for ARF Demo
3
- Updated with REAL ARF installation detection
4
  """
5
  from typing import Optional, Dict, Any, List
6
  from enum import Enum
@@ -162,6 +162,26 @@ class Settings(BaseSettings):
162
  )
163
 
164
  # ===== Validation =====
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  @validator("arf_api_key")
166
  def validate_api_key(cls, v: Optional[str], values: Dict[str, Any]) -> Optional[str]:
167
  if values.get("arf_mode") == ARFMode.ENTERPRISE and not v:
@@ -273,6 +293,44 @@ class Settings(BaseSettings):
273
  use_enum_values = True
274
 
275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  # Global settings instance with installation detection
277
  try:
278
  # First detect installation
@@ -315,32 +373,4 @@ except Exception as e:
315
 
316
  def get_settings() -> Settings:
317
  """Get settings instance (singleton pattern)"""
318
- return settings
319
-
320
-
321
- def print_installation_status():
322
- """Print installation status to console"""
323
- s = get_settings()
324
- status = s.get_installation_status()
325
-
326
- print("=" * 70)
327
- print("πŸš€ ARF Ultimate Investor Demo - Installation Status")
328
- print("=" * 70)
329
-
330
- print(f"πŸ“¦ ARF OSS: {'βœ… v' + s.arf_oss_version if s.arf_oss_installed else '⚠️ Not installed'}")
331
- print(f"🏒 Enterprise: {'βœ… v' + s.arf_enterprise_version if s.arf_enterprise_installed else '⚠️ Not installed'}")
332
- print(f"🎯 Mode: {s.arf_mode.value}")
333
- print(f"πŸ€– Using True ARF: {'βœ… Yes' if s.use_true_arf else '⚠️ Mock mode'}")
334
-
335
- recommendations = s.get_installation_recommendations()
336
- if recommendations:
337
- print("\nπŸ’‘ Recommendations:")
338
- for rec in recommendations:
339
- print(f" β€’ {rec}")
340
-
341
- print("=" * 70)
342
-
343
-
344
- # Print status on import (but only if not in test mode)
345
- if __name__ != "__main__" and "pytest" not in sys.modules:
346
- print_installation_status()
 
1
  """
2
  Configuration management for ARF Demo
3
+ Updated with REAL ARF installation detection - FIXED VERSION
4
  """
5
  from typing import Optional, Dict, Any, List
6
  from enum import Enum
 
162
  )
163
 
164
  # ===== Validation =====
165
+ @validator("arf_mode", "default_safety_mode", pre=True)
166
+ def validate_enums(cls, v):
167
+ """Convert strings to enum values if needed"""
168
+ if isinstance(v, str):
169
+ # Try to match enum values
170
+ if hasattr(cls, '__fields__'):
171
+ field_name = None
172
+ for field in cls.__fields__.values():
173
+ if field.name == 'arf_mode' and isinstance(v, str):
174
+ try:
175
+ return ARFMode(v.lower())
176
+ except ValueError:
177
+ return ARFMode.DEMO
178
+ elif field.name == 'default_safety_mode' and isinstance(v, str):
179
+ try:
180
+ return SafetyMode(v.lower())
181
+ except ValueError:
182
+ return SafetyMode.ADVISORY
183
+ return v
184
+
185
  @validator("arf_api_key")
186
  def validate_api_key(cls, v: Optional[str], values: Dict[str, Any]) -> Optional[str]:
187
  if values.get("arf_mode") == ARFMode.ENTERPRISE and not v:
 
293
  use_enum_values = True
294
 
295
 
296
+ def print_installation_status():
297
+ """Print installation status to console - SAFE VERSION"""
298
+ try:
299
+ # Create settings instance first to avoid circular imports
300
+ installation_info = Settings.detect_installation()
301
+
302
+ # Create settings with installation info
303
+ s = Settings(
304
+ arf_oss_installed=installation_info["oss_installed"],
305
+ arf_enterprise_installed=installation_info["enterprise_installed"],
306
+ arf_oss_version=installation_info["oss_version"],
307
+ arf_enterprise_version=installation_info["enterprise_version"],
308
+ )
309
+
310
+ print("=" * 70)
311
+ print("πŸš€ ARF Ultimate Investor Demo - Installation Status")
312
+ print("=" * 70)
313
+
314
+ print(f"πŸ“¦ ARF OSS: {'βœ… v' + s.arf_oss_version if s.arf_oss_installed else '⚠️ Not installed'}")
315
+ print(f"🏒 Enterprise: {'βœ… v' + s.arf_enterprise_version if s.arf_enterprise_installed else '⚠️ Not installed'}")
316
+
317
+ # Safe enum access - convert to string first
318
+ mode_str = str(s.arf_mode) if hasattr(s.arf_mode, 'value') else str(s.arf_mode)
319
+ print(f"🎯 Mode: {mode_str.upper()}")
320
+ print(f"πŸ€– Using True ARF: {'βœ… Yes' if s.use_true_arf else '⚠️ Mock mode'}")
321
+
322
+ recommendations = s.get_installation_recommendations()
323
+ if recommendations:
324
+ print("\nπŸ’‘ Recommendations:")
325
+ for rec in recommendations:
326
+ print(f" β€’ {rec}")
327
+
328
+ print("=" * 70)
329
+
330
+ except Exception as e:
331
+ print(f"⚠️ Could not print installation status: {e}")
332
+
333
+
334
  # Global settings instance with installation detection
335
  try:
336
  # First detect installation
 
373
 
374
  def get_settings() -> Settings:
375
  """Get settings instance (singleton pattern)"""
376
+ return settings