File size: 2,161 Bytes
c9f18eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""

MediSync: Multi-Modal Medical Analysis System - Runner Script

============================================================

This script downloads sample data and launches the MediSync application.

"""

import logging
import sys
from pathlib import Path

# Set up logging
logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    handlers=[logging.StreamHandler(), logging.FileHandler("mediSync.log")],
)
logger = logging.getLogger(__name__)


def main():
    """

    Main function to set up and run the MediSync application.

    """
    logger.info("Starting MediSync setup")

    # Add the current directory to Python path
    current_dir = Path(__file__).resolve().parent
    sys.path.append(str(current_dir))

    # Download sample data if needed
    try:
        logger.info("Checking for sample data")
        from mediSync.utils.download_samples import (
            create_sample_info_file,
            download_sample_images,
        )

        # Check if sample directory exists and contains images
        sample_dir = current_dir / "mediSync" / "data" / "sample"
        sample_dir.mkdir(parents=True, exist_ok=True)

        image_files = list(sample_dir.glob("*.jpg")) + list(sample_dir.glob("*.png"))

        if not image_files:
            logger.info("No sample images found. Downloading...")
            download_sample_images()
            create_sample_info_file()
        else:
            logger.info(f"Found {len(image_files)} existing sample images")

    except Exception as e:
        logger.error(f"Error setting up sample data: {e}")
        print(f"Warning: Could not set up sample data: {e}")

    # Launch the application
    try:
        logger.info("Launching MediSync application")
        from mediSync.app import create_interface

        create_interface()

    except Exception as e:
        logger.error(f"Error launching application: {e}")
        print(f"Error: Failed to launch MediSync application: {e}")
        return 1

    return 0


if __name__ == "__main__":
    sys.exit(main())