Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- client.py +2 -2
- server/wildfire_web_interface.py +45 -1
client.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
# Support both in-repo and standalone imports
|
| 2 |
try:
|
| 3 |
# In-repo imports (when running from OpenEnv repository)
|
| 4 |
-
from core.http_env_client import HTTPEnvClient
|
| 5 |
-
from core.client_types import StepResult
|
| 6 |
from .models import WildfireAction, WildfireObservation, WildfireState
|
| 7 |
except ImportError:
|
| 8 |
# Standalone imports (when environment is standalone with openenv-core from pip)
|
|
|
|
| 1 |
# Support both in-repo and standalone imports
|
| 2 |
try:
|
| 3 |
# In-repo imports (when running from OpenEnv repository)
|
| 4 |
+
from openenv.core.http_env_client import HTTPEnvClient
|
| 5 |
+
from openenv.core.client_types import StepResult
|
| 6 |
from .models import WildfireAction, WildfireObservation, WildfireState
|
| 7 |
except ImportError:
|
| 8 |
# Standalone imports (when environment is standalone with openenv-core from pip)
|
server/wildfire_web_interface.py
CHANGED
|
@@ -12,7 +12,7 @@ from dataclasses import asdict
|
|
| 12 |
# Support both in-repo and standalone imports
|
| 13 |
try:
|
| 14 |
# In-repo imports (when running from OpenEnv repository)
|
| 15 |
-
from core.env_server.types import EnvironmentMetadata
|
| 16 |
from ..models import WildfireAction
|
| 17 |
except ImportError:
|
| 18 |
# Standalone imports (when environment is standalone with openenv-core from pip)
|
|
@@ -720,6 +720,50 @@ def get_wildfire_web_interface_html(metadata: Optional[EnvironmentMetadata] = No
|
|
| 720 |
|
| 721 |
const result = await response.json();
|
| 722 |
console.log('Step result:', result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 723 |
}} catch (error) {{
|
| 724 |
console.error('Error submitting action:', error);
|
| 725 |
alert('Error submitting action: ' + error.message);
|
|
|
|
| 12 |
# Support both in-repo and standalone imports
|
| 13 |
try:
|
| 14 |
# In-repo imports (when running from OpenEnv repository)
|
| 15 |
+
from openenv.core.env_server.types import EnvironmentMetadata
|
| 16 |
from ..models import WildfireAction
|
| 17 |
except ImportError:
|
| 18 |
# Standalone imports (when environment is standalone with openenv-core from pip)
|
|
|
|
| 720 |
|
| 721 |
const result = await response.json();
|
| 722 |
console.log('Step result:', result);
|
| 723 |
+
console.log('Step result observation:', result.observation);
|
| 724 |
+
console.log('Step result observation grid:', result.observation?.grid);
|
| 725 |
+
|
| 726 |
+
// Update UI immediately from the response (don't wait for WebSocket)
|
| 727 |
+
if (result.observation) {{
|
| 728 |
+
const obs = result.observation;
|
| 729 |
+
// Update grid if available - check both direct grid and nested observation structure
|
| 730 |
+
let gridData = obs.grid;
|
| 731 |
+
let gridWidth = obs.width;
|
| 732 |
+
let gridHeight = obs.height;
|
| 733 |
+
|
| 734 |
+
// If grid is missing but we have dimensions, try to get from nested structure
|
| 735 |
+
if ((!gridData || gridData.length === 0) && gridWidth && gridHeight) {{
|
| 736 |
+
console.warn('Grid data is empty in observation, checking nested structure...');
|
| 737 |
+
// The observation might be nested differently - check the full structure
|
| 738 |
+
console.log('Full observation structure:', JSON.stringify(obs, null, 2));
|
| 739 |
+
}}
|
| 740 |
+
|
| 741 |
+
if (gridData && Array.isArray(gridData) && gridData.length > 0 && gridWidth && gridHeight) {{
|
| 742 |
+
console.log('Updating grid from step response:', gridWidth, 'x', gridHeight, 'cells:', gridData.length);
|
| 743 |
+
this.renderGrid(gridData, gridWidth, gridHeight);
|
| 744 |
+
}} else {{
|
| 745 |
+
console.warn('Grid data not available in step response - will rely on WebSocket update');
|
| 746 |
+
}}
|
| 747 |
+
// Update stats
|
| 748 |
+
if (obs.remaining_water !== undefined) {{
|
| 749 |
+
document.getElementById('water-remaining').textContent = obs.remaining_water;
|
| 750 |
+
}}
|
| 751 |
+
if (obs.remaining_breaks !== undefined) {{
|
| 752 |
+
document.getElementById('breaks-remaining').textContent = obs.remaining_breaks;
|
| 753 |
+
}}
|
| 754 |
+
if (obs.burning_count !== undefined) {{
|
| 755 |
+
document.getElementById('burning-count').textContent = obs.burning_count;
|
| 756 |
+
}}
|
| 757 |
+
if (obs.wind_dir) {{
|
| 758 |
+
document.getElementById('wind-dir').textContent = obs.wind_dir;
|
| 759 |
+
}}
|
| 760 |
+
if (obs.humidity !== undefined) {{
|
| 761 |
+
document.getElementById('humidity').textContent = obs.humidity.toFixed(2);
|
| 762 |
+
}}
|
| 763 |
+
if (obs.step !== undefined) {{
|
| 764 |
+
document.getElementById('step-count').textContent = obs.step;
|
| 765 |
+
}}
|
| 766 |
+
}}
|
| 767 |
}} catch (error) {{
|
| 768 |
console.error('Error submitting action:', error);
|
| 769 |
alert('Error submitting action: ' + error.message);
|