Coverage for openhcs/utils/environment.py: 14.3%

10 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-04 02:09 +0000

1""" 

2Environment detection utilities for OpenHCS. 

3 

4Provides functions for detecting runtime environment characteristics 

5like headless mode, CI environments, and other context-specific settings. 

6""" 

7import os 

8 

9 

10def is_headless_mode() -> bool: 

11 """ 

12 Detect headless/CI contexts where viz deps should not be required at import time. 

13 

14 CPU-only mode does NOT imply headless - you can run CPU mode with napari. 

15 Only CI or explicit OPENHCS_HEADLESS flag triggers headless mode. 

16 

17 Returns: 

18 True if running in headless mode (CI or explicitly set), False otherwise 

19 """ 

20 try: 

21 if os.getenv('CI', '').lower() == 'true': 

22 return True 

23 if os.getenv('OPENHCS_HEADLESS', '').lower() == 'true': 

24 return True 

25 except Exception: 

26 pass 

27 return False 

28