CLI output path is hardcoded, making scripted usage difficult#268
Open
mustafagoktugibolar wants to merge 2 commits into
Open
CLI output path is hardcoded, making scripted usage difficult#268mustafagoktugibolar wants to merge 2 commits into
mustafagoktugibolar wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds CLI configurability for where run_pageindex.py writes its JSON output, addressing scripted/pipeline usage where a hardcoded ./results/... path is inconvenient.
Changes:
- Added
--output-dirand--output-fileCLI flags (mutually exclusive) to control output location. - Updated PDF and Markdown flows to write JSON to either the specified directory or explicit file path.
- Documented the new flags in
README.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| run_pageindex.py | Adds mutually exclusive output path CLI args and updates both PDF/MD save logic to respect them. |
| README.md | Documents the new --output-dir / --output-file options in the optional parameters list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+79
to
+88
| pdf_name = os.path.splitext(os.path.basename(args.pdf_path))[0] | ||
| if args.output_file: | ||
| output_file = args.output_file | ||
| parent = os.path.dirname(os.path.abspath(output_file)) | ||
| if parent: | ||
| os.makedirs(parent, exist_ok=True) | ||
| else: | ||
| output_dir = args.output_dir if args.output_dir else './results' | ||
| os.makedirs(output_dir, exist_ok=True) | ||
| output_file = os.path.join(output_dir, f'{pdf_name}_structure.json') |
Comment on lines
+183
to
+184
| --output-dir Directory to write the output JSON (default: ./results) | ||
| --output-file Full output file path, e.g. /tmp/my_doc.json |
Comment on lines
+81
to
+86
| output_file = args.output_file | ||
| parent = os.path.dirname(os.path.abspath(output_file)) | ||
| if parent: | ||
| os.makedirs(parent, exist_ok=True) | ||
| else: | ||
| output_dir = args.output_dir if args.output_dir else './results' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
I've been using
run_pageindex.pyas part of a larger script that processesmultiple documents. The issue is that the output path is hardcoded to
./results/{name}_structure.jsonwith no way to override it.This becomes a problem when:
Expected Behavior
Users should be able to specify where the output file is written via CLI arguments.
Proposed Solution
Add
--output-dirand--output-filearguments:Backward Compatibility
No breaking changes. If neither argument is provided, the output is still written
to
./results/{name}_structure.json— exactly the same as before.