rifatSDAS commited on
Commit
daffff7
·
1 Parent(s): d5a8545

Remove test and setup files

Browse files
Files changed (3) hide show
  1. setup.bat +0 -89
  2. setup.sh +0 -87
  3. test_app.py +0 -173
setup.bat DELETED
@@ -1,89 +0,0 @@
1
- @echo off
2
- REM Geospatial AI Query System - Quick Start Script (Windows)
3
- REM This script helps you set up and run the application locally
4
-
5
- echo ================================
6
- echo Geospatial AI Query System - Setup
7
- echo ================================
8
- echo.
9
-
10
- REM Check Python version
11
- echo Checking Python version...
12
- python --version >nul 2>&1
13
- if errorlevel 1 (
14
- echo [ERROR] Python 3 is not installed. Please install Python 3.8 or higher.
15
- pause
16
- exit /b 1
17
- )
18
- python --version
19
- echo [OK] Python found
20
- echo.
21
-
22
- REM Create virtual environment
23
- echo Creating virtual environment...
24
- if not exist "venv" (
25
- python -m venv venv
26
- echo [OK] Virtual environment created
27
- ) else (
28
- echo [OK] Virtual environment already exists
29
- )
30
- echo.
31
-
32
- REM Activate virtual environment
33
- echo Activating virtual environment...
34
- call venv\Scripts\activate.bat
35
- echo [OK] Virtual environment activated
36
- echo.
37
-
38
- REM Upgrade pip
39
- echo Upgrading pip...
40
- python -m pip install --upgrade pip >nul 2>&1
41
- echo [OK] Pip upgraded
42
- echo.
43
-
44
- REM Install requirements
45
- echo Installing dependencies...
46
- echo This may take a few minutes...
47
- pip install -r requirements.txt
48
- if errorlevel 1 (
49
- echo [ERROR] Failed to install dependencies
50
- pause
51
- exit /b 1
52
- )
53
- echo [OK] All dependencies installed successfully
54
- echo.
55
-
56
- REM Check for HF_TOKEN
57
- echo Checking for Hugging Face token...
58
- if "%HF_TOKEN%"=="" (
59
- echo [WARNING] HF_TOKEN not set (optional for testing)
60
- echo To enable LLM features, get a token from:
61
- echo https://huggingface.co/settings/tokens
62
- echo Then run: set HF_TOKEN=your_token_here
63
- ) else (
64
- echo [OK] HF_TOKEN found
65
- )
66
- echo.
67
-
68
- REM Run tests
69
- echo Running tests...
70
- pytest test_app.py -v
71
- if errorlevel 1 (
72
- echo [WARNING] Some tests failed (app may still work)
73
- ) else (
74
- echo [OK] All tests passed
75
- )
76
- echo.
77
-
78
- REM Start application
79
- echo ================================
80
- echo Starting application...
81
- echo ================================
82
- echo.
83
- echo The app will be available at:
84
- echo http://localhost:7860
85
- echo.
86
- echo Press Ctrl+C to stop the application
87
- echo.
88
-
89
- python app.py
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
setup.sh DELETED
@@ -1,87 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Geospatial AI Query System - Quick Start Script
4
- # This script helps you set up and run the application locally
5
-
6
- echo "🌍 Geospatial AI Query System - Setup"
7
- echo "======================================"
8
- echo ""
9
-
10
- # Check Python version
11
- echo "Checking Python version..."
12
- python_version=$(python3 --version 2>&1)
13
- if [[ $? -ne 0 ]]; then
14
- echo "❌ Python 3 is not installed. Please install Python 3.8 or higher."
15
- exit 1
16
- fi
17
- echo "✅ Found: $python_version"
18
- echo ""
19
-
20
- # Create virtual environment
21
- echo "Creating virtual environment..."
22
- if [ ! -d "venv" ]; then
23
- python3 -m venv venv
24
- echo "✅ Virtual environment created"
25
- else
26
- echo "✅ Virtual environment already exists"
27
- fi
28
- echo ""
29
-
30
- # Activate virtual environment
31
- echo "Activating virtual environment..."
32
- source venv/bin/activate
33
- echo "✅ Virtual environment activated"
34
- echo ""
35
-
36
- # Upgrade pip
37
- echo "Upgrading pip..."
38
- pip install --upgrade pip > /dev/null 2>&1
39
- echo "✅ Pip upgraded"
40
- echo ""
41
-
42
- # Install requirements
43
- echo "Installing dependencies..."
44
- echo "This may take a few minutes..."
45
- pip install -r requirements.txt
46
- if [[ $? -eq 0 ]]; then
47
- echo "✅ All dependencies installed successfully"
48
- else
49
- echo "❌ Failed to install dependencies"
50
- exit 1
51
- fi
52
- echo ""
53
-
54
- # Check for HF_TOKEN
55
- echo "Checking for Hugging Face token..."
56
- if [ -z "$HF_TOKEN" ]; then
57
- echo "⚠️ HF_TOKEN not set (optional for testing)"
58
- echo " To enable LLM features, get a token from:"
59
- echo " https://huggingface.co/settings/tokens"
60
- echo " Then run: export HF_TOKEN=your_token_here"
61
- else
62
- echo "✅ HF_TOKEN found"
63
- fi
64
- echo ""
65
-
66
- # Run tests
67
- echo "Running tests..."
68
- pytest test_app.py -v
69
- if [[ $? -eq 0 ]]; then
70
- echo "✅ All tests passed"
71
- else
72
- echo "⚠️ Some tests failed (app may still work)"
73
- fi
74
- echo ""
75
-
76
- # Start application
77
- echo "======================================"
78
- echo "🚀 Starting application..."
79
- echo "======================================"
80
- echo ""
81
- echo "The app will be available at:"
82
- echo "http://localhost:7860"
83
- echo ""
84
- echo "Press Ctrl+C to stop the application"
85
- echo ""
86
-
87
- python app.py
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
test_app.py DELETED
@@ -1,173 +0,0 @@
1
- """
2
- Test suite for Geospatial AI Query System
3
- Run: pytest test_app.py
4
- """
5
-
6
- import pytest
7
- import pandas as pd
8
- import geopandas as gpd
9
- from pathlib import Path
10
- from data_utils import DataEnhancer, QueryEnhancer, GeoStats
11
-
12
- # Path to local Natural Earth data (geopandas.datasets was deprecated in GeoPandas 1.0)
13
- DATA_DIR = Path(__file__).parent / "data" / "ne_110m_admin_0_countries"
14
- NATURAL_EARTH_SHP = DATA_DIR / "ne_110m_admin_0_countries.shp"
15
-
16
- class TestDataEnhancer:
17
- """Test data enhancement utilities"""
18
-
19
- def test_economic_data_structure(self):
20
- """Test economic data has correct structure"""
21
- data = DataEnhancer.get_sample_economic_data()
22
- assert isinstance(data, dict)
23
- assert 'United States' in data
24
- assert 'gdp_growth' in data['United States']
25
- assert 'unemployment' in data['United States']
26
- assert 'inflation' in data['United States']
27
-
28
- def test_environmental_data_structure(self):
29
- """Test environmental data has correct structure"""
30
- data = DataEnhancer.get_sample_environmental_data()
31
- assert isinstance(data, dict)
32
- assert 'China' in data
33
- assert 'co2_per_capita' in data['China']
34
- assert 'renewable_energy' in data['China']
35
-
36
- def test_enrich_dataframe(self):
37
- """Test dataframe enrichment"""
38
- # Create sample dataframe
39
- df = pd.DataFrame({
40
- 'name': ['United States', 'China', 'Germany'],
41
- 'pop_est': [331000000, 1440000000, 83000000],
42
- 'gdp_md_est': [21000000, 14000000, 3800000]
43
- })
44
-
45
- enriched = DataEnhancer.enrich_dataframe(df, 'economic')
46
- assert 'gdp_growth' in enriched.columns
47
- assert enriched.loc[enriched['name'] == 'United States', 'gdp_growth'].iloc[0] == 2.1
48
-
49
- class TestQueryEnhancer:
50
- """Test query enhancement utilities"""
51
-
52
- def test_expand_continent(self):
53
- """Test continent expansion"""
54
- result = QueryEnhancer.expand_location('asia')
55
- assert result == ['Asia']
56
-
57
- def test_expand_country_group_brics(self):
58
- """Test BRICS expansion"""
59
- result = QueryEnhancer.expand_location('brics')
60
- assert 'Brazil' in result
61
- assert 'India' in result
62
- assert 'China' in result
63
- assert len(result) == 5
64
-
65
- def test_expand_country_group_g7(self):
66
- """Test G7 expansion"""
67
- result = QueryEnhancer.expand_location('g7')
68
- assert 'United States of America' in result
69
- assert 'Japan' in result
70
- assert len(result) == 7
71
-
72
- def test_validate_indicators(self):
73
- """Test indicator validation"""
74
- indicators = ['GDP', 'Population', 'CO2 emissions']
75
- result = QueryEnhancer.validate_indicators(indicators)
76
- assert 'gdp_md_est' in result
77
- assert 'pop_est' in result
78
-
79
- class TestGeoStats:
80
- """Test statistical utilities"""
81
-
82
- def test_calculate_correlation(self):
83
- """Test correlation calculation"""
84
- df = pd.DataFrame({
85
- 'col1': [1, 2, 3, 4, 5],
86
- 'col2': [2, 4, 6, 8, 10]
87
- })
88
- corr = GeoStats.calculate_correlation(df, 'col1', 'col2')
89
- assert corr == 1.0 # Perfect positive correlation
90
-
91
- def test_summary_stats(self):
92
- """Test summary statistics"""
93
- df = pd.DataFrame({
94
- 'values': [10, 20, 30, 40, 50]
95
- })
96
- stats = GeoStats.generate_summary_stats(df, 'values')
97
- assert stats['mean'] == 30.0
98
- assert stats['median'] == 30.0
99
- assert stats['min'] == 10
100
- assert stats['max'] == 50
101
-
102
- class TestIntegration:
103
- """Integration tests"""
104
-
105
- def test_world_data_loading(self):
106
- """Test loading world data"""
107
- world = gpd.read_file(NATURAL_EARTH_SHP)
108
- assert not world.empty
109
- assert 'NAME' in world.columns or 'name' in world.columns
110
- assert 'CONTINENT' in world.columns or 'continent' in world.columns
111
- assert 'POP_EST' in world.columns or 'pop_est' in world.columns
112
-
113
- def test_query_to_data_pipeline(self):
114
- """Test complete query to data pipeline"""
115
- # Load data
116
- world = gpd.read_file(NATURAL_EARTH_SHP)
117
-
118
- # Normalize column names to lowercase
119
- world.columns = world.columns.str.lower()
120
-
121
- # Expand query
122
- locations = QueryEnhancer.expand_location('brics')
123
-
124
- # Filter data (try both 'name' and 'admin' columns)
125
- name_col = 'name' if 'name' in world.columns else 'admin'
126
- filtered = world[world[name_col].isin(locations)]
127
-
128
- assert not filtered.empty
129
- assert len(filtered) > 0
130
-
131
- def test_data_enrichment_pipeline(self):
132
- """Test data enrichment pipeline"""
133
- # Load data
134
- world = gpd.read_file(NATURAL_EARTH_SHP)
135
-
136
- # Normalize column names to lowercase
137
- world.columns = world.columns.str.lower()
138
-
139
- # Take sample
140
- sample = world.head(10)
141
-
142
- # Enrich
143
- enriched = DataEnhancer.enrich_dataframe(sample, 'economic')
144
-
145
- assert 'gdp_growth' in enriched.columns
146
- assert 'unemployment' in enriched.columns
147
-
148
- # Sample query test cases
149
- SAMPLE_QUERIES = [
150
- "Show me population of Asian countries",
151
- "Compare GDP of European nations",
152
- "What's the population density in Africa?",
153
- "Display economic indicators for South American countries",
154
- "Show me top 10 countries by GDP",
155
- "Compare BRICS nations",
156
- "Environmental data for G7 countries"
157
- ]
158
-
159
- class TestQueryParsing:
160
- """Test query parsing (mock LLM responses)"""
161
-
162
- def test_query_keywords(self):
163
- """Test that queries contain expected keywords"""
164
- for query in SAMPLE_QUERIES:
165
- assert len(query) > 0
166
- assert any(continent in query.lower() for continent in
167
- ['asian', 'european', 'africa', 'south american', 'brics', 'g7']) or \
168
- any(indicator in query.lower() for indicator in
169
- ['population', 'gdp', 'economic', 'environmental'])
170
-
171
- if __name__ == "__main__":
172
- # Run tests
173
- pytest.main([__file__, '-v'])