Skip to content

Commit

Permalink
make analyzer optional
Browse files Browse the repository at this point in the history
  • Loading branch information
peckto committed Jul 29, 2022
1 parent 2f36e29 commit e8eb005
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ zstandard = ">=0.17,<0.19"
python-can = "^4.0.0"
tabulate = "^0.8.9"
construct = "^2.10.68"

# A list of all of the optional dependencies, some of which are included in the
# below `extras`. They can be opted into by apps.
numpy = "^1.21.4"
openpyxl = "^3.0.9"
pandas = "^1.3.4"
matplotlib = "^3.4.3"

[tool.poetry.extras]
analyzer = ["numpy", "openpyxl", "pandas", "matplotlib"]

[tool.poetry.dev-dependencies]
black = "^22.6.0"
Sphinx = "^5.0.2"
Expand Down
31 changes: 21 additions & 10 deletions src/gallia/analyzer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@
from tempfile import gettempdir
from typing import Optional

import numpy as np
from gallia.analyzer.operator import Operator
from gallia.analyzer.analyzer import Analyzer
from gallia.analyzer.extractor import Extractor
from gallia.analyzer.reporter import Reporter
from gallia.analyzer.categorizer import Categorizer
from gallia.analyzer.time_analyzer import TimeAnalyzer
from gallia.analyzer.mode_config import LogMode
from gallia.analyzer.arg_help import ArgHelp
from gallia.udscan.core import Script
try:
import numpy as np
from gallia.analyzer.operator import Operator
from gallia.analyzer.analyzer import Analyzer
from gallia.analyzer.extractor import Extractor
from gallia.analyzer.reporter import Reporter
from gallia.analyzer.categorizer import Categorizer
from gallia.analyzer.time_analyzer import TimeAnalyzer
from gallia.analyzer.mode_config import LogMode
from gallia.analyzer.arg_help import ArgHelp
from gallia.udscan.core import Script

ANALYZER_AVAILABLE = True
except ModuleNotFoundError:
ANALYZER_AVAILABLE = False


# ========================================================== #
# [Rule for arguments]
Expand All @@ -39,6 +45,11 @@ class AnalyzerMain(Script):
def __init__(self) -> None:
super().__init__()
self.artifacts_dir: Path
if not ANALYZER_AVAILABLE:
self.logger.log_error(
"Please install optional dependencies to run the analyzer"
)
sys.exit(1)

def prepare_artifactsdir(self, path: Optional[Path]) -> Path:
if path is None:
Expand Down

0 comments on commit e8eb005

Please sign in to comment.