Skip to content

Commit b065cbd

Browse files
committed
add --skip-commit, --skip-push, and --show-plots options
1 parent 468ae99 commit b065cbd

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

scripts/3-report/gcs_reports.py

+29-7
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,28 @@ def parse_arguments():
4141
"--quarter",
4242
"-q",
4343
type=str,
44-
required=False,
4544
default=f"{quarter}",
4645
help="Data quarter in format YYYYQx, e.g., 2024Q2",
4746
)
48-
return parser.parse_args()
47+
parser.add_argument(
48+
"--skip-commit",
49+
action="store_true",
50+
help="Don't git commit changes (also skips git push changes)",
51+
)
52+
parser.add_argument(
53+
"--skip-push",
54+
action="store_true",
55+
help="Don't git push changes",
56+
)
57+
parser.add_argument(
58+
"--show-plots",
59+
action="store_true",
60+
help="Show generated plots (in addition to saving them)",
61+
)
62+
args = parser.parse_args()
63+
if args.skip_commit:
64+
args.skip_push = True
65+
return args
4966

5067

5168
def load_data(args):
@@ -129,7 +146,8 @@ def visualize_by_country(data, args):
129146
image_path = os.path.join(output_directory, "gcs_country_report.png")
130147
plt.savefig(image_path)
131148

132-
plt.show()
149+
if args.show_plots:
150+
plt.show()
133151

134152
shared.update_readme(
135153
PATHS,
@@ -198,7 +216,8 @@ def millions_formatter(x, pos):
198216

199217
plt.savefig(image_path)
200218

201-
plt.show()
219+
if args.show_plots:
220+
plt.show()
202221

203222
shared.update_readme(
204223
PATHS,
@@ -274,7 +293,8 @@ def visualize_by_language(data, args):
274293
image_path = os.path.join(output_directory, "gcs_language_report.png")
275294
plt.savefig(image_path)
276295

277-
plt.show()
296+
if args.show_plots:
297+
plt.show()
278298

279299
shared.update_readme(
280300
PATHS,
@@ -307,10 +327,12 @@ def main():
307327
visualize_by_language(data, args)
308328

309329
# Add and commit changes
310-
shared.add_and_commit(PATHS["repo"], "Added and committed new reports")
330+
if not args.skip_commit:
331+
shared.add_and_commit(PATHS["repo"], "Added and committed new reports")
311332

312333
# Push changes
313-
shared.push_changes(PATHS["repo"])
334+
if not args.skip_push:
335+
shared.push_changes(PATHS["repo"])
314336

315337

316338
if __name__ == "__main__":

0 commit comments

Comments
 (0)