Fix session state

#1
by Wauplin HF staff - opened
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -68,7 +68,9 @@ model_info = "N/A"
68
  ### Conversion factors
69
  kg_per_mile = 0.348
70
  embodied_conversion_factor = 0.0289
71
- st.session_state["is_shared"] = False
 
 
72
 
73
  electricity = pd.read_csv(electricity_url)
74
  servers = pd.read_csv(server_url)
@@ -190,7 +192,7 @@ div.stButton > button:first-child {
190
 
191
  buttoncol1, buttoncol2, buttoncol3 = st.columns(3)
192
  with buttoncol2:
193
- if st.session_state["is_shared"] == False:
194
  submitted = st.button(label="Share my CO2 data!", on_click = lambda *args: write_to_csv(hardware, gpu_tdp, num_gpus, training_time, provider, carbon_intensity, dynamic_emissions, experimentation_time, experimental_emissions, pue, pue_emissions, embodied_type, embodied_emissions, model_info))
195
  else:
196
  st.info('Thank you! Your data has been shared in https://huggingface.co/datasets/sasha/co2_submissions.')
 
68
  ### Conversion factors
69
  kg_per_mile = 0.348
70
  embodied_conversion_factor = 0.0289
71
+
72
+ if "is_shared" not in st.session_state:
73
+ st.session_state["is_shared"] = False
74
 
75
  electricity = pd.read_csv(electricity_url)
76
  servers = pd.read_csv(server_url)
 
192
 
193
  buttoncol1, buttoncol2, buttoncol3 = st.columns(3)
194
  with buttoncol2:
195
+ if not st.session_state["is_shared"]:
196
  submitted = st.button(label="Share my CO2 data!", on_click = lambda *args: write_to_csv(hardware, gpu_tdp, num_gpus, training_time, provider, carbon_intensity, dynamic_emissions, experimentation_time, experimental_emissions, pue, pue_emissions, embodied_type, embodied_emissions, model_info))
197
  else:
198
  st.info('Thank you! Your data has been shared in https://huggingface.co/datasets/sasha/co2_submissions.')