# Path: metatlas/tools/logging.py
# def activate_logging(console_level="INFO", console_format=None, file_level="DEBUG", filename=None):
#     """
#     inputs:
#         console_level: string with desired logging level for messages on stdout (notebook)
#         file_level: string with desired logging level for message to log file
#         filename: file to send logs to
#     returns logger
# 
#     Call this function to activate logging to console and file
#     valid logging levels are 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
#     """
#     disable_jupyter_default_logging()
#     activate_module_logging("metatlas", console_level, console_format, file_level, filename)
# 
# Path: metatlas/tools/logging.py
# def activate_module_logging(
#     module, console_level="INFO", console_format=None, file_level="DEBUG", filename=None
# ):
#     """
#     inputs:
#         module: name of logger to capture messages from, often a module name
#         console_level: string with desired logging level for messages on stdout (notebook)
#         file_level: string with desired logging level for message to log file
#         filename: file to send logs to
#     returns logger
# 
#     Call this function to activate logging to console and file
#     valid logging levels are 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
#     """
#     console_handler = get_console_handler(console_level, console_format)
#     file_handler = get_file_handler(file_level, filename)
# 
#     new_logger = logging.getLogger(module)
#     new_logger.handlers[:] = []
#     new_logger.addHandler(console_handler)
#     new_logger.addHandler(file_handler)
#     new_logger.setLevel(
#         levels[file_level] if levels[file_level] < levels[console_level] else levels[console_level]
#     )
#     return new_logger
# 
# Path: metatlas/tools/environment.py
# def get_commit_date() -> str:
#     """Returns a string describing when the HEAD commit was created"""
#     cmd = ["git", "show", "-s", "--format=%ci -- %cr", "HEAD"]
#     return subprocess.run(cmd, cwd=repo_dir(), check=True, capture_output=True, text=True).stdout.rstrip()
# 
# Path: metatlas/tools/environment.py
# def get_repo_hash():
#     """
#     Returns the full hash for the current git commit or 'git not found, hash unknown'
#     """
#     try:
#         result = subprocess.run(["git", "rev-parse", "HEAD"], cwd=repo_dir(), capture_output=True, check=True)
#     except FileNotFoundError:
#         return "git not found, hash unknown"
#     return result.stdout.strip()
# 
# Path: metatlas/tools/environment.py
# def set_git_head(source_code_version_id: str) -> None:
#     """Performs a git checkout"""
#     cmd = ["git", "checkout", source_code_version_id]
#     subprocess.run(cmd, cwd=repo_dir(), check=True, capture_output=True)


import json
import logging
import os
import re
import pandas as pd
from typing import List, Optional
from IPython.core.display import display, HTML
from metatlas.tools.logging import activate_logging
from metatlas.tools.logging import activate_module_logging
from metatlas.tools.environment import get_commit_date
from metatlas.tools.environment import get_repo_hash
from metatlas.tools.environment import set_git_head
"""Jupyter notebook helper functions"""





logger = logging.getLogger(__name__)


def configure_environment(log_level: str) -> None:
    """
    Sets environment variables and configures logging
    inputs:
        log_level: one of 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
    """

# Path: metatlas/tools/logging.py
# def activate_logging(console_level="INFO", console_format=None, file_level="DEBUG", filename=None):
#     """
#     inputs:
#         console_level: string with desired logging level for messages on stdout (notebook)
#         file_level: string with desired logging level for message to log file
#         filename: file to send logs to
#     returns logger
# 
#     Call this function to activate logging to console and file
#     valid logging levels are 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
#     """
#     disable_jupyter_default_logging()
#     activate_module_logging("metatlas", console_level, console_format, file_level, filename)
# 
# Path: metatlas/tools/logging.py
# def activate_module_logging(
#     module, console_level="INFO", console_format=None, file_level="DEBUG", filename=None
# ):
#     """
#     inputs:
#         module: name of logger to capture messages from, often a module name
#         console_level: string with desired logging level for messages on stdout (notebook)
#         file_level: string with desired logging level for message to log file
#         filename: file to send logs to
#     returns logger
# 
#     Call this function to activate logging to console and file
#     valid logging levels are 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
#     """
#     console_handler = get_console_handler(console_level, console_format)
#     file_handler = get_file_handler(file_level, filename)
# 
#     new_logger = logging.getLogger(module)
#     new_logger.handlers[:] = []
#     new_logger.addHandler(console_handler)
#     new_logger.addHandler(file_handler)
#     new_logger.setLevel(
#         levels[file_level] if levels[file_level] < levels[console_level] else levels[console_level]
#     )
#     return new_logger
# 
# Path: metatlas/tools/environment.py
# def get_commit_date() -> str:
#     """Returns a string describing when the HEAD commit was created"""
#     cmd = ["git", "show", "-s", "--format=%ci -- %cr", "HEAD"]
#     return subprocess.run(cmd, cwd=repo_dir(), check=True, capture_output=True, text=True).stdout.rstrip()
# 
# Path: metatlas/tools/environment.py
# def get_repo_hash():
#     """
#     Returns the full hash for the current git commit or 'git not found, hash unknown'
#     """
#     try:
#         result = subprocess.run(["git", "rev-parse", "HEAD"], cwd=repo_dir(), capture_output=True, check=True)
#     except FileNotFoundError:
#         return "git not found, hash unknown"
#     return result.stdout.strip()
# 
# Path: metatlas/tools/environment.py
# def set_git_head(source_code_version_id: str) -> None:
#     """Performs a git checkout"""
#     cmd = ["git", "checkout", source_code_version_id]
#     subprocess.run(cmd, cwd=repo_dir(), check=True, capture_output=True)


# Path: metatlas/tools/notebook.py
import json
import logging
import os
import re
import pandas as pd
from typing import List, Optional
from IPython.core.display import display, HTML
from metatlas.tools.logging import activate_logging
from metatlas.tools.logging import activate_module_logging
from metatlas.tools.environment import get_commit_date
from metatlas.tools.environment import get_repo_hash
from metatlas.tools.environment import set_git_head

"""Jupyter notebook helper functions"""





logger = logging.getLogger(__name__)


def configure_environment(log_level: str) -> None:
    """
    Sets environment variables and configures logging
    inputs:
        log_level: one of 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
    """

    activate_logging(console_level=log_level)