Skip to content

Feature/ Added unroll command in PYQASM CLI#224

Merged
TheGupta2012 merged 10 commits intoqBraid:mainfrom
vinayswamik:feature/cli-unroll
Jul 4, 2025
Merged

Feature/ Added unroll command in PYQASM CLI#224
TheGupta2012 merged 10 commits intoqBraid:mainfrom
vinayswamik:feature/cli-unroll

Conversation

@vinayswamik
Copy link
Copy Markdown
Collaborator

Summary of changes

Add unroll command to PyQASM CLI

  • Introduced a new unroll command for unrolling OpenQASM files, allowing users to process multiple files or directories.
  • Implemented options for skipping files (-s or --skip), overwriting original files (--overwrite), and specifying output paths (--output or -o).
  • Added validation to ensure output paths are only used with single input files.
  • Created a new unroll.py module to handle the unrolling logic.
  • Enhanced CLI tests to cover various scenarios for the new command, including help output, single file processing, directory handling, and error cases.

Closes #189

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 30, 2025

Codecov Report

Attention: Patch coverage is 96.21212% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pyqasm/cli/unroll.py 96.36% 4 Missing ⚠️
src/pyqasm/cli/validate.py 88.88% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!


except (ValidationError, UnrollError, QasmParsingError) as err:
failed_files.append((file_path, err))
except Exception as uncaught_err: # pylint: disable=broad-exception-caught
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are creating the file at output_path and an error occurs, better to add a remove file in this exception block

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, if output path already exists, files might get effect from remove. instead i will try writing to temp file if it succeed then remove the tempfile and add it to output file.

Copy link
Copy Markdown
Member

@TheGupta2012 TheGupta2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vinayswamik , looks good overall! Gave some comments related to refactoring and minor updates to error handling / reporting

vinayswamik and others added 7 commits July 3, 2025 04:04
- Added `unroll` command to PYQASM cli.
- Added test cases.
Co-authored-by: Harshit Gupta <harshit.11235@gmail.com>
- Updated `unroll` command in `main.py` to accept optional parameters for `skip_files` and `overwrite`.
- Introduced a new method in `QasmModule` to determine if files should be skipped based on specific tags.
- Enhanced error reporting in the `unroll_qasm` function to include raw logger output for better debugging.
- Added comprehensive tests for the `unroll` command, covering various scenarios including file skipping, output handling, and error cases.
@vinayswamik vinayswamik force-pushed the feature/cli-unroll branch from 7fedb2c to 0c43714 Compare July 3, 2025 09:04
@vinayswamik vinayswamik requested a review from TheGupta2012 July 3, 2025 09:11
Copy link
Copy Markdown
Member

@TheGupta2012 TheGupta2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vinayswamik , changes lgtm - just one edit about skip files and then we should be good to merge!

@TheGupta2012 TheGupta2012 self-requested a review July 4, 2025 08:16
Copy link
Copy Markdown
Member

@TheGupta2012 TheGupta2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@TheGupta2012 TheGupta2012 merged commit 6b5c711 into qBraid:main Jul 4, 2025
21 checks passed
@vinayswamik vinayswamik deleted the feature/cli-unroll branch July 7, 2025 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Introduce unroll Command in PyQASM CLI

3 participants