loodvanniekerkginkgo commited on
Commit
393870b
·
1 Parent(s): c4f1261

Changed state to track a hash

Browse files
Files changed (2) hide show
  1. app.py +7 -4
  2. submit.py +0 -1
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import pandas as pd
2
  import gradio as gr
3
  from gradio.themes.utils import sizes
@@ -77,12 +78,14 @@ with gr.Blocks(theme=gr.themes.Default(text_size=sizes.text_lg)) as demo:
77
  def update_current_dataframe():
78
  global current_dataframe
79
  new_dataframe = fetch_hf_results()
 
80
 
81
  # Check if data has actually changed
82
- if not current_dataframe.equals(new_dataframe):
83
- print(f"TMP Dataframe has changed at {get_time()}. New value will be {data_version.value + 1}")
84
  current_dataframe = new_dataframe
85
- return data_version.value + 1 # Increment version to trigger updates
 
86
  return data_version.value
87
 
88
  timer.tick(fn=update_current_dataframe, outputs=data_version)
@@ -288,4 +291,4 @@ with gr.Blocks(theme=gr.themes.Default(text_size=sizes.text_lg)) as demo:
288
  )
289
 
290
  if __name__ == "__main__":
291
- demo.launch(ssr_mode=False, share=True)
 
1
+ import hashlib
2
  import pandas as pd
3
  import gradio as gr
4
  from gradio.themes.utils import sizes
 
78
  def update_current_dataframe():
79
  global current_dataframe
80
  new_dataframe = fetch_hf_results()
81
+ new_hash = hashlib.sha256(pd.util.hash_pandas_object(new_dataframe).values).hexdigest()
82
 
83
  # Check if data has actually changed
84
+ if new_hash != data_version.value:
85
+ print(f"TMP Dataframe has changed at {get_time()}. Old hash: {str(data_version.value)[:8]}, new hash: {str(new_hash)[:8]}")
86
  current_dataframe = new_dataframe
87
+ data_version.value = new_hash # Increment version to trigger updates
88
+ return new_hash
89
  return data_version.value
90
 
91
  timer.tick(fn=update_current_dataframe, outputs=data_version)
 
291
  )
292
 
293
  if __name__ == "__main__":
294
+ demo.launch(ssr_mode=False)
submit.py CHANGED
@@ -81,7 +81,6 @@ def make_submission(
81
  raise gr.Error("Please provide a model name.")
82
  if not model_description:
83
  model_description = ""
84
- # raise gr.Error("Please provide a model description.") # Not mandatory anymore
85
  if str(registration_code).strip().upper() != REGISTRATION_CODE:
86
  raise gr.Error(
87
  "Invalid registration code. Please register on the <a href='https://datapoints.ginkgo.bio/ai-competitions/2025-abdev-competition'>Competition Registration page</a> or email <a href='mailto:[email protected]'>[email protected]</a>."
 
81
  raise gr.Error("Please provide a model name.")
82
  if not model_description:
83
  model_description = ""
 
84
  if str(registration_code).strip().upper() != REGISTRATION_CODE:
85
  raise gr.Error(
86
  "Invalid registration code. Please register on the <a href='https://datapoints.ginkgo.bio/ai-competitions/2025-abdev-competition'>Competition Registration page</a> or email <a href='mailto:[email protected]'>[email protected]</a>."