-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_json_analyzer.py
More file actions
52 lines (42 loc) · 1.75 KB
/
test_json_analyzer.py
File metadata and controls
52 lines (42 loc) · 1.75 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
52
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_json_analyzer():
"""Test the JsonAnalyzer with the problematic file."""
try:
# Import the JsonAnalyzer
from src.analyzers.json_analyzer import JsonAnalyzer
# Create an instance of the analyzer
analyzer = JsonAnalyzer()
# Path to the problematic JSON file
problematic_file = Path(r"C:\Users\jonah\Documents\Cline\datasets\tategallery\tategallery_artists\a\abakanowicz-magdalena-10093.json")
if not problematic_file.exists():
logger.error(f"File not found: {problematic_file}")
return 1
logger.info(f"Testing file: {problematic_file}")
# Try to detect if the file is JSON
is_json = await analyzer.detect(problematic_file)
logger.info(f"File detected as JSON: {is_json}")
if is_json:
# Try to analyze the file
schema = await analyzer.analyze(problematic_file)
logger.info(f"Successfully analyzed file and extracted schema: {schema.id}")
logger.info(f"Found {len(schema.tables)} tables in the schema")
logger.info("JSON analyzer is working correctly!")
return 0
else:
logger.error("File not detected as JSON")
return 1
except Exception as e:
logger.error(f"Error testing JSON analyzer: {str(e)}", exc_info=True)
return 1
if __name__ == "__main__":
exit_code = asyncio.run(test_json_analyzer())
sys.exit(exit_code)