Skip to content

Add submission_info command#6

Merged
kostyanf14 merged 2 commits into
cross.1.2025.326.1from
info_cmd
Dec 1, 2025
Merged

Add submission_info command#6
kostyanf14 merged 2 commits into
cross.1.2025.326.1from
info_cmd

Conversation

@kostyanf14
Copy link
Copy Markdown
Member

No description provided.

if script is running in Cygwin environment, os.path.abspath will broke Windows path

Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
@kostyanf14 kostyanf14 requested a review from menli820 November 20, 2025 09:54
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @kostyanf14, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to the hw_submission_automation.py script by adding a new submission_info command. This command empowers users to query and retrieve comprehensive details about specific hardware submissions. It supports flexible input mechanisms, allowing submission identifiers to be specified directly or sourced from a JSON configuration file, and outputs the structured information into a new JSON file for easy consumption and further processing. This addition streamlines the process of monitoring and managing hardware submission statuses.

Highlights

  • New submission_info Command: A new command-line action submission_info has been added to the hw_submission_automation.py script.
  • Submission Information Retrieval: This command allows users to fetch detailed information about a specific hardware submission using its product_id and submission_id.
  • Flexible Input Options: The product_id and submission_id can be provided either directly via command-line arguments or loaded from an input_json file.
  • JSON Output: The retrieved submission information is parsed and saved into a structured JSON file, with an optional --output_file argument to specify the output path.
  • Cygwin Path Handling Improvement: A minor adjustment was made in the wait_download function to prevent os.path.abspath from breaking Windows paths when the script runs in a Cygwin environment.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new submission_info command, which is a useful addition. The implementation is generally sound, but I've identified several areas for improvement to enhance code quality, maintainability, and user experience. My feedback includes suggestions to refactor duplicated code, correct function signatures for consistency, fix incorrect error messages, handle exceptions more specifically, and refactor repetitive code blocks. Addressing these points will make the new feature more robust and the overall codebase cleaner.

Comment thread hw_submission_automation/hw_submission_automation.py Outdated
Comment thread hw_submission_automation/hw_submission_automation.py Outdated
Comment thread hw_submission_automation/hw_submission_automation.py Outdated
Comment on lines +628 to +652
input_json_data = None
if args.input_json:
try:
with open(args.input_json, "r") as f:
input_json_data = json.load(f)
print(f"[INFO] Loaded input JSON data from {args.input_json}")
except Exception as e:
print(f"Error: Failed to load input JSON file '{args.input_json}': {e}")
sys.exit(1)

if not args.product_id:
if input_json_data and "product_id" in input_json_data:
args.product_id = input_json_data["product_id"]
else:
print("Error: --product_id is required for download action")
sys.exit(1)
if not args.submission_id:
if input_json_data and "submission_id" in input_json_data:
args.submission_id = input_json_data["submission_id"]
else:
print("Error: --submission_id is required for download action")
sys.exit(1)
if not args.output_file:
if input_json_data and "output_file" in input_json_data:
args.output_file = input_json_data["output_file"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This block of code for handling arguments from a JSON file is nearly identical to the one in main_wait_download. To reduce code duplication and improve maintainability, consider extracting this logic into a helper function. The helper could take args and a list of required arguments as parameters, and return the populated args object. This would make the code more DRY (Don't Repeat Yourself).

Comment on lines +634 to +636
except Exception as e:
print(f"Error: Failed to load input JSON file '{args.input_json}': {e}")
sys.exit(1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Catching a broad Exception is generally discouraged as it can hide unexpected errors. It's better to catch more specific exceptions that you expect to handle, such as FileNotFoundError and json.JSONDecodeError.

Suggested change
except Exception as e:
print(f"Error: Failed to load input JSON file '{args.input_json}': {e}")
sys.exit(1)
except (FileNotFoundError, json.JSONDecodeError) as e:
print(f"Error: Failed to load or parse input JSON file '{args.input_json}': {e}")
sys.exit(1)

Comment on lines +665 to +679
match = re.search(r"\s*commitStatus:\s*(\S+)", text_info)
if match:
results["commit_status"] = match.group(1)
match = re.search(r"\s*Name:\s*(\S+.*)", text_info)
if match:
results["name"] = match.group(1)
match = re.search(r"\s*type:\s*(\S+)", text_info)
if match:
results["type"] = match.group(1)
match = re.search(r"\s*> Step:\s*(\S+)", text_info)
if match:
results["step"] = match.group(1)
match = re.search(r"\s*> State:\s*(\S+)", text_info)
if match:
results["state"] = match.group(1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The code uses a series of re.search calls and if match: blocks to parse the text output. This pattern is repetitive. You could refactor this into a more data-driven approach by using a list of tuples, where each tuple contains the result key and the regex pattern. This would make the code more concise and easier to extend if more fields need to be parsed in the future.

Suggested change
match = re.search(r"\s*commitStatus:\s*(\S+)", text_info)
if match:
results["commit_status"] = match.group(1)
match = re.search(r"\s*Name:\s*(\S+.*)", text_info)
if match:
results["name"] = match.group(1)
match = re.search(r"\s*type:\s*(\S+)", text_info)
if match:
results["type"] = match.group(1)
match = re.search(r"\s*> Step:\s*(\S+)", text_info)
if match:
results["step"] = match.group(1)
match = re.search(r"\s*> State:\s*(\S+)", text_info)
if match:
results["state"] = match.group(1)
parsing_rules = [
("commit_status", r"\s*commitStatus:\s*(\S+)"),
("name", r"\s*Name:\s*(\S+.*)"),
("type", r"\s*type:\s*(\S+)"),
("step", r"\s*> Step:\s*(\S+)"),
("state", r"\s*> State:\s*(\S+)"),
]
for key, pattern in parsing_rules:
match = re.search(pattern, text_info)
if match:
results[key] = match.group(1)

Comment thread hw_submission_automation/hw_submission_automation.py Outdated
Comment thread hw_submission_automation/hw_submission_automation.py Outdated
@kostyanf14 kostyanf14 force-pushed the info_cmd branch 2 times, most recently from 2e88056 to d510c3e Compare November 20, 2025 10:00
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
@menli820
Copy link
Copy Markdown
Collaborator

menli820 commented Nov 24, 2025

LGTM

test with:

python3 hw_submission_automation.py submission_info --product_id=13897625692316071 --submission_id=1152921505700117129

{
"product_id": "13897625692316071",
"submission_id": "1152921505700117129",
"commit_status": "commitComplete",
"name": "test_blk",
"type": "initial",
"step": "finalizeIngestion",
"state": "completed"
}

@kostyanf14 kostyanf14 merged commit cad9be7 into cross.1.2025.326.1 Dec 1, 2025
1 check passed
@kostyanf14 kostyanf14 deleted the info_cmd branch December 1, 2025 14:35
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