Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plaintext): include max_plaintext_per_fixture_file attribute in… #61

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions alto2txt2fixture/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .plaintext import (
DEFAULT_EXTRACTED_SUBDIR,
DEFAULT_INITIAL_PK,
DEFAULT_MAX_PLAINTEXT_PER_FIXTURE_FILE,
DEFAULT_PLAINTEXT_FIXTURE_OUTPUT,
PlainTextFixture,
)
Expand All @@ -34,6 +35,9 @@ def plaintext(
initial_pk: Annotated[
int, typer.Option(help="First primary key to increment json export from")
] = DEFAULT_INITIAL_PK,
records_per_json: Annotated[
int, typer.Option(help="Max records per json fixture")
] = DEFAULT_MAX_PLAINTEXT_PER_FIXTURE_FILE,
) -> None:
"""Create a PlainTextFixture and save to `save_path`."""
plaintext_fixture = PlainTextFixture(
Expand All @@ -42,6 +46,7 @@ def plaintext(
extract_subdir=extract_path,
export_directory=save_path,
initial_pk=initial_pk,
max_plaintext_per_fixture_file=records_per_json,
)
plaintext_fixture.info()
while (
Expand Down
5 changes: 4 additions & 1 deletion alto2txt2fixture/plaintext.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
] = f"*{FULLTEXT_FILE_NAME_SUFFIX}.{ZIP_FILE_EXTENSION}"
TXT_FIXTURE_FILE_EXTENSION: Final[str] = "txt"
TXT_FIXTURE_FILE_GLOB_REGEX: Final[str] = f"**/*.{TXT_FIXTURE_FILE_EXTENSION}"
DEFAULT_MAX_PLAINTEXT_PER_FIXTURE_FILE: Final[int] = 2000
DEFAULT_MAX_PLAINTEXT_PER_FIXTURE_FILE: Final[int] = 100
DEFAULT_PLAINTEXT_FILE_NAME_PREFIX: Final[str] = "plaintext_fixture"
DEFAULT_PLAINTEXT_FIXTURE_OUTPUT: Final[PathLike] = Path("output") / "plaintext"
DEFAULT_INITIAL_PK: int = 1
Expand Down Expand Up @@ -157,6 +157,7 @@ class PlainTextFixture:
│ Uncompressed Files │ None ...│
│ Data Provider │ 'Living with Machines' ...│
│ Initial Primary Key │ 1 ...│
│ Max Rows Per JSON │ 100 ...│
└─────────────────────┴────────────────────────────────...┘
>>> plaintext_bl_lwm.free_hd_space_in_GB > 1
True
Expand Down Expand Up @@ -276,6 +277,7 @@ def info_table(self) -> str:
table.add_row("Uncompressed Files", self.trunc_uncompressed_file_names_str)
table.add_row("Data Provider", f"'{str(self.data_provider_name)}'")
table.add_row("Initial Primary Key", str(self.initial_pk))
table.add_row("Max Rows Per JSON", str(self.max_plaintext_per_fixture_file))
return table

def info(self) -> None:
Expand Down Expand Up @@ -655,6 +657,7 @@ def export_to_json_fixtures(
prefix=prefix,
output_path=output_path,
add_created=True,
max_elements_per_file=self.max_plaintext_per_fixture_file,
)
self._exported_json_paths = tuple(
Path(path) for path in sorted(Path(output_path).glob(f"**/{prefix}*.json"))
Expand Down