Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 721553902
  • Loading branch information
agutkin committed Jan 31, 2025
1 parent 0d70fa9 commit d7c4146
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
4 changes: 3 additions & 1 deletion protoscribe/corpus/builder/build_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ def _prepare_language_components() -> None:
language_dir = os.path.join(output_dir, "language")
logging.info("Language directory: %s", language_dir)
if not os.path.exists(language_dir):
os.makedirs(language_dir)
os.makedirs(
language_dir, exist_ok=True
)

# Copy these files that are copyable verbatim.
file_utils.copy_src_file("texts/configs", _NUMBER_CONFIG.value, language_dir)
Expand Down
4 changes: 3 additions & 1 deletion protoscribe/evolution/make_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ def make_html() -> None:
output_svg_dir = os.path.join(_OUTPUT_HTML_DIR.value, "svgs")
if not os.path.exists(output_svg_dir):
logging.info("Making directory %s ...", output_svg_dir)
os.makedirs(output_svg_dir)
os.makedirs(
output_svg_dir, exist_ok=True
)

# Create index page.
if not _EXTENSIONS_FILE.value:
Expand Down
2 changes: 1 addition & 1 deletion protoscribe/evolution/new_spellings_basic_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def main(unused_argv):
# Create a summary of all the extensions in this round.
output_dir = os.path.join(_DATA_LOCATION.value, "inference_extensions")
if not os.path.exists(output_dir):
os.makedirs(output_dir)
os.makedirs(output_dir, exist_ok=True)
extensions_path = os.path.join(output_dir, "extensions.tsv")
logging.info("Writing extensions to %s ...", extensions_path)
with open(extensions_path, "w") as s:
Expand Down
8 changes: 6 additions & 2 deletions protoscribe/evolution/stages/build_dataset_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def _setup_builder(round_data_dir: str) -> list[tuple[str, Any]]:
# language definitions from the previous round.
logging.info("Making %s ...", round_data_dir)
language_dir = os.path.join(round_data_dir, "language")
os.makedirs(language_dir)
os.makedirs(
language_dir, exist_ok=True
)
file_utils.copy_dir(
os.path.join(previous_data_dir, "language"), language_dir
)
Expand Down Expand Up @@ -116,7 +118,9 @@ def _setup_builder(round_data_dir: str) -> list[tuple[str, Any]]:

# At this stage it is safe to do this again.
if not os.path.isdir(round_data_dir):
os.makedirs(round_data_dir)
os.makedirs(
round_data_dir, exist_ok=True
)
logging.info(
"Created `%s` for outputs for round %d.", round_data_dir, round_id
)
Expand Down
5 changes: 4 additions & 1 deletion protoscribe/evolution/stages/new_spellings_basic_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ def main(argv: Sequence[str]) -> None:
round_data_dir, "glyph_extensions_svg"
)
if not os.path.exists(output_glyph_graphics_dir):
os.makedirs(output_glyph_graphics_dir)
os.makedirs(
output_glyph_graphics_dir,
exist_ok=True
)
args.extend([
"--output_glyph_graphics_dir", svg_temp_dir.name
])
Expand Down
4 changes: 3 additions & 1 deletion protoscribe/evolution/stages/sketches_from_jsonl_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def _sketches_and_glyphs_for_model_type(
images_dir = os.path.join(output_dir, "images")
logging.info("Copying sketches to %s ...", images_dir)
if not os.path.exists(images_dir):
os.makedirs(images_dir)
os.makedirs(
images_dir, exist_ok=True
)
file_utils.copy_dir(temp_dir_name, images_dir)


Expand Down
4 changes: 2 additions & 2 deletions protoscribe/texts/generate_simple_corpus_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def main(argv: Sequence[str]) -> None:
params_dir = f"{initial_dir}/params"
concepts_dir = f"{_SRC_DIR}/data/concepts"
if not os.path.exists(params_dir):
os.makedirs(params_dir)
os.makedirs(params_dir, exist_ok=True)

# Generate lexicon resources.
logging.info("Generating the lexicon with ALL concepts in %s ...", params_dir)
Expand Down Expand Up @@ -116,7 +116,7 @@ def main(argv: Sequence[str]) -> None:
# Now generate the accounting texts.
output_dir = f"{initial_dir}/output"
if not os.path.exists(output_dir):
os.makedirs(output_dir)
os.makedirs(output_dir, exist_ok=True)
for set_idx in range(_NUM_SETS.value):
logging.info("Generating accounting texts set %d ...", set_idx)
subprocess_utils.run_subprocess(
Expand Down

0 comments on commit d7c4146

Please sign in to comment.