Coverage for openhcs/__init__.py: 92.9%

12 statements  

« prev     ^ index     » next       coverage.py v7.10.3, created at 2025-08-14 05:57 +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 

11 

12__version__ = "0.1.0" 

13 

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

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

16_original_file_handler_init = logging.FileHandler.__init__ 

17 

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

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

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

21 

22logging.FileHandler.__init__ = _utf8_file_handler_init 

23 

24# Set up basic logging configuration if none exists 

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

26def _ensure_basic_logging(): 

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

28 root_logger = logging.getLogger() 

29 

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

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

32 # Set up basic console logging at INFO level 

33 logging.basicConfig( 

34 level=logging.INFO, 

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

36 ) 

37 

38# Configure basic logging on import 

39_ensure_basic_logging() 

40 

41# Re-export public API 

42#from openhcs.ez.api import ( 

43# # Core functions 

44# initialize, 

45# create_config, 

46# run_pipeline, 

47# stitch_images, 

48# 

49# # Key types 

50# PipelineConfig, 

51# BackendConfig, 

52# MISTConfig, 

53# VirtualPath, 

54# PhysicalPath, 

55#) 

56# 

57__all__ = [ 

58 # Core functions 

59 "initialize", 

60 "create_config", 

61 "run_pipeline", 

62 "stitch_images", 

63 

64 # Key types 

65 "PipelineConfig", 

66 "BackendConfig", 

67 "MISTConfig", 

68 "VirtualPath", 

69 "PhysicalPath", 

70]