Skip to content
Open
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
34 changes: 34 additions & 0 deletions code/main.py
Original file line number Diff line number Diff line change
@@ -1,0 +1,34 @@
import argparse
import sys
from pathlib import Path

def parse_args(args):
parser = argparse.ArgumentParser(description="Multi-Modal Evidence Review System")
parser.add_argument("--input", type=str, default="dataset/claims.csv", help="Path to input claims CSV file")
parser.add_argument("--output", type=str, default="output.csv", help="Path to output CSV file")
parser.add_argument("--sample", action="store_true", help="Run on sample_claims.csv instead")
return parser.parse_args(args)

def main(args=None):
if args is None:
args = sys.argv[1:]

try:
parsed_args = parse_args(args)
except SystemExit as e:

Check failure on line 18 in code/main.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Reraise this exception to stop the application as the user expects

See more on https://sonarcloud.io/project/issues?id=NITISH-R-G_hackerrank-orchestrate-june26&issues=AZ7fBx94jTJXDMZfJPhX&open=AZ7fBx94jTJXDMZfJPhX&pullRequest=3
return e.code

input_file = "dataset/sample_claims.csv" if parsed_args.sample else parsed_args.input
output_file = parsed_args.output

print(f"Starting evidence review pipeline...")

Check warning on line 24 in code/main.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add replacement fields or use a normal string instead of an f-string.

See more on https://sonarcloud.io/project/issues?id=NITISH-R-G_hackerrank-orchestrate-june26&issues=AZ7fBx94jTJXDMZfJPhY&open=AZ7fBx94jTJXDMZfJPhY&pullRequest=3

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟑 Minor | ⚑ Quick win

Remove unnecessary f-string prefix on static text.

This triggers Ruff F541 and can fail lint checks; use a normal string literal.

Proposed fix
-    print(f"Starting evidence review pipeline...")
+    print("Starting evidence review pipeline...")
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print(f"Starting evidence review pipeline...")
print("Starting evidence review pipeline...")
🧰 Tools
πŸͺ› GitHub Check: SonarCloud Code Analysis

[warning] 24-24: Add replacement fields or use a normal string instead of an f-string.

See more on https://sonarcloud.io/project/issues?id=NITISH-R-G_hackerrank-orchestrate-june26&issues=AZ7fBx94jTJXDMZfJPhY&open=AZ7fBx94jTJXDMZfJPhY&pullRequest=3

πŸͺ› Ruff (0.15.17)

[error] 24-24: f-string without any placeholders

Remove extraneous f prefix

(F541)

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@code/main.py` at line 24, The print statement at the location with the
message "Starting evidence review pipeline..." uses an f-string prefix
(`f"..."`) but contains no variable interpolations or expressions, which
triggers the Ruff F541 lint rule. Remove the f-string prefix and use a normal
string literal instead, changing `f"Starting evidence review pipeline..."` to
`"Starting evidence review pipeline..."`.

Source: Linters/SAST tools

print(f"Input: {input_file}")
print(f"Output: {output_file}")

# TODO: Initialize and run the pipeline

Check warning on line 28 in code/main.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=NITISH-R-G_hackerrank-orchestrate-june26&issues=AZ7fBx94jTJXDMZfJPhZ&open=AZ7fBx94jTJXDMZfJPhZ&pullRequest=3

print("Pipeline completed successfully.")
return 0

if __name__ == "__main__":
sys.exit(main())
62 changes: 62 additions & 0 deletions code/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import pytest
import sys
from main import parse_args, main

def test_parse_args_defaults():
args = parse_args([])
assert args.input == "dataset/claims.csv"
assert args.output == "output.csv"
assert args.sample is False

def test_parse_args_custom_files():
args = parse_args(["--input", "custom_in.csv", "--output", "custom_out.csv"])
assert args.input == "custom_in.csv"
assert args.output == "custom_out.csv"
assert args.sample is False

def test_parse_args_sample_flag():
args = parse_args(["--sample"])
assert args.sample is True

def test_parse_args_help(capsys):
with pytest.raises(SystemExit) as excinfo:
parse_args(["--help"])
assert excinfo.value.code == 0
captured = capsys.readouterr()
assert "Multi-Modal Evidence Review System" in captured.out

def test_parse_args_invalid_argument(capsys):
with pytest.raises(SystemExit) as excinfo:
parse_args(["--invalid-flag"])
assert excinfo.value.code == 2
captured = capsys.readouterr()
assert "unrecognized arguments: --invalid-flag" in captured.err

def test_main_execution_defaults(capsys):
exit_code = main([])
assert exit_code == 0
captured = capsys.readouterr()
assert "Starting evidence review pipeline" in captured.out
assert "Input: dataset/claims.csv" in captured.out
assert "Output: output.csv" in captured.out

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (testing): Consider asserting that the final success message is printed to ensure the whole happy-path is exercised.

Since main prints a final status line, it’d be good to assert on it here as well to fully cover the happy path and catch regressions that skip or change the message:

assert "Pipeline completed successfully." in captured.out


def test_main_execution_sample_flag(capsys):
exit_code = main(["--sample"])
assert exit_code == 0
captured = capsys.readouterr()
assert "Input: dataset/sample_claims.csv" in captured.out

def test_main_execution_custom_args(capsys):
exit_code = main(["--input", "test_in.csv", "--output", "test_out.csv"])
assert exit_code == 0
captured = capsys.readouterr()
assert "Input: test_in.csv" in captured.out
assert "Output: test_out.csv" in captured.out

def test_main_help_returns_zero(capsys):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟑 Minor | ⚑ Quick win

Drop unused capsys fixture parameters in two tests.

These trigger Ruff ARG001; removing them keeps the suite lint-clean.

Proposed fix
-def test_main_help_returns_zero(capsys):
+def test_main_help_returns_zero():
@@
-def test_main_invalid_args_returns_error(capsys):
+def test_main_invalid_args_returns_error():

Also applies to: 60-60

🧰 Tools
πŸͺ› Ruff (0.15.17)

[warning] 56-56: Unused function argument: capsys

(ARG001)

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@code/tests/test_main.py` at line 56, Remove the unused `capsys` fixture
parameter from the function signature of `test_main_help_returns_zero` and from
the other test function mentioned at lines 60-60. The `capsys` parameter is not
used within these test functions and triggers the Ruff ARG001 linting rule.
Simply delete the parameter from both function definitions to keep the test
suite lint-clean.

Source: Linters/SAST tools

exit_code = main(["--help"])
assert exit_code == 0
Comment on lines +56 to +58

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion (testing): Also assert that the help text is printed in test_main_help_returns_zero to fully validate --help behavior.

Since parse_args(["--help"]) prints the help text before exiting, please capture stdout/stderr and assert a key phrase from the help, e.g.:

def test_main_help_returns_zero(capsys):
    exit_code = main(["--help"])
    assert exit_code == 0
    captured = capsys.readouterr()
    assert "Multi-Modal Evidence Review System" in captured.out

This verifies the help content from the main entry point, not just the exit code.

Suggested change
def test_main_help_returns_zero(capsys):
exit_code = main(["--help"])
assert exit_code == 0
def test_main_help_returns_zero(capsys):
exit_code = main(["--help"])
assert exit_code == 0
captured = capsys.readouterr()
assert "Multi-Modal Evidence Review System" in captured.out


def test_main_invalid_args_returns_error(capsys):
exit_code = main(["--invalid"])
assert exit_code == 2