Coverage for openhcs/__init__.py: 63.0%

19 statements  

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

1""" 

2OpenHCS: A library for stitching microscopy images. 

3 

4This module provides the public API for OpenHCS. 

5It re-exports only the intended public symbols from openhcs.ez.api 

6and does NOT import from internal modules in a way that triggers 

7registrations or other side-effects. 

8""" 

9 

10import logging 

11import sys 

12import platform 

13 

14__version__ = "0.3.15" 

15 

16# Force UTF-8 encoding for stdout/stderr on Windows 

17# This ensures emoji and Unicode characters work in console output 

18if platform.system() == 'Windows': 18 ↛ 19line 18 didn't jump to line 19 because the condition on line 18 was never true

19 if hasattr(sys.stdout, 'reconfigure'): 

20 sys.stdout.reconfigure(encoding='utf-8') 

21 if hasattr(sys.stderr, 'reconfigure'): 

22 sys.stderr.reconfigure(encoding='utf-8') 

23 

24# Monkey patch logging.FileHandler to default to UTF-8 encoding 

25# This ensures all log files support emojis and Unicode characters 

26_original_file_handler_init = logging.FileHandler.__init__ 

27 

28def _utf8_file_handler_init(self, filename, mode='a', encoding='utf-8', delay=False, errors=None): 

29 """FileHandler.__init__ with UTF-8 encoding as default.""" 

30 return _original_file_handler_init(self, filename, mode, encoding, delay, errors) 

31 

32logging.FileHandler.__init__ = _utf8_file_handler_init 

33 

34# Set up basic logging configuration if none exists 

35# This ensures INFO level logging works when testing outside the TUI 

36def _ensure_basic_logging(): 

37 """Ensure basic logging is configured if no configuration exists.""" 

38 root_logger = logging.getLogger() 

39 

40 # Only configure if no handlers exist and level is too high 

41 if not root_logger.handlers and root_logger.level > logging.INFO: 41 ↛ exitline 41 didn't return from function '_ensure_basic_logging' because the condition on line 41 was always true

42 # Set up basic console logging at INFO level 

43 logging.basicConfig( 

44 level=logging.INFO, 

45 format='%(asctime)s - %(name)s - %(levelname)s - %(message)s' 

46 ) 

47 

48# Configure basic logging on import 

49_ensure_basic_logging() 

50 

51# Re-export public API 

52#from openhcs.ez.api import ( 

53# # Core functions 

54# initialize, 

55# create_config, 

56# run_pipeline, 

57# stitch_images, 

58# 

59# # Key types 

60# PipelineConfig, 

61# BackendConfig, 

62# MISTConfig, 

63# VirtualPath, 

64# PhysicalPath, 

65#) 

66# 

67__all__ = [ 

68 # Core functions 

69 "initialize", 

70 "create_config", 

71 "run_pipeline", 

72 "stitch_images", 

73 

74 # Key types 

75 "PipelineConfig", 

76 "BackendConfig", 

77 "MISTConfig", 

78 "VirtualPath", 

79 "PhysicalPath", 

80]