Skip to content

Commit

Permalink
bugfix: check analyzer output directory
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijianma committed Oct 20, 2023
1 parent d0ac2f8 commit 1c1df1d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 38 deletions.
32 changes: 21 additions & 11 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@ def analyze_and_show_res():
analyzer = Analyser(cfg)
dataset = analyzer.run()

analysis_res_ori = pd.read_csv(
os.path.join(analyzer.analysis_path, 'overall.csv'))
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))
overall_file = os.path.join(analyzer.analysis_path, 'overall.csv')
analysis_res_ori = pd.DataFrame()
if os.path.exists(overall_file):
analysis_res_ori = pd.read_csv(overall_file)

if os.path.exists(analyzer.analysis_path):
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))

st.session_state.dataset = dataset
st.session_state.original_overall = analysis_res_ori
Expand Down Expand Up @@ -171,12 +175,16 @@ def process_and_show_res():
analyzer.analysis_path = os.path.dirname(
cfg_for_processed_data.export_path) + '/analysis'
analyzer.run()
analysis_res_processed = pd.read_csv(
os.path.join(analyzer.analysis_path, 'overall.csv'))
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_processed.append(
os.path.join(analyzer.analysis_path, f_path))

overall_file = os.path.join(analyzer.analysis_path, 'overall.csv')
if os.path.exists(overall_file):
analysis_res_processed = pd.read_csv(overall_file)

if os.path.exists(analyzer.analysis_path):
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_processed.append(
os.path.join(analyzer.analysis_path, f_path))
except Exception as e:
st.warning(f'Something error with {str(e)}')

Expand Down Expand Up @@ -221,6 +229,8 @@ class Visualize:

@staticmethod
def filter_dataset(dataset):
if Fields.stats not in dataset:
return
text_key = st.session_state.get('text_key', 'text')
text = dataset[text_key]
stats = pd.DataFrame(dataset[Fields.stats])
Expand Down
30 changes: 19 additions & 11 deletions demos/data_process_loop/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@ def analyze_and_show_res():
analyzer = Analyser(cfg)
analyzed_dataset = analyzer.run()

analysis_res_ori = pd.read_csv(
os.path.join(analyzer.analysis_path, 'overall.csv'))
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))
overall_file = os.path.join(analyzer.analysis_path, 'overall.csv')
analysis_res_ori = pd.DataFrame()
if os.path.exists(overall_file):
analysis_res_ori = pd.read_csv(overall_file)

if os.path.exists(analyzer.analysis_path):
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))

st.session_state.analyzed_dataset = analyzed_dataset
st.session_state.original_overall = analysis_res_ori
Expand Down Expand Up @@ -132,12 +136,16 @@ def process_and_show_res():
analyzer.analysis_path = os.path.dirname(
cfg_for_processed_data.export_path) + '/analysis'
analyzer.run()
analysis_res_processed = pd.read_csv(
os.path.join(analyzer.analysis_path, 'overall.csv'))
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_processed.append(
os.path.join(analyzer.analysis_path, f_path))

overall_file = os.path.join(analyzer.analysis_path, 'overall.csv')
if os.path.exists(overall_file):
analysis_res_processed = pd.read_csv(overall_file)

if os.path.exists(analyzer.analysis_path):
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_processed.append(
os.path.join(analyzer.analysis_path, f_path))
else:
st.warning('No sample left after processing. Please change \
anther dataset or op parameters then rerun')
Expand Down
17 changes: 11 additions & 6 deletions demos/data_visualization_op_effect/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,15 @@ def analyze_and_show_res(dataset_file):
analyzer = Analyser(cfg)
dataset = analyzer.run()

analysis_res_ori = pd.read_csv(
os.path.join(analyzer.analysis_path, 'overall.csv'))
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))
overall_file = os.path.join(analyzer.analysis_path, 'overall.csv')
analysis_res_ori = pd.DataFrame()
if os.path.exists(overall_file):
analysis_res_ori = pd.read_csv(overall_file)

if os.path.exists(analyzer.analysis_path):
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))

st.session_state.dataset = dataset
st.session_state.original_overall = analysis_res_ori
Expand Down Expand Up @@ -316,7 +320,8 @@ def op_effect_analyze():

@staticmethod
def filter_dataset(dataset):

if Fields.stats not in dataset:
return
text_key = st.session_state.get('text_key', 'text')
text = dataset[text_key]
stats = pd.DataFrame(dataset[Fields.stats])
Expand Down
14 changes: 9 additions & 5 deletions demos/data_visualization_statistics/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ def analyze_and_show_res(dataset_file):
analyzer = Analyser(cfg)
dataset = analyzer.run()

analysis_res_ori = pd.read_csv(
os.path.join(analyzer.analysis_path, 'overall.csv'))
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))
overall_file = os.path.join(analyzer.analysis_path, 'overall.csv')
analysis_res_ori = pd.DataFrame()
if os.path.exists(overall_file):
analysis_res_ori = pd.read_csv(overall_file)

if os.path.exists(analyzer.analysis_path):
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))

st.session_state.dataset = dataset
st.session_state.original_overall = analysis_res_ori
Expand Down
14 changes: 9 additions & 5 deletions demos/overview_scan/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ def run_demo():
with st.spinner('Wait for analyze...'):
analyzer.run()

analysis_res_ori = pd.read_csv(
os.path.join(analyzer.analysis_path, 'overall.csv'))
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))
overall_file = os.path.join(analyzer.analysis_path, 'overall.csv')
analysis_res_ori = pd.DataFrame()
if os.path.exists(overall_file):
analysis_res_ori = pd.read_csv(overall_file)

if os.path.exists(analyzer.analysis_path):
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))

st.subheader('Statistics')
st.dataframe(analysis_res_ori, use_container_width=True)
Expand Down

0 comments on commit 1c1df1d

Please sign in to comment.