Spaces:
Sleeping
Sleeping
Tracy André
commited on
Commit
·
4d340aa
1
Parent(s):
36e01a6
updated
Browse files- MCP_RESOURCES.md +0 -134
- app.py +1 -1
- debug_parcelles.py +0 -38
- quick_test.py +0 -29
- test_analysis.py +0 -109
- test_app_launch.py +0 -28
- test_dual_sliders.py +0 -36
- test_final_app.py +52 -0
- test_gradio.py +0 -45
- test_improved_interface.py +0 -44
- test_mcp_resources.py +0 -47
- test_rangeslider.py +0 -36
MCP_RESOURCES.md
DELETED
|
@@ -1,134 +0,0 @@
|
|
| 1 |
-
# MCP Resources Documentation
|
| 2 |
-
|
| 3 |
-
## Overview
|
| 4 |
-
This MCP server provides agricultural data analysis resources for weed pressure prediction and crop recommendations. The resources are designed to be consumed by LLMs through the Model Context Protocol.
|
| 5 |
-
|
| 6 |
-
## Available Resources
|
| 7 |
-
|
| 8 |
-
### Static Resources
|
| 9 |
-
|
| 10 |
-
#### `agricultural://plots`
|
| 11 |
-
- **Description**: List of all available agricultural plots
|
| 12 |
-
- **Returns**: String with plot names and count
|
| 13 |
-
- **Example**: "Available plots (106): Charbonnerie Entrée, Grand champ 5 (MH), ..."
|
| 14 |
-
|
| 15 |
-
#### `agricultural://crops`
|
| 16 |
-
- **Description**: List of all crop types in the dataset
|
| 17 |
-
- **Returns**: String with crop names and count
|
| 18 |
-
- **Example**: "Available crops (42): blé tendre hiver, pois de conserve, ..."
|
| 19 |
-
|
| 20 |
-
#### `agricultural://years`
|
| 21 |
-
- **Description**: Range of years available in the dataset
|
| 22 |
-
- **Returns**: String with year range and total count
|
| 23 |
-
- **Example**: "Available years: 2014-2025 (12 years total)"
|
| 24 |
-
|
| 25 |
-
#### `agricultural://dataset-info`
|
| 26 |
-
- **Description**: Comprehensive dataset information
|
| 27 |
-
- **Returns**: String with statistics about the agricultural dataset
|
| 28 |
-
- **Includes**: Record counts, plot/crop/intervention counts, herbicide usage stats
|
| 29 |
-
|
| 30 |
-
#### `agricultural://herbicide-usage`
|
| 31 |
-
- **Description**: Summary of herbicide usage patterns
|
| 32 |
-
- **Returns**: String with IFT statistics and risk distribution
|
| 33 |
-
- **Includes**: Total applications, average IFT, risk levels, most used herbicides
|
| 34 |
-
|
| 35 |
-
#### `agricultural://predictions/2025-2027`
|
| 36 |
-
- **Description**: Summary of weed pressure predictions for 2025-2027
|
| 37 |
-
- **Returns**: String with prediction statistics and risk distribution
|
| 38 |
-
- **Includes**: Total predictions, average IFT, risk levels, best plots
|
| 39 |
-
|
| 40 |
-
#### `agricultural://recommendations/sensitive-crops`
|
| 41 |
-
- **Description**: Summary of plot recommendations for sensitive crops
|
| 42 |
-
- **Returns**: String with recommendation statistics and top plots
|
| 43 |
-
- **Includes**: Suitable plots count, average score, top 5 recommendations
|
| 44 |
-
|
| 45 |
-
### Parameterized Resources
|
| 46 |
-
|
| 47 |
-
#### `agricultural://plot/{plot_name}`
|
| 48 |
-
- **Description**: Detailed information about a specific agricultural plot
|
| 49 |
-
- **Parameters**: `plot_name` (string) - Name of the plot
|
| 50 |
-
- **Returns**: String with plot statistics and characteristics
|
| 51 |
-
- **Includes**: Interventions count, years active, herbicide usage, surface, main crops
|
| 52 |
-
|
| 53 |
-
#### `agricultural://crop/{crop_type}`
|
| 54 |
-
- **Description**: Information about a specific crop type
|
| 55 |
-
- **Parameters**: `crop_type` (string) - Name of the crop
|
| 56 |
-
- **Returns**: String with crop cultivation patterns
|
| 57 |
-
- **Includes**: Total interventions, years cultivated, plots count, herbicide usage
|
| 58 |
-
|
| 59 |
-
#### `agricultural://year/{year}`
|
| 60 |
-
- **Description**: Summary of agricultural activities for a specific year
|
| 61 |
-
- **Parameters**: `year` (int) - Year to analyze
|
| 62 |
-
- **Returns**: String with year statistics
|
| 63 |
-
- **Includes**: Total interventions, active plots, crop types, most active plot/crop
|
| 64 |
-
|
| 65 |
-
#### `agricultural://plot/{plot_name}/predictions`
|
| 66 |
-
- **Description**: Weed pressure predictions for a specific plot
|
| 67 |
-
- **Parameters**: `plot_name` (string) - Name of the plot
|
| 68 |
-
- **Returns**: String with predictions for 2025-2027
|
| 69 |
-
- **Includes**: IFT predictions by year, risk levels, historical average, recent crops
|
| 70 |
-
|
| 71 |
-
## Usage Examples
|
| 72 |
-
|
| 73 |
-
### For LLMs
|
| 74 |
-
```python
|
| 75 |
-
# Get dataset overview
|
| 76 |
-
dataset_info = get_dataset_info()
|
| 77 |
-
|
| 78 |
-
# Get specific plot information
|
| 79 |
-
plot_info = get_plot_info("Champ ferme W du sol")
|
| 80 |
-
|
| 81 |
-
# Get crop cultivation patterns
|
| 82 |
-
crop_info = get_crop_info("blé tendre hiver")
|
| 83 |
-
|
| 84 |
-
# Get year summary
|
| 85 |
-
year_summary = get_year_summary(2023)
|
| 86 |
-
|
| 87 |
-
# Get herbicide usage patterns
|
| 88 |
-
herbicide_usage = get_herbicide_usage_summary()
|
| 89 |
-
|
| 90 |
-
# Get predictions summary
|
| 91 |
-
predictions = get_predictions_summary()
|
| 92 |
-
|
| 93 |
-
# Get recommendations for sensitive crops
|
| 94 |
-
recommendations = get_recommendations_summary()
|
| 95 |
-
|
| 96 |
-
# Get specific plot predictions
|
| 97 |
-
plot_predictions = get_plot_predictions("Etang 5")
|
| 98 |
-
```
|
| 99 |
-
|
| 100 |
-
## Activation Instructions
|
| 101 |
-
|
| 102 |
-
**Current Status**: MCP resource decorators are commented out due to compatibility issues with the current Gradio version on Hugging Face Spaces.
|
| 103 |
-
|
| 104 |
-
To activate MCP resources when supported, uncomment the `@gr.mcp.resource` decorators in `mcp_server.py`:
|
| 105 |
-
|
| 106 |
-
```python
|
| 107 |
-
# Change from:
|
| 108 |
-
# @gr.mcp.resource("agricultural://plots")
|
| 109 |
-
def get_available_plots_resource() -> str:
|
| 110 |
-
|
| 111 |
-
# To:
|
| 112 |
-
@gr.mcp.resource("agricultural://plots")
|
| 113 |
-
def get_available_plots_resource() -> str:
|
| 114 |
-
```
|
| 115 |
-
|
| 116 |
-
**Note**: The resource functions are fully functional and can be called directly. Only the MCP protocol exposure is currently disabled.
|
| 117 |
-
|
| 118 |
-
## Data Sources
|
| 119 |
-
|
| 120 |
-
- **Station**: Station Expérimentale de Kerguéhennec
|
| 121 |
-
- **Period**: 2014-2025
|
| 122 |
-
- **Records**: 5,756 agricultural interventions
|
| 123 |
-
- **Plots**: 106 agricultural plots
|
| 124 |
-
- **Crops**: 42 different crop types
|
| 125 |
-
- **Herbicide Applications**: 985 applications
|
| 126 |
-
|
| 127 |
-
## Key Metrics
|
| 128 |
-
|
| 129 |
-
- **IFT (Indice de Fréquence de Traitement)**: Number of herbicide applications per hectare
|
| 130 |
-
- **Risk Levels**:
|
| 131 |
-
- Low (IFT < 1.0): Suitable for sensitive crops
|
| 132 |
-
- Moderate (1.0 ≤ IFT < 2.0): Requires monitoring
|
| 133 |
-
- High (IFT ≥ 2.0): Not recommended for sensitive crops
|
| 134 |
-
- **Recommendation Score**: 100 - (predicted_ift × 30)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -10,4 +10,4 @@ os.environ.setdefault("HF_TOKEN", os.environ.get("HF_TOKEN"))
|
|
| 10 |
os.environ.setdefault("DATASET_ID", "HackathonCRA/2024")
|
| 11 |
|
| 12 |
demo = create_mcp_interface()
|
| 13 |
-
demo.launch(mcp_server=True
|
|
|
|
| 10 |
os.environ.setdefault("DATASET_ID", "HackathonCRA/2024")
|
| 11 |
|
| 12 |
demo = create_mcp_interface()
|
| 13 |
+
demo.launch(mcp_server=True)
|
debug_parcelles.py
DELETED
|
@@ -1,38 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Debug des noms de parcelles
|
| 3 |
-
"""
|
| 4 |
-
|
| 5 |
-
from data_loader import AgriculturalDataLoader
|
| 6 |
-
|
| 7 |
-
def debug_plot_names():
|
| 8 |
-
loader = AgriculturalDataLoader()
|
| 9 |
-
df = loader.load_all_files()
|
| 10 |
-
|
| 11 |
-
print("🔍 Analyse des noms de parcelles...")
|
| 12 |
-
|
| 13 |
-
# Toutes les parcelles uniques
|
| 14 |
-
all_plots = df['plot_name'].unique()
|
| 15 |
-
print(f"Nombre total de parcelles: {len(all_plots)}")
|
| 16 |
-
|
| 17 |
-
# Chercher des variations de "Champ ferme Bas"
|
| 18 |
-
champ_ferme_variants = [p for p in all_plots if 'champ' in p.lower() and 'ferme' in p.lower()]
|
| 19 |
-
print(f"\nVariantes de 'Champ ferme':")
|
| 20 |
-
for variant in sorted(champ_ferme_variants):
|
| 21 |
-
count = len(df[df['plot_name'] == variant])
|
| 22 |
-
print(f" '{variant}': {count} interventions")
|
| 23 |
-
|
| 24 |
-
# Parcelles les plus fréquentes
|
| 25 |
-
plot_counts = df['plot_name'].value_counts().head(10)
|
| 26 |
-
print(f"\nTop 10 des parcelles par nombre d'interventions:")
|
| 27 |
-
for plot, count in plot_counts.items():
|
| 28 |
-
print(f" '{plot}': {count} interventions")
|
| 29 |
-
|
| 30 |
-
# Vérifier les herbicides par parcelle
|
| 31 |
-
herbicide_df = df[df['is_herbicide'] == True]
|
| 32 |
-
herbicide_plots = herbicide_df['plot_name'].value_counts().head(10)
|
| 33 |
-
print(f"\nTop 10 des parcelles avec herbicides:")
|
| 34 |
-
for plot, count in herbicide_plots.items():
|
| 35 |
-
print(f" '{plot}': {count} applications herbicides")
|
| 36 |
-
|
| 37 |
-
if __name__ == "__main__":
|
| 38 |
-
debug_plot_names()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
quick_test.py
DELETED
|
@@ -1,29 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Test rapide de l'interface complète
|
| 3 |
-
"""
|
| 4 |
-
|
| 5 |
-
import gradio as gr
|
| 6 |
-
from mcp_server import create_mcp_interface
|
| 7 |
-
|
| 8 |
-
if __name__ == "__main__":
|
| 9 |
-
print("🚀 Test de l'interface Gradio complète...")
|
| 10 |
-
|
| 11 |
-
try:
|
| 12 |
-
demo = create_mcp_interface()
|
| 13 |
-
print("✅ Interface créée avec succès")
|
| 14 |
-
|
| 15 |
-
# Test de lancement (sans vraiment lancer)
|
| 16 |
-
print("✅ Interface prête pour le déploiement")
|
| 17 |
-
|
| 18 |
-
# Test d'une fonction
|
| 19 |
-
from mcp_server import analyze_herbicide_trends
|
| 20 |
-
fig, summary = analyze_herbicide_trends([2022, 2024], "Toutes")
|
| 21 |
-
if fig is not None:
|
| 22 |
-
print("✅ Fonction d'analyse fonctionnelle")
|
| 23 |
-
else:
|
| 24 |
-
print("❌ Problème avec l'analyse")
|
| 25 |
-
|
| 26 |
-
except Exception as e:
|
| 27 |
-
print(f"❌ Erreur: {e}")
|
| 28 |
-
import traceback
|
| 29 |
-
traceback.print_exc()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_analysis.py
DELETED
|
@@ -1,109 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Script de test pour diagnostiquer les problèmes d'analyse des tendances
|
| 3 |
-
"""
|
| 4 |
-
|
| 5 |
-
import pandas as pd
|
| 6 |
-
import numpy as np
|
| 7 |
-
from data_loader import AgriculturalDataLoader
|
| 8 |
-
|
| 9 |
-
def test_data_loading():
|
| 10 |
-
"""Test du chargement des données"""
|
| 11 |
-
print("🔍 Test du chargement des données...")
|
| 12 |
-
|
| 13 |
-
try:
|
| 14 |
-
loader = AgriculturalDataLoader()
|
| 15 |
-
df = loader.load_all_files()
|
| 16 |
-
|
| 17 |
-
print(f"✅ Données chargées: {len(df)} lignes")
|
| 18 |
-
print(f"📋 Colonnes disponibles: {list(df.columns)}")
|
| 19 |
-
print(f"📊 Types de données:")
|
| 20 |
-
print(df.dtypes)
|
| 21 |
-
|
| 22 |
-
return df
|
| 23 |
-
except Exception as e:
|
| 24 |
-
print(f"❌ Erreur lors du chargement: {e}")
|
| 25 |
-
return None
|
| 26 |
-
|
| 27 |
-
def test_herbicide_analysis(df):
|
| 28 |
-
"""Test de l'analyse des herbicides"""
|
| 29 |
-
print("\n🧪 Test de l'analyse des herbicides...")
|
| 30 |
-
|
| 31 |
-
if df is None:
|
| 32 |
-
return
|
| 33 |
-
|
| 34 |
-
# Vérifier les colonnes nécessaires
|
| 35 |
-
required_cols = ['is_herbicide', 'plot_name', 'year', 'crop_type', 'produit', 'plot_surface']
|
| 36 |
-
missing_cols = [col for col in required_cols if col not in df.columns]
|
| 37 |
-
|
| 38 |
-
if missing_cols:
|
| 39 |
-
print(f"❌ Colonnes manquantes: {missing_cols}")
|
| 40 |
-
return
|
| 41 |
-
|
| 42 |
-
# Filtrer les herbicides
|
| 43 |
-
herbicide_df = df[df['is_herbicide'] == True].copy()
|
| 44 |
-
print(f"📊 Nombre d'applications herbicides: {len(herbicide_df)}")
|
| 45 |
-
|
| 46 |
-
if len(herbicide_df) == 0:
|
| 47 |
-
print("❌ Aucune donnée d'herbicides trouvée")
|
| 48 |
-
print("🔍 Vérification des valeurs 'is_herbicide':")
|
| 49 |
-
print(df['is_herbicide'].value_counts())
|
| 50 |
-
|
| 51 |
-
print("🔍 Vérification des familles de produits:")
|
| 52 |
-
if 'familleprod' in df.columns:
|
| 53 |
-
print(df['familleprod'].value_counts())
|
| 54 |
-
|
| 55 |
-
return
|
| 56 |
-
|
| 57 |
-
print(f"✅ Données herbicides trouvées: {len(herbicide_df)} applications")
|
| 58 |
-
|
| 59 |
-
# Test du calcul IFT
|
| 60 |
-
print("\n📈 Test du calcul IFT...")
|
| 61 |
-
|
| 62 |
-
try:
|
| 63 |
-
ift_summary = herbicide_df.groupby(['plot_name', 'year', 'crop_type']).agg({
|
| 64 |
-
'produit': 'count',
|
| 65 |
-
'plot_surface': 'first',
|
| 66 |
-
'quantitetot': 'sum'
|
| 67 |
-
}).reset_index()
|
| 68 |
-
|
| 69 |
-
ift_summary['ift_herbicide'] = ift_summary['produit'] / ift_summary['plot_surface']
|
| 70 |
-
|
| 71 |
-
print(f"✅ IFT calculé pour {len(ift_summary)} combinaisons parcelle/année/culture")
|
| 72 |
-
print(f"📊 IFT moyen: {ift_summary['ift_herbicide'].mean():.2f}")
|
| 73 |
-
print(f"📊 IFT max: {ift_summary['ift_herbicide'].max():.2f}")
|
| 74 |
-
|
| 75 |
-
print("\n📋 Échantillon des données IFT:")
|
| 76 |
-
print(ift_summary.head())
|
| 77 |
-
|
| 78 |
-
return ift_summary
|
| 79 |
-
|
| 80 |
-
except Exception as e:
|
| 81 |
-
print(f"❌ Erreur dans le calcul IFT: {e}")
|
| 82 |
-
return None
|
| 83 |
-
|
| 84 |
-
def test_years_and_plots(df):
|
| 85 |
-
"""Test des années et parcelles disponibles"""
|
| 86 |
-
print("\n📅 Test des années et parcelles...")
|
| 87 |
-
|
| 88 |
-
if df is None:
|
| 89 |
-
return
|
| 90 |
-
|
| 91 |
-
years = sorted(df['year'].dropna().unique())
|
| 92 |
-
plots = sorted(df['plot_name'].dropna().unique())
|
| 93 |
-
|
| 94 |
-
print(f"📅 Années disponibles: {years}")
|
| 95 |
-
print(f"🏞️ Parcelles disponibles: {plots}")
|
| 96 |
-
|
| 97 |
-
# Test par année
|
| 98 |
-
print("\n📊 Données par année:")
|
| 99 |
-
year_counts = df.groupby('year').size()
|
| 100 |
-
print(year_counts)
|
| 101 |
-
|
| 102 |
-
if __name__ == "__main__":
|
| 103 |
-
print("🚜 Test de l'analyse des tendances herbicides\n")
|
| 104 |
-
|
| 105 |
-
df = test_data_loading()
|
| 106 |
-
test_herbicide_analysis(df)
|
| 107 |
-
test_years_and_plots(df)
|
| 108 |
-
|
| 109 |
-
print("\n✅ Tests terminés")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_app_launch.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Test de lancement de l'application
|
| 3 |
-
"""
|
| 4 |
-
|
| 5 |
-
from mcp_server import create_mcp_interface
|
| 6 |
-
|
| 7 |
-
def test_app_creation():
|
| 8 |
-
"""Test de création de l'interface sans lancement"""
|
| 9 |
-
print("🧪 Test de création de l'interface...")
|
| 10 |
-
|
| 11 |
-
try:
|
| 12 |
-
demo = create_mcp_interface()
|
| 13 |
-
print("✅ Interface créée avec succès")
|
| 14 |
-
print("✅ Tous les onglets sont fonctionnels")
|
| 15 |
-
print("✅ Resources MCP disponibles (décorateurs commentés)")
|
| 16 |
-
return True
|
| 17 |
-
except Exception as e:
|
| 18 |
-
print(f"❌ Erreur lors de la création: {e}")
|
| 19 |
-
import traceback
|
| 20 |
-
traceback.print_exc()
|
| 21 |
-
return False
|
| 22 |
-
|
| 23 |
-
if __name__ == "__main__":
|
| 24 |
-
success = test_app_creation()
|
| 25 |
-
if success:
|
| 26 |
-
print("\n🎯 Application prête pour le déploiement !")
|
| 27 |
-
else:
|
| 28 |
-
print("\n❌ Problème détecté")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_dual_sliders.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Test des deux sliders séparés
|
| 3 |
-
"""
|
| 4 |
-
|
| 5 |
-
from mcp_server import analyze_herbicide_trends
|
| 6 |
-
|
| 7 |
-
def test_dual_sliders():
|
| 8 |
-
"""Test avec deux sliders séparés"""
|
| 9 |
-
print("🧪 Test des deux sliders séparés...")
|
| 10 |
-
|
| 11 |
-
# Test 1: Période normale
|
| 12 |
-
print("\nTest 1: 2020-2024, toutes parcelles")
|
| 13 |
-
fig, summary = analyze_herbicide_trends(2020, 2024, "Toutes")
|
| 14 |
-
if fig is not None:
|
| 15 |
-
print("✅ Succès avec période normale")
|
| 16 |
-
else:
|
| 17 |
-
print("❌ Erreur:", summary)
|
| 18 |
-
|
| 19 |
-
# Test 2: Année unique
|
| 20 |
-
print("\nTest 2: 2023-2023, toutes parcelles")
|
| 21 |
-
fig, summary = analyze_herbicide_trends(2023, 2023, "Toutes")
|
| 22 |
-
if fig is not None:
|
| 23 |
-
print("✅ Succès avec année unique")
|
| 24 |
-
else:
|
| 25 |
-
print("❌ Erreur:", summary)
|
| 26 |
-
|
| 27 |
-
# Test 3: Ordre inversé (doit être corrigé automatiquement)
|
| 28 |
-
print("\nTest 3: 2024-2020 (ordre inversé)")
|
| 29 |
-
fig, summary = analyze_herbicide_trends(2024, 2020, "Toutes")
|
| 30 |
-
if fig is not None:
|
| 31 |
-
print("✅ Succès avec ordre inversé corrigé")
|
| 32 |
-
else:
|
| 33 |
-
print("❌ Erreur:", summary)
|
| 34 |
-
|
| 35 |
-
if __name__ == "__main__":
|
| 36 |
-
test_dual_sliders()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_final_app.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Test final de l'application sans mcp_server
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from mcp_server import create_mcp_interface
|
| 6 |
+
|
| 7 |
+
def test_final_app():
|
| 8 |
+
"""Test final de l'application"""
|
| 9 |
+
print("🧪 Test final de l'application...")
|
| 10 |
+
|
| 11 |
+
try:
|
| 12 |
+
demo = create_mcp_interface()
|
| 13 |
+
print("✅ Interface créée avec succès")
|
| 14 |
+
|
| 15 |
+
# Test des fonctions principales
|
| 16 |
+
from mcp_server import analyze_herbicide_trends, predict_future_weed_pressure, recommend_sensitive_crop_plots, explore_raw_data
|
| 17 |
+
|
| 18 |
+
# Test rapide des fonctions
|
| 19 |
+
print("📈 Test analyse tendances...")
|
| 20 |
+
fig, summary = analyze_herbicide_trends(2020, 2024, "Toutes")
|
| 21 |
+
if fig is not None:
|
| 22 |
+
print("✅ Analyse tendances OK")
|
| 23 |
+
|
| 24 |
+
print("🔮 Test prédictions...")
|
| 25 |
+
fig, summary = predict_future_weed_pressure()
|
| 26 |
+
if fig is not None:
|
| 27 |
+
print("✅ Prédictions OK")
|
| 28 |
+
|
| 29 |
+
print("🌱 Test recommandations...")
|
| 30 |
+
fig, summary = recommend_sensitive_crop_plots()
|
| 31 |
+
if fig is not None:
|
| 32 |
+
print("✅ Recommandations OK")
|
| 33 |
+
|
| 34 |
+
print("📊 Test exploration données...")
|
| 35 |
+
fig, summary = explore_raw_data(2020, 2024, "Toutes", "Toutes", "Toutes")
|
| 36 |
+
if fig is not None:
|
| 37 |
+
print("✅ Exploration données OK")
|
| 38 |
+
|
| 39 |
+
print("\n🎯 Application prête pour le déploiement !")
|
| 40 |
+
print("📋 Toutes les fonctionnalités sont opérationnelles")
|
| 41 |
+
print("🔧 Resources MCP disponibles en tant que fonctions Python")
|
| 42 |
+
|
| 43 |
+
return True
|
| 44 |
+
|
| 45 |
+
except Exception as e:
|
| 46 |
+
print(f"❌ Erreur: {e}")
|
| 47 |
+
import traceback
|
| 48 |
+
traceback.print_exc()
|
| 49 |
+
return False
|
| 50 |
+
|
| 51 |
+
if __name__ == "__main__":
|
| 52 |
+
test_final_app()
|
test_gradio.py
DELETED
|
@@ -1,45 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Script de test pour l'interface Gradio
|
| 3 |
-
"""
|
| 4 |
-
|
| 5 |
-
from mcp_server import analyze_herbicide_trends, get_available_plots
|
| 6 |
-
|
| 7 |
-
def test_function_calls():
|
| 8 |
-
"""Test des fonctions individuelles"""
|
| 9 |
-
print("🧪 Test des fonctions...")
|
| 10 |
-
|
| 11 |
-
# Test get_available_plots
|
| 12 |
-
print("\n📋 Test get_available_plots():")
|
| 13 |
-
plots = get_available_plots()
|
| 14 |
-
print(f"Parcelles disponibles: {len(plots)} - {plots[:5]}...")
|
| 15 |
-
|
| 16 |
-
# Test analyze_herbicide_trends avec différents paramètres
|
| 17 |
-
print("\n📈 Test analyze_herbicide_trends():")
|
| 18 |
-
|
| 19 |
-
# Test 1: Période normale
|
| 20 |
-
print("Test 1: Période 2020-2024, toutes parcelles")
|
| 21 |
-
fig, summary = analyze_herbicide_trends([2020, 2024], "Toutes")
|
| 22 |
-
if fig is not None:
|
| 23 |
-
print("✅ Graphique généré avec succès")
|
| 24 |
-
print("📊 Résumé:", summary[:200] + "...")
|
| 25 |
-
else:
|
| 26 |
-
print("❌ Erreur:", summary)
|
| 27 |
-
|
| 28 |
-
# Test 2: Parcelle spécifique
|
| 29 |
-
print("\nTest 2: Période 2020-2024, parcelle spécifique")
|
| 30 |
-
fig, summary = analyze_herbicide_trends([2020, 2024], "Champ ferme W du sol")
|
| 31 |
-
if fig is not None:
|
| 32 |
-
print("✅ Graphique généré avec succès")
|
| 33 |
-
else:
|
| 34 |
-
print("❌ Erreur:", summary)
|
| 35 |
-
|
| 36 |
-
# Test 3: Format année simple
|
| 37 |
-
print("\nTest 3: Année simple")
|
| 38 |
-
fig, summary = analyze_herbicide_trends(2023, "Toutes")
|
| 39 |
-
if fig is not None:
|
| 40 |
-
print("✅ Graphique généré avec succès")
|
| 41 |
-
else:
|
| 42 |
-
print("❌ Erreur:", summary)
|
| 43 |
-
|
| 44 |
-
if __name__ == "__main__":
|
| 45 |
-
test_function_calls()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_improved_interface.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Test de l'interface améliorée
|
| 3 |
-
"""
|
| 4 |
-
|
| 5 |
-
from mcp_server import analyze_herbicide_trends, predict_future_weed_pressure, recommend_sensitive_crop_plots, explore_raw_data
|
| 6 |
-
|
| 7 |
-
def test_improved_functions():
|
| 8 |
-
"""Test des fonctions améliorées"""
|
| 9 |
-
print("🧪 Test de l'interface améliorée...")
|
| 10 |
-
|
| 11 |
-
# Test 1: Analyse tendances
|
| 12 |
-
print("\nTest 1: Analyse tendances")
|
| 13 |
-
fig, summary = analyze_herbicide_trends(2020, 2024, "Toutes")
|
| 14 |
-
if fig is not None:
|
| 15 |
-
print("✅ Analyse tendances fonctionne")
|
| 16 |
-
else:
|
| 17 |
-
print("❌ Erreur:", summary)
|
| 18 |
-
|
| 19 |
-
# Test 2: Prédictions
|
| 20 |
-
print("\nTest 2: Prédictions")
|
| 21 |
-
fig, summary = predict_future_weed_pressure()
|
| 22 |
-
if fig is not None:
|
| 23 |
-
print("✅ Prédictions fonctionnent")
|
| 24 |
-
else:
|
| 25 |
-
print("❌ Erreur:", summary)
|
| 26 |
-
|
| 27 |
-
# Test 3: Recommandations
|
| 28 |
-
print("\nTest 3: Recommandations")
|
| 29 |
-
fig, summary = recommend_sensitive_crop_plots()
|
| 30 |
-
if fig is not None:
|
| 31 |
-
print("✅ Recommandations fonctionnent")
|
| 32 |
-
else:
|
| 33 |
-
print("❌ Erreur:", summary)
|
| 34 |
-
|
| 35 |
-
# Test 4: Exploration données
|
| 36 |
-
print("\nTest 4: Exploration données")
|
| 37 |
-
fig, summary = explore_raw_data(2020, 2024, "Toutes", "Toutes", "Toutes")
|
| 38 |
-
if fig is not None:
|
| 39 |
-
print("✅ Exploration données fonctionne")
|
| 40 |
-
else:
|
| 41 |
-
print("❌ Erreur:", summary)
|
| 42 |
-
|
| 43 |
-
if __name__ == "__main__":
|
| 44 |
-
test_improved_functions()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_mcp_resources.py
DELETED
|
@@ -1,47 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Test des resources MCP
|
| 3 |
-
"""
|
| 4 |
-
|
| 5 |
-
from mcp_server import (
|
| 6 |
-
get_available_plots_resource,
|
| 7 |
-
get_available_crops_resource,
|
| 8 |
-
get_available_years_resource,
|
| 9 |
-
get_dataset_info,
|
| 10 |
-
get_plot_info,
|
| 11 |
-
get_crop_info,
|
| 12 |
-
get_year_summary,
|
| 13 |
-
get_herbicide_usage_summary,
|
| 14 |
-
get_predictions_summary,
|
| 15 |
-
get_recommendations_summary,
|
| 16 |
-
get_plot_predictions
|
| 17 |
-
)
|
| 18 |
-
|
| 19 |
-
def test_mcp_resources():
|
| 20 |
-
"""Test des resources MCP"""
|
| 21 |
-
print("🧪 Test des resources MCP...")
|
| 22 |
-
|
| 23 |
-
# Test resources statiques
|
| 24 |
-
print("\n📋 Test resources statiques:")
|
| 25 |
-
print("Plots:", get_available_plots_resource())
|
| 26 |
-
print("Crops:", get_available_crops_resource())
|
| 27 |
-
print("Years:", get_available_years_resource())
|
| 28 |
-
print("Dataset info:", get_dataset_info()[:200] + "...")
|
| 29 |
-
|
| 30 |
-
# Test resources avec paramètres
|
| 31 |
-
print("\n🏞️ Test resources avec paramètres:")
|
| 32 |
-
print("Plot info:", get_plot_info("Champ ferme W du sol")[:200] + "...")
|
| 33 |
-
print("Crop info:", get_crop_info("blé tendre hiver")[:200] + "...")
|
| 34 |
-
print("Year summary:", get_year_summary(2023)[:200] + "...")
|
| 35 |
-
|
| 36 |
-
# Test resources d'analyse
|
| 37 |
-
print("\n📊 Test resources d'analyse:")
|
| 38 |
-
print("Herbicide usage:", get_herbicide_usage_summary()[:200] + "...")
|
| 39 |
-
print("Predictions:", get_predictions_summary()[:200] + "...")
|
| 40 |
-
print("Recommendations:", get_recommendations_summary()[:200] + "...")
|
| 41 |
-
|
| 42 |
-
# Test resource prédictions par parcelle
|
| 43 |
-
print("\n🔮 Test prédictions par parcelle:")
|
| 44 |
-
print("Plot predictions:", get_plot_predictions("Champ ferme W du sol")[:200] + "...")
|
| 45 |
-
|
| 46 |
-
if __name__ == "__main__":
|
| 47 |
-
test_mcp_resources()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_rangeslider.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Test du RangeSlider corrigé
|
| 3 |
-
"""
|
| 4 |
-
|
| 5 |
-
from mcp_server import analyze_herbicide_trends
|
| 6 |
-
|
| 7 |
-
def test_rangeslider():
|
| 8 |
-
"""Test avec différents formats de RangeSlider"""
|
| 9 |
-
print("🧪 Test du RangeSlider corrigé...")
|
| 10 |
-
|
| 11 |
-
# Test 1: Format RangeSlider normal
|
| 12 |
-
print("\nTest 1: RangeSlider [2020, 2024]")
|
| 13 |
-
fig, summary = analyze_herbicide_trends([2020, 2024], "Toutes")
|
| 14 |
-
if fig is not None:
|
| 15 |
-
print("✅ Succès avec RangeSlider")
|
| 16 |
-
else:
|
| 17 |
-
print("❌ Erreur:", summary)
|
| 18 |
-
|
| 19 |
-
# Test 2: Format RangeSlider avec une seule année
|
| 20 |
-
print("\nTest 2: RangeSlider [2023, 2023]")
|
| 21 |
-
fig, summary = analyze_herbicide_trends([2023, 2023], "Toutes")
|
| 22 |
-
if fig is not None:
|
| 23 |
-
print("✅ Succès avec une seule année")
|
| 24 |
-
else:
|
| 25 |
-
print("❌ Erreur:", summary)
|
| 26 |
-
|
| 27 |
-
# Test 3: Format RangeSlider avec parcelle spécifique
|
| 28 |
-
print("\nTest 3: RangeSlider [2022, 2024] avec parcelle")
|
| 29 |
-
fig, summary = analyze_herbicide_trends([2022, 2024], "Champ ferme W du sol")
|
| 30 |
-
if fig is not None:
|
| 31 |
-
print("✅ Succès avec parcelle spécifique")
|
| 32 |
-
else:
|
| 33 |
-
print("❌ Erreur:", summary)
|
| 34 |
-
|
| 35 |
-
if __name__ == "__main__":
|
| 36 |
-
test_rangeslider()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|