diff --git a/protoscribe/corpus/builder/build_dataset.py b/protoscribe/corpus/builder/build_dataset.py index ce1822a..2fa9cb2 100644 --- a/protoscribe/corpus/builder/build_dataset.py +++ b/protoscribe/corpus/builder/build_dataset.py @@ -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) diff --git a/protoscribe/evolution/make_html.py b/protoscribe/evolution/make_html.py index 3a09fe2..2897e9c 100644 --- a/protoscribe/evolution/make_html.py +++ b/protoscribe/evolution/make_html.py @@ -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: diff --git a/protoscribe/evolution/new_spellings_basic_main.py b/protoscribe/evolution/new_spellings_basic_main.py index f307570..b82fd1b 100644 --- a/protoscribe/evolution/new_spellings_basic_main.py +++ b/protoscribe/evolution/new_spellings_basic_main.py @@ -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: diff --git a/protoscribe/evolution/stages/build_dataset_main.py b/protoscribe/evolution/stages/build_dataset_main.py index 792d7ec..f83dd86 100644 --- a/protoscribe/evolution/stages/build_dataset_main.py +++ b/protoscribe/evolution/stages/build_dataset_main.py @@ -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 ) @@ -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 ) diff --git a/protoscribe/evolution/stages/new_spellings_basic_main.py b/protoscribe/evolution/stages/new_spellings_basic_main.py index 7b1e050..b2299de 100644 --- a/protoscribe/evolution/stages/new_spellings_basic_main.py +++ b/protoscribe/evolution/stages/new_spellings_basic_main.py @@ -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 ]) diff --git a/protoscribe/evolution/stages/sketches_from_jsonl_main.py b/protoscribe/evolution/stages/sketches_from_jsonl_main.py index 1b220f6..06bf2a0 100644 --- a/protoscribe/evolution/stages/sketches_from_jsonl_main.py +++ b/protoscribe/evolution/stages/sketches_from_jsonl_main.py @@ -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) diff --git a/protoscribe/texts/generate_simple_corpus_main.py b/protoscribe/texts/generate_simple_corpus_main.py index f79fbc2..5d3fbb8 100644 --- a/protoscribe/texts/generate_simple_corpus_main.py +++ b/protoscribe/texts/generate_simple_corpus_main.py @@ -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) @@ -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(