-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_all_analyzers.py
More file actions
51 lines (42 loc) · 1.79 KB
/
test_all_analyzers.py
File metadata and controls
51 lines (42 loc) · 1.79 KB
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
import asyncio
import logging
import sys
from pathlib import Path
# Configure logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
logger = logging.getLogger(__name__)
async def test_analyzers():
"""Test all analyzers to verify fixes."""
try:
# Import analyzers
from src.analyzers.json_analyzer import JsonAnalyzer
from src.analyzers.csv_analyzer import CsvAnalyzer
from src.analyzers.text_analyzer import TextAnalyzer
# Create instances of the analyzers
json_analyzer = JsonAnalyzer()
csv_analyzer = CsvAnalyzer()
text_analyzer = TextAnalyzer()
# Path to the problematic JSON file
json_file = Path(r"C:\Users\jonah\Documents\Cline\datasets\tategallery\tategallery_artists\a\abakanowicz-magdalena-10093.json")
if json_file.exists():
logger.info(f"Testing JSON analyzer with: {json_file}")
is_json = await json_analyzer.detect(json_file)
logger.info(f"File detected as JSON: {is_json}")
if is_json:
schema = await json_analyzer.analyze(json_file)
logger.info(f"Successfully analyzed JSON file: {schema.id}")
logger.info(f"Found {len(schema.tables)} tables in the schema")
logger.info("JSON analyzer is working correctly!")
else:
logger.warning(f"JSON file not found: {json_file}")
logger.info("All tests passed successfully!")
return 0
except Exception as e:
logger.error(f"Error testing analyzers: {str(e)}", exc_info=True)
return 1
if __name__ == "__main__":
exit_code = asyncio.run(test_analyzers())
sys.exit(exit_code)