Skip to content

Commit 36fd3aa

Browse files
committed
Made review changes
1 parent 3355e03 commit 36fd3aa

File tree

3 files changed

+54
-9
lines changed

3 files changed

+54
-9
lines changed

scripts/3-report/gcs_report.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ def parse_arguments():
5959
help="Enable git actions such as fetch, merge, add, commit, and push"
6060
" (default: False)",
6161
)
62+
parser.add_argument(
63+
"--force",
64+
action="store_true",
65+
help="Regenerate data even if report files exist",
66+
)
6267
args = parser.parse_args()
6368
if not args.enable_save and args.enable_git:
6469
parser.error("--enable-git requires --enable-save")
@@ -71,10 +76,20 @@ def parse_arguments():
7176

7277

7378
def check_report_completion(args):
74-
last_entry = shared.path_join(PATHS["data_phase"], "gcs_free_culture.png")
75-
if os.path.exists(last_entry) and not args.force:
76-
LOGGER.info(f"{last_entry} already exists. Script completed")
79+
""" "
80+
The function checks for the last plot and image
81+
caption created in this script. This helps to
82+
immediately know if all plots in the script have
83+
been created and should not be regenerated.
84+
85+
"""
86+
if args.force:
7787
return
88+
last_entry = shared.path_join(PATHS["data_phase"], "gcs_free_culture.png")
89+
if os.path.exists(last_entry):
90+
raise shared.QuantifyingException(
91+
f"{last_entry} already exists. Report script completed", 0
92+
)
7893

7994

8095
def gcs_intro(args):

scripts/3-report/github_report.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ def parse_arguments():
6262
action="store_true",
6363
help="Regenerate data even if images files already exist",
6464
)
65+
parser.add_argument(
66+
"--force",
67+
action="store_true",
68+
help="Regenerate data even if report files exist",
69+
)
6570
args = parser.parse_args()
6671
if not args.enable_save and args.enable_git:
6772
parser.error("--enable-git requires --enable-save")
@@ -74,12 +79,22 @@ def parse_arguments():
7479

7580

7681
def check_report_completion(args):
82+
""" "
83+
The function checks for the last plot and image
84+
caption created in this script. This helps to
85+
immediately know if all plots in the script have
86+
been created and should not be regenerated.
87+
88+
"""
89+
if args.force:
90+
return
7791
last_entry = shared.path_join(
7892
PATHS["data_phase"], "github_restriction.png"
7993
)
80-
if os.path.exists(last_entry) and not args.force:
81-
LOGGER.info(f"{last_entry} already exists. Script completed")
82-
return
94+
if os.path.exists(last_entry):
95+
raise shared.QuantifyingException(
96+
f"{last_entry} already exists. Report script completed", 0
97+
)
8398

8499

85100
def load_data(args):

scripts/3-report/wikipedia_report.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ def parse_arguments():
5757
help="Enable git actions such as fetch, merge, add, commit, and push"
5858
" (default: False)",
5959
)
60+
parser.add_argument(
61+
"--force",
62+
action="store_true",
63+
help="Regenerate data even if report files exist",
64+
)
6065
args = parser.parse_args()
6166
if not args.enable_save and args.enable_git:
6267
parser.error("--enable-git requires --enable-save")
@@ -69,12 +74,22 @@ def parse_arguments():
6974

7075

7176
def check_report_completion(args):
77+
""" "
78+
The function checks for the last plot and image
79+
caption created in this script. This helps to
80+
immediately know if all plots in the script have
81+
been created and should not be regenerated.
82+
83+
"""
84+
if args.force:
85+
return
7286
last_entry = shared.path_join(
7387
PATHS["data_phase"], "wikipedia_least_language_usage.png"
7488
)
75-
if os.path.exists(last_entry) and not args.force:
76-
LOGGER.info(f"{last_entry} already exists. Script completed")
77-
return
89+
if os.path.exists(last_entry):
90+
raise shared.QuantifyingException(
91+
f"{last_entry} already exists. Report script completed", 0
92+
)
7893

7994

8095
def wikipedia_intro(args):

0 commit comments

Comments
 (0)