-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5daa021
commit 18f2e1f
Showing
16 changed files
with
119 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Various utilities for the ngio package.""" | ||
|
||
from ngio.utils._common_types import ArrayLike | ||
from ngio.utils._logger import ngio_logger, set_logger_level | ||
from ngio.utils._pydantic_utils import BaseWithExtraFields, unique_items_validator | ||
|
||
__all__ = [ | ||
"ArrayLike", | ||
"BaseWithExtraFields", | ||
"unique_items_validator", | ||
"ngio_logger", | ||
"set_logger_level", | ||
] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Create a generic error class for the NGFF project | ||
|
||
|
||
class NgioError(Exception): | ||
"""Base class for all errors in the NGFF project.""" | ||
|
||
pass | ||
|
||
|
||
class NgioFileNotFoundError(NgioError): | ||
"""Error raised when a file is not found.""" | ||
|
||
pass | ||
|
||
|
||
class NgioFileExistsError(NgioError): | ||
"""Error raised when a file already exists.""" | ||
|
||
pass | ||
|
||
|
||
class NgioNGFFValidationError(NgioError): | ||
"""Error raised when a file does not pass validation.""" | ||
|
||
pass | ||
|
||
|
||
class NgioTableValidationError(NgioError): | ||
"""Error raised when a table does not pass validation.""" | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import logging | ||
|
||
# Configure the logger | ||
ngio_logger = logging.getLogger("NgioLogger") | ||
ngio_logger.setLevel(logging.ERROR) | ||
|
||
# Set up a console handler with a custom format | ||
console_handler = logging.StreamHandler() | ||
formatter = logging.Formatter( | ||
"%(asctime)s - %(levelname)s - %(name)s - " | ||
"[%(module)s.%(funcName)s:%(lineno)d]: %(message)s" | ||
) | ||
console_handler.setFormatter(formatter) | ||
|
||
# Add the handler to the logger | ||
ngio_logger.addHandler(console_handler) | ||
|
||
|
||
def set_logger_level(level: str) -> None: | ||
"""Set the logger level. | ||
Args: | ||
level: The level to set the logger to. | ||
Must be one of "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL". | ||
""" | ||
if level not in ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]: | ||
raise ValueError(f"Invalid log level: {level}") | ||
|
||
ngio_logger.setLevel(level) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters