mabuseif commited on
Commit
832797a
·
verified ·
1 Parent(s): 34b5369

Update app/main.py

Browse files
Files changed (1) hide show
  1. app/main.py +25 -2
app/main.py CHANGED
@@ -83,6 +83,11 @@ class HVACCalculator:
83
  self.heating_calculator = HeatingLoadCalculator()
84
  self.reference_data = ReferenceData()
85
 
 
 
 
 
 
86
  # Initialize climate data
87
  self._initialize_climate_data()
88
 
@@ -163,9 +168,27 @@ class HVACCalculator:
163
  "Building Components": self.component_selection.display_component_selection,
164
  "Internal Loads": self.display_internal_loads,
165
  "Calculation Results": self.display_calculation_results,
166
- "Export Data": self.data_export.display
167
  }
168
- page_functions[page](st.session_state)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
  def generate_climate_id(self, country: str, city: str) -> str:
171
  """Generate a climate ID from country and city names."""
 
83
  self.heating_calculator = HeatingLoadCalculator()
84
  self.reference_data = ReferenceData()
85
 
86
+ # Validate DataExport has display method
87
+ if not hasattr(self.data_export, 'display'):
88
+ logger.error("DataExport object missing 'display' method")
89
+ raise AttributeError("DataExport object missing 'display' method")
90
+
91
  # Initialize climate data
92
  self._initialize_climate_data()
93
 
 
168
  "Building Components": self.component_selection.display_component_selection,
169
  "Internal Loads": self.display_internal_loads,
170
  "Calculation Results": self.display_calculation_results,
171
+ "Export Data": lambda state: self._display_export_data(state)
172
  }
173
+ try:
174
+ page_functions[page](st.session_state)
175
+ except AttributeError as e:
176
+ logger.error(f"Error displaying page {page}: {str(e)}")
177
+ st.error(f"Error displaying {page} page: {str(e)}")
178
+ except Exception as e:
179
+ logger.error(f"Unexpected error displaying page {page}: {str(e)}")
180
+ st.error(f"Unexpected error displaying {page} page: {str(e)}")
181
+
182
+ def _display_export_data(self, state):
183
+ """Wrapper for DataExport.display with error handling."""
184
+ try:
185
+ self.data_export.display(state)
186
+ except AttributeError as e:
187
+ logger.error(f"DataExport.display failed: {str(e)}")
188
+ st.error("Export Data functionality is unavailable. Please check DataExport implementation.")
189
+ st.write("Placeholder for Export Data page. Select export options below:")
190
+ st.button("Export to CSV (Not Implemented)")
191
+ st.button("Export to JSON (Not Implemented)")
192
 
193
  def generate_climate_id(self, country: str, city: str) -> str:
194
  """Generate a climate ID from country and city names."""