Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Update textbook generation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
emrgnt-cmplxty committed Oct 14, 2023
1 parent c5e7833 commit b223748
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sciphi/examples/library_of_phi/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def validate_config(self, logger: logging.Logger) -> None:
for key, value in summary.items():
logger.info(f"{key}: {value}")

def get_yml_file_paths(self) -> list:
def get_yml_file_paths(self, logger: logging.Logger) -> list:
"""Get the YAML file paths."""
if self.config.textbook:
yml_file_paths = [
Expand Down Expand Up @@ -139,7 +139,7 @@ def get_yml_file_paths(self) -> list:
if not self._book_exists(yml_file_path):
filtered_books.append(yml_file_path)
else:
self.logger.warning(
logger.warning(
f"Skipping {yml_file_path} as it already exists."
)
yml_file_paths_chunk = filtered_books
Expand Down
9 changes: 7 additions & 2 deletions sciphi/examples/library_of_phi/generate_textbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def dry_run(self) -> None:

def run(self) -> None:
"""Run the draft book generation process."""
yml_file_paths_chunk = self.config_manager.get_yml_file_paths()
yml_file_paths_chunk = self.config_manager.get_yml_file_paths(
self.logger
)

if self.config.num_threads_per_proc > 1:
self.logger.debug(
Expand All @@ -146,7 +148,10 @@ def run(self) -> None:
pool.close()
pool.join()
else:
self.process_yml_file(yml_file_paths_chunk[0])
for yml_file_path in tqdm(
yml_file_paths_chunk, desc="Processing files"
):
self.process_yml_file(yml_file_path)

def process_yml_file(self, yml_file_path: str) -> None:
"""Process a single YAML file to generate textbook content."""
Expand Down

0 comments on commit b223748

Please sign in to comment.