Skip to content

Prevent FASTA-to-JSONL conversion from erasing its source - #1758

Open
VishnuR23 wants to merge 1 commit into
NVIDIA-BioNeMo:mainfrom
VishnuR23:fix/fasta-jsonl-source-protection
Open

VishnuR23 wants to merge 1 commit into
NVIDIA-BioNeMo:mainfrom
VishnuR23:fix/fasta-jsonl-source-protection

Conversation

@VishnuR23

Copy link
Copy Markdown

Description

Passing the same file as both input and output to bionemo_fasta_to_jsonl opens the output in write mode before reading the source, silently erasing the FASTA and reporting zero records. Different path strings can trigger the same loss through symlinks or hard links.

Check file identity before opening the output and raise a clear ValueError when input and output refer to the same file. The CLI reports the error and exits with status 1. Conversion to a distinct output retains the current overwrite and uppercase behavior. Regenerate the enforced Eden/phage copies.

Type of changes

  • Bug fix

Validation

  • Four source-protection regressions fail on main: identical path, relative alias, symlink, and hard link.
  • All seven CPU tests pass after the fix, including CLI behavior and normal multiline conversion with/without uppercasing.
  • All applicable pre-commit hooks pass.
  • GPU recipe suites were not run locally; this change operates on local text files.

Signed-off-by: VishnuR23 <vishnurajeev2345@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Sep 21, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: NVIDIA-BioNeMo/bionemo-recipes/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: a5780594-707e-43d9-a03c-32298203ec50

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

Comment on lines -100 to +111
count = fasta_to_jsonl(args.input, args.output, uppercase=args.upper)
try:
count = fasta_to_jsonl(args.input, args.output, uppercase=args.upper)
except ValueError as error:
print(f"Error: {error}", file=sys.stderr)
sys.exit(1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm pretty sure this doesn't add anything, right? the stack trace will be printed either way and the program will exit on that raise. Otherwise looks good.

@jstjohn jstjohn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved with one cleanup request around exception handling (I think it would be better to not do it in this case), since as far as I can tell all you are doing is prepending the stack trace message with the word "Error: ".

This branch has not been deployed

No deployments
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.

2 participants