attilasimko commited on
Commit
69cbe77
·
1 Parent(s): 6e3c928

new logging style

Browse files
app.py CHANGED
@@ -6,10 +6,12 @@ st.write("\n")
6
  st.write("Welcome to the online reproducibility evaluation tool!")
7
  st.write("We follow guidelines provided by Simkó et al. (2022) (https://arxiv.org/abs/2210.11146)")
8
 
 
9
  repo_link = st.text_input("Github repository link:", value="", type="default", help=None)
10
 
11
  if (repo_link):
12
- evaluate(llm=None, verbose=2, repo_url=repo_link)
 
13
 
14
  with st.form("my_form"):
15
  st.write("Notice something wrong? Please tell us so we can improve.")
@@ -20,7 +22,7 @@ with st.form("my_form"):
20
  if submitted:
21
  if repo_link and feedback:
22
  st.write("Repository:", repo_link)
23
-
24
  google_form_url = "https://docs.google.com/forms/d/e/1FAIpQLSeJ6eWl4rdZX2lKnIMkylcMBR0qj2Dq2dDHzQX5dfUjOieB7w/formResponse"
25
  form_data = {
26
  "entry.1379878677": repo_link,
 
6
  st.write("Welcome to the online reproducibility evaluation tool!")
7
  st.write("We follow guidelines provided by Simkó et al. (2022) (https://arxiv.org/abs/2210.11146)")
8
 
9
+ checkbox = st.checkbox("Would you like to see recommendations during evaluation?", value=False)
10
  repo_link = st.text_input("Github repository link:", value="", type="default", help=None)
11
 
12
  if (repo_link):
13
+ verbose = 3 if checkbox else 4
14
+ evaluate(llm=None, verbose=verbose, repo_url=repo_link)
15
 
16
  with st.form("my_form"):
17
  st.write("Notice something wrong? Please tell us so we can improve.")
 
22
  if submitted:
23
  if repo_link and feedback:
24
  st.write("Repository:", repo_link)
25
+
26
  google_form_url = "https://docs.google.com/forms/d/e/1FAIpQLSeJ6eWl4rdZX2lKnIMkylcMBR0qj2Dq2dDHzQX5dfUjOieB7w/formResponse"
27
  form_data = {
28
  "entry.1379878677": repo_link,
evaluations/documentation.py CHANGED
@@ -3,7 +3,7 @@ import re
3
  import numpy as np
4
 
5
  def evaluate(verbose, llm, zip, readme):
6
- log(verbose, "LOG", "\nEvaluating code documentation...")
7
  overall = "No"
8
 
9
 
@@ -14,7 +14,7 @@ def evaluate(verbose, llm, zip, readme):
14
  if (readme):
15
  non_empty_rows = [row for row in readme.split("\n") if row != ""]
16
  if (len(non_empty_rows) < 5):
17
- log(verbose, "WARNING", "Readme file has very few lines")
18
  return overall
19
 
20
  if (count_code_lines(non_empty_rows) > 5):
 
3
  import numpy as np
4
 
5
  def evaluate(verbose, llm, zip, readme):
6
+ log(verbose, "TITLE", "\nEvaluating code documentation...")
7
  overall = "No"
8
 
9
 
 
14
  if (readme):
15
  non_empty_rows = [row for row in readme.split("\n") if row != ""]
16
  if (len(non_empty_rows) < 5):
17
+ log(verbose, "ERROR", "Readme file has very few lines")
18
  return overall
19
 
20
  if (count_code_lines(non_empty_rows) > 5):
evaluations/license.py CHANGED
@@ -2,7 +2,7 @@ from .utils import log, model_predict
2
  import re
3
 
4
  def evaluate(verbose, llm, zip, readme):
5
- log(verbose, "LOG", "\nEvaluating repository licensing...")
6
  overall = "No"
7
  license_files = [license for license in zip.namelist() if ((("LICENSE" in license) | ("license" in license)) & (len(license.split("/")) == 2))]
8
  if (len(license_files) > 0):
 
2
  import re
3
 
4
  def evaluate(verbose, llm, zip, readme):
5
+ log(verbose, "TITLE", "\nEvaluating repository licensing...")
6
  overall = "No"
7
  license_files = [license for license in zip.namelist() if ((("LICENSE" in license) | ("license" in license)) & (len(license.split("/")) == 2))]
8
  if (len(license_files) > 0):
evaluations/repo_evaluations.py CHANGED
@@ -92,7 +92,7 @@ def full_evaluation():
92
  row[column] = result[column]
93
 
94
  full_results.append(row)
95
- return pd.dataFrame(full_results)
96
 
97
  def midl_evaluations():
98
  compare_to_gt = True
@@ -145,4 +145,4 @@ def midl_evaluations():
145
  eval_licensing.append(("No" if row["license"] == "No" else "Yes") == row["pred_license"])
146
  print(f"LICENSE acc. - {row['pred_license']} (GT:{row['license']}) / {int(100 * np.mean(eval_licensing))}%")
147
 
148
- return pd.dataFrame(full_results)
 
92
  row[column] = result[column]
93
 
94
  full_results.append(row)
95
+ return pd.DataFrame(full_results)
96
 
97
  def midl_evaluations():
98
  compare_to_gt = True
 
145
  eval_licensing.append(("No" if row["license"] == "No" else "Yes") == row["pred_license"])
146
  print(f"LICENSE acc. - {row['pred_license']} (GT:{row['license']}) / {int(100 * np.mean(eval_licensing))}%")
147
 
148
+ return pd.DataFrame(full_results)
evaluations/requirements.py CHANGED
@@ -1,7 +1,7 @@
1
  from .utils import log
2
 
3
  def evaluate(verbose, llm, zip, readme):
4
- log(verbose, "LOG", "\nLooking for package dependencies for running the code...")
5
  overall = "No"
6
 
7
  scripts = [file_path for file_path in zip.namelist() if ((file_path.endswith(".py") | file_path.endswith(".ipynb")))]
@@ -13,7 +13,7 @@ def evaluate(verbose, llm, zip, readme):
13
  requirements = zip.open(file).read().decode("utf-8")
14
  overall = "Yes"
15
  if (len(requirements.split("\n")) < 5):
16
- log(verbose, "WARNING", "Requirements file contains too few lines.")
17
  overall = "No"
18
 
19
  if (readme):
 
1
  from .utils import log
2
 
3
  def evaluate(verbose, llm, zip, readme):
4
+ log(verbose, "TITLE", "\nLooking for package dependencies for running the code...")
5
  overall = "No"
6
 
7
  scripts = [file_path for file_path in zip.namelist() if ((file_path.endswith(".py") | file_path.endswith(".ipynb")))]
 
13
  requirements = zip.open(file).read().decode("utf-8")
14
  overall = "Yes"
15
  if (len(requirements.split("\n")) < 5):
16
+ log(verbose, "ERROR", "Requirements file contains too few lines.")
17
  overall = "No"
18
 
19
  if (readme):
evaluations/training.py CHANGED
@@ -2,7 +2,7 @@ from .utils import log
2
  import re
3
 
4
  def evaluate(verbose, llm, zip, readme):
5
- log(verbose, "LOG", "\nLooking for code to train the model...")
6
  overall = "No"
7
 
8
 
 
2
  import re
3
 
4
  def evaluate(verbose, llm, zip, readme):
5
+ log(verbose, "TITLE", "\nLooking for code to train the model...")
6
  overall = "No"
7
 
8
 
evaluations/utils.py CHANGED
@@ -105,32 +105,29 @@ def fetch_openalex(verbose, paper_name, year):
105
  def log(verbose, log_type, log_text, hf=False):
106
  if (verbose == 0):
107
  return
 
 
 
 
 
108
 
109
  # Align line-break
110
  if (log_text.startswith("\n")):
111
- if (verbose == 1):
112
- print("\n")
113
- if (verbose == 2):
114
- st.write("\n")
115
  log_text = log_text.lstrip('\n')
116
 
117
- if (log_type == "LOG"):
118
- log_text = f"LOG: {log_text}"
119
- if (log_type == "ERROR"):
120
- log_text = f"ERROR: {log_text}"
121
- if (log_type == "WARNING"):
122
- log_text = f"WARNING: {log_text}"
123
-
124
-
125
- if (verbose == 1):
126
- print(log_text)
127
- return
128
-
129
- if (verbose == 2):
130
- st.write(log_text)
131
- return
132
-
133
- raise Exception(log_text)
134
 
135
  def init_llm(verbose):
136
  log(verbose, "LOG", "Initializing LLM...")
 
105
  def log(verbose, log_type, log_text, hf=False):
106
  if (verbose == 0):
107
  return
108
+
109
+ if (verbose == 1 | verbose == 2):
110
+ show = print
111
+ if (verbose == 3 | verbose == 4):
112
+ show = st.write
113
 
114
  # Align line-break
115
  if (log_text.startswith("\n")):
116
+ show("\n")
 
 
 
117
  log_text = log_text.lstrip('\n')
118
 
119
+ # Only show tips in verbose mode 2 and 4
120
+ if ((log_type == "TITLE") & (verbose == 2 | verbose == 4)):
121
+ show(f"\n####{log_text}")
122
+ if ((log_type == "TIP") & (verbose == 2 | verbose == 4)):
123
+ show(f"*{log_text}*")
124
+ if ((log_type == "LOG") & (verbose == 2 | verbose == 4)):
125
+ show(f"{log_text}")
126
+ if ((log_type == "ERROR")):
127
+ show(f"**{log_text}**")
128
+
129
+ if ((log_type != "TIP") & (log_type != "LOG") & (log_type != "ERROR") & (log_type != "TITLE")):
130
+ raise ValueError("Invalid log type. Use 'TIP', 'LOG', 'TITLE' or 'ERROR'.")
 
 
 
 
 
131
 
132
  def init_llm(verbose):
133
  log(verbose, "LOG", "Initializing LLM...")
evaluations/validating.py CHANGED
@@ -2,7 +2,7 @@ from .utils import log
2
  import re
3
 
4
  def evaluate(verbose, llm, zip, readme):
5
- log(verbose, "LOG", "\nLooking for examples for running the model...")
6
  overall = "No"
7
  patterns = {
8
  'tensorflow': [
 
2
  import re
3
 
4
  def evaluate(verbose, llm, zip, readme):
5
+ log(verbose, "TITLE", "\nLooking for examples for running the model...")
6
  overall = "No"
7
  patterns = {
8
  'tensorflow': [
evaluations/weights.py CHANGED
@@ -2,7 +2,7 @@ from .utils import log
2
  import re
3
 
4
  def evaluate(verbose, llm, zip, readme):
5
- log(verbose, "LOG", "\nLooking for pre-trained model weights...")
6
  overall = "No"
7
  files = [file_path for file_path in zip.namelist() if ((file_path.endswith(".h5") | file_path.endswith(".pth") | file_path.endswith(".torch") | file_path.endswith(".pt") | file_path.endswith(".tar.gz") | file_path.endswith("checkpoint.pt") | ("weights" in file_path) | file_path.endswith("ckpt")))]
8
  if (len(files) > 0):
 
2
  import re
3
 
4
  def evaluate(verbose, llm, zip, readme):
5
+ log(verbose, "TITLE", "\nLooking for pre-trained model weights...")
6
  overall = "No"
7
  files = [file_path for file_path in zip.namelist() if ((file_path.endswith(".h5") | file_path.endswith(".pth") | file_path.endswith(".torch") | file_path.endswith(".pt") | file_path.endswith(".tar.gz") | file_path.endswith("checkpoint.pt") | ("weights" in file_path) | file_path.endswith("ckpt")))]
8
  if (len(files) > 0):