rmm commited on
Commit
d0c3bfa
·
1 Parent(s): 94698a8

fix: retired use of tab_log in session state

Browse files

st_logs provide the logging functionality, and the current method
for the few places used was not persistent to tab-switches.

Files changed (2) hide show
  1. src/hf_push_observations.py +4 -6
  2. src/main.py +1 -11
src/hf_push_observations.py CHANGED
@@ -30,9 +30,7 @@ def push_observation(image_hash:str, api:HfApi, enable_push:False) -> CommitInfo
30
  metadata_str = json.dumps(observation) # doesn't work yet, TODO
31
 
32
  st.toast(f"Uploading observation: {metadata_str}", icon="🦭")
33
- tab_log = st.session_state.tab_log
34
- if tab_log is not None:
35
- tab_log.info(f"Uploading observation: {metadata_str}")
36
 
37
  # write to temp file so we can send it (why is this not using context mgr?)
38
  f = tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False)
@@ -89,14 +87,14 @@ def push_observations(tab_log:DeltaGenerator=None):
89
  push any observation since generating the logger)
90
 
91
  """
 
 
92
  # we get the observation from session state: 1 is the dict 2 is the image.
93
  # first, lets do an info display (popup)
94
  metadata_str = json.dumps(st.session_state.public_observation)
95
 
96
  st.toast(f"Uploading observations: {metadata_str}", icon="🦭")
97
- tab_log = st.session_state.tab_log
98
- if tab_log is not None:
99
- tab_log.info(f"Uploading observations: {metadata_str}")
100
 
101
  # get huggingface api
102
  token = os.environ.get("HF_TOKEN", None)
 
30
  metadata_str = json.dumps(observation) # doesn't work yet, TODO
31
 
32
  st.toast(f"Uploading observation: {metadata_str}", icon="🦭")
33
+ g_logger.info(f"Uploading observation: {metadata_str}")
 
 
34
 
35
  # write to temp file so we can send it (why is this not using context mgr?)
36
  f = tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False)
 
87
  push any observation since generating the logger)
88
 
89
  """
90
+ raise DeprecationWarning("This function is deprecated. Use push_all_observations instead.")
91
+
92
  # we get the observation from session state: 1 is the dict 2 is the image.
93
  # first, lets do an info display (popup)
94
  metadata_str = json.dumps(st.session_state.public_observation)
95
 
96
  st.toast(f"Uploading observations: {metadata_str}", icon="🦭")
97
+ g_logger.info(f"Uploading observations: {metadata_str}")
 
 
98
 
99
  # get huggingface api
100
  token = os.environ.get("HF_TOKEN", None)
src/main.py CHANGED
@@ -54,22 +54,13 @@ g_logger.setLevel(LOG_LEVEL)
54
  st.set_page_config(layout="wide")
55
 
56
  # initialise various session state variables
57
- init_logging_session_states() # logging should be early
58
  init_workflow_session_states()
59
-
60
- # TODO: this is obselete, now we have the st_logs functionality.
61
- if "tab_log" not in st.session_state:
62
- st.session_state.tab_log = None
63
-
64
  init_input_data_session_states()
65
  init_input_container_states()
66
  init_workflow_viz()
67
  init_classifier_session_states()
68
 
69
-
70
-
71
-
72
-
73
 
74
  def main() -> None:
75
  """
@@ -101,7 +92,6 @@ def main() -> None:
101
  # Streamlit app
102
  tab_inference, tab_hotdogs, tab_map, tab_coords, tab_log, tab_gallery = \
103
  st.tabs(["Cetecean classifier", "Hotdog classifier", "Map", "*:gray[Dev:coordinates]*", "Log", "Beautiful cetaceans"])
104
- st.session_state.tab_log = tab_log
105
 
106
  # put this early so the progress indicator is at the top (also refreshed at end)
107
  refresh_progress_display()
 
54
  st.set_page_config(layout="wide")
55
 
56
  # initialise various session state variables
57
+ init_logging_session_states() # logging init should be early
58
  init_workflow_session_states()
 
 
 
 
 
59
  init_input_data_session_states()
60
  init_input_container_states()
61
  init_workflow_viz()
62
  init_classifier_session_states()
63
 
 
 
 
 
64
 
65
  def main() -> None:
66
  """
 
92
  # Streamlit app
93
  tab_inference, tab_hotdogs, tab_map, tab_coords, tab_log, tab_gallery = \
94
  st.tabs(["Cetecean classifier", "Hotdog classifier", "Map", "*:gray[Dev:coordinates]*", "Log", "Beautiful cetaceans"])
 
95
 
96
  # put this early so the progress indicator is at the top (also refreshed at end)
97
  refresh_progress_display()