stephenleo commited on
Commit
43def6f
1 Parent(s): 7e53eea

updating to streamlit 1.9

Browse files
Files changed (2) hide show
  1. helpers.py +37 -37
  2. requirements.txt +9 -11
helpers.py CHANGED
@@ -11,7 +11,7 @@ import networkx as nx
11
  import textwrap
12
  import logging
13
 
14
- from streamlit.report_thread import REPORT_CONTEXT_ATTR_NAME
15
  from threading import current_thread
16
  from contextlib import contextmanager
17
  from io import StringIO
@@ -232,39 +232,39 @@ def network_centrality(topic_data, centrality, centrality_option):
232
  # Progress bar printer
233
  # https://github.com/BugzTheBunny/streamlit_logging_output_example/blob/main/app.py
234
  # https://discuss.streamlit.io/t/cannot-print-the-terminal-output-in-streamlit/6602/34
235
- @contextmanager
236
- def st_redirect(src, dst):
237
- placeholder = st.empty()
238
- output_func = getattr(placeholder, dst)
239
-
240
- with StringIO() as buffer:
241
- old_write = src.write
242
-
243
- def new_write(b):
244
- if getattr(current_thread(), REPORT_CONTEXT_ATTR_NAME, None):
245
- buffer.write(b)
246
- time.sleep(1)
247
- buffer.seek(0) # returns pointer to 0 position
248
- output_func(b)
249
- else:
250
- old_write(b)
251
-
252
- try:
253
- src.write = new_write
254
- yield
255
- finally:
256
- src.write = old_write
257
-
258
-
259
- @contextmanager
260
- def st_stdout(dst):
261
- "this will show the prints"
262
- with st_redirect(sys.stdout, dst):
263
- yield
264
-
265
-
266
- @contextmanager
267
- def st_stderr(dst):
268
- "This will show the logging"
269
- with st_redirect(sys.stderr, dst):
270
- yield
 
11
  import textwrap
12
  import logging
13
 
14
+ # from streamlit.ReportThread import REPORT_CONTEXT_ATTR_NAME
15
  from threading import current_thread
16
  from contextlib import contextmanager
17
  from io import StringIO
 
232
  # Progress bar printer
233
  # https://github.com/BugzTheBunny/streamlit_logging_output_example/blob/main/app.py
234
  # https://discuss.streamlit.io/t/cannot-print-the-terminal-output-in-streamlit/6602/34
235
+ # @contextmanager
236
+ # def st_redirect(src, dst):
237
+ # placeholder = st.empty()
238
+ # output_func = getattr(placeholder, dst)
239
+
240
+ # with StringIO() as buffer:
241
+ # old_write = src.write
242
+
243
+ # def new_write(b):
244
+ # if getattr(current_thread(), REPORT_CONTEXT_ATTR_NAME, None):
245
+ # buffer.write(b)
246
+ # time.sleep(1)
247
+ # buffer.seek(0) # returns pointer to 0 position
248
+ # output_func(b)
249
+ # else:
250
+ # old_write(b)
251
+
252
+ # try:
253
+ # src.write = new_write
254
+ # yield
255
+ # finally:
256
+ # src.write = old_write
257
+
258
+
259
+ # @contextmanager
260
+ # def st_stdout(dst):
261
+ # "this will show the prints"
262
+ # with st_redirect(sys.stdout, dst):
263
+ # yield
264
+
265
+
266
+ # @contextmanager
267
+ # def st_stderr(dst):
268
+ # "This will show the logging"
269
+ # with st_redirect(sys.stderr, dst):
270
+ # yield
requirements.txt CHANGED
@@ -1,11 +1,9 @@
1
- bertopic==0.9.4
2
- git+https://github.com/scikit-learn-contrib/hdbscan.git@master
3
- numba==0.53.0
4
- networkx==2.6.3
5
- numpy==1.22.0
6
- pandas==1.3.4
7
- plotly==5.1.0
8
- pyvis==0.1.9
9
- scikit_learn==1.0.2
10
- sentence_transformers==2.1.0
11
- streamlit==1.3.1
 
1
+ bertopic==0.10.0
2
+ networkx==2.8.2
3
+ numpy==1.22.4
4
+ pandas==1.4.2
5
+ plotly==5.8.0
6
+ pyvis==0.2.1
7
+ scikit_learn==1.1.1
8
+ sentence_transformers==2.2.0
9
+ streamlit==1.9.2