Skip to content

Commit e7e981a

Browse files
author
anna.yamkovaya
committed
add showing report on inspect page
1 parent 686e8b7 commit e7e981a

File tree

4 files changed

+38
-24
lines changed

4 files changed

+38
-24
lines changed

main.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
import streamlit as st
44

55

6-
7-
8-
96
def main():
107

118
st.set_page_config(page_title="Test2Text App", layout="wide")
@@ -16,6 +13,5 @@ def main():
1613
st.markdown("- Create report about the coverage of the requirements by the test cases.")
1714

1815

19-
2016
if __name__ == "__main__":
2117
main()

pages/2_inspect.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import streamlit as st
2+
3+
from report import make_a_report
4+
5+
6+
PAGES = {
7+
"Make coverage report": make_a_report,
8+
#"Visualize vectors": ,
9+
}
10+
11+
st.sidebar.title("Navigation")
12+
selection = st.sidebar.radio("Go to", list(PAGES.keys()))
13+
page = PAGES[selection]
14+
page()

pages/upload/requirements.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ def show():
1414

1515
index_requirements_from_files(uploaded_files)
1616

17+
18+
if __name__ == "__main__":
19+
show()

report.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import streamlit as st
12
from services.db import DbClient
23
from tqdm import tqdm
34

@@ -6,9 +7,8 @@ def add_new_line(summary):
67
return summary.replace("\n", "<br>")
78

89

9-
if __name__ == "__main__":
10-
with open("./private/report.html", "w", newline="", encoding="utf-8") as f:
11-
f.write("""
10+
def make_a_report():
11+
st.html("""
1212
<html>
1313
<head>
1414
<meta charset="utf-8">
@@ -27,35 +27,35 @@ def add_new_line(summary):
2727
"SELECT COUNT(*) FROM Requirements"
2828
).fetchone()[0]
2929

30-
f.write('<nav style="break-after: page;"><h1>Table of Contents</h1><ul>')
30+
st.html('<nav style="break-after: page;"><h1>Table of Contents</h1><ul>')
3131

3232
for requirement in tqdm(
33-
db.conn.execute("SELECT * FROM Requirements").fetchall(),
34-
desc="Generating table of contents",
35-
unit="requirements",
36-
total=all_reqs_count,
33+
db.conn.execute("SELECT * FROM Requirements").fetchall(),
34+
desc="Generating table of contents",
35+
unit="requirements",
36+
total=all_reqs_count,
3737
):
3838
req_id, req_external_id, req_summary, _ = requirement
39-
f.write(f"""
39+
st.html(f"""
4040
<li>
4141
<a href="#req_{req_id}">
4242
Requirement {req_external_id} ({req_id})
4343
</a>
4444
</li>""")
4545

46-
f.write("</ul></nav>")
46+
st.html("</ul></nav>")
4747

4848
data = db.conn.execute("""
4949
SELECT
5050
Requirements.id as req_id,
5151
Requirements.external_id as req_external_id,
5252
Requirements.summary as req_summary,
53-
53+
5454
Annotations.id as anno_id,
5555
Annotations.summary as anno_summary,
56-
56+
5757
AnnotationsToRequirements.cached_distance as distance,
58-
58+
5959
TestCases.id as case_id,
6060
TestCases.test_script as test_script,
6161
TestCases.test_case as test_case
@@ -83,22 +83,22 @@ def write_requirement():
8383
# if written_count > 5:
8484
# return
8585
written_count += 1
86-
f.write(f"""
86+
st.html(f"""
8787
<section style="break-after: page;">
8888
<h2 id="req_{current_req_id}">Requirement {current_req_external_id} ({current_req_id})</h2>
8989
<p>{add_new_line(req_summary)}</p>
9090
<h3>Annotations</h3>
9191
<ul>
9292
""")
9393
for anno_id, (anno_summary, distance) in current_annotations.items():
94-
f.write(
94+
st.html(
9595
f"<li>Annotation {anno_id} (distance: {distance:.3f}): <p>{add_new_line(anno_summary)}</p></li>"
9696
)
97-
f.write("</ul>")
98-
f.write("<h3>Test Scripts</h3><ul>")
97+
st.html("</ul>")
98+
st.html("<h3>Test Scripts</h3><ul>")
9999
for test_script in current_test_scripts:
100-
f.write(f"<li>{test_script}</li>")
101-
f.write("</ul></section>")
100+
st.html(f"<li>{test_script}</li>")
101+
st.html("</ul></section>")
102102

103103
for row in data.fetchall():
104104
(
@@ -123,9 +123,10 @@ def write_requirement():
123123
current_annotations[anno_id] = (anno_summary, distance)
124124
current_test_scripts.add(test_script)
125125
write_requirement()
126-
f.write("""
126+
st.html("""
127127
</article>
128128
</main>
129129
</body>
130130
</html>
131131
""")
132+

0 commit comments

Comments
 (0)