Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in proper handling of spaces and quotes in ISVC parsing #3592

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Xaenalt
Copy link
Member

@Xaenalt Xaenalt commented Dec 18, 2024

https://issues.redhat.com/browse/RHOAIENG-16900

Description

This adds a rudimentary parser that should handle most cases for inferenceservice argument parsing.

Note, I'm not a JS expert, and wrote it with the help of my internal AI, so it's possible there's some degerenate edge case with this, but in testing it worked fine

How Has This Been Tested?

Code used to test:
parseCommandLine.ts.txt
(Note it misbehaves a bit on some of the negative tests, but the normal test cases it works fine on)

Test Impact

Tested with the above tests, caveats noted

Request review criteria:

  • Someone with JS expertise looks this over to make sure it's sane

Self checklist (all need to be checked):

  • The developer has manually tested the changes and verified that the changes work
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has added tests or explained why testing cannot be added (unit or cypress tests for related changes)

After the PR is posted & before it merges:

  • The developer has tested their solution on a cluster by using the image produced by the PR to main

Copy link
Contributor

openshift-ci bot commented Dec 18, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign manosnoam for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Xaenalt Xaenalt force-pushed the dashboard-argparse-fix branch 2 times, most recently from 6c3ffe4 to 4732326 Compare December 18, 2024 17:38
This adds a rudimentary parser that should handle most cases for
inferenceservice argument parsing. Note, I'm not a JS expert, so
it's possible there's some degerenate edge case with this, but
in testing it worked fine
@Xaenalt Xaenalt force-pushed the dashboard-argparse-fix branch from 2163428 to 42b88b2 Compare December 18, 2024 18:11
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.18%. Comparing base (2ee880d) to head (42b88b2).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
frontend/src/api/k8s/utils.ts 81.81% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3592      +/-   ##
==========================================
+ Coverage   85.16%   85.18%   +0.01%     
==========================================
  Files        1392     1392              
  Lines       31856    31868      +12     
  Branches     8925     8927       +2     
==========================================
+ Hits        27130    27146      +16     
+ Misses       4726     4722       -4     
Files with missing lines Coverage Δ
frontend/src/api/k8s/inferenceServices.ts 96.70% <100.00%> (+0.03%) ⬆️
frontend/src/api/k8s/utils.ts 94.28% <81.81%> (-5.72%) ⬇️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ee880d...42b88b2. Read the comment docs.

const regex = /(?:[^\s"']+|"[^"]*"|'[^']*')+/g;
let match: RegExpExecArray | null;

while ((match = regex.exec(input)) !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking closer at this - what iterates this loop? does regex.exec(input) with the same input multiple times step to the next match? A quick glance at docs says yes - interesting, I haven't used it that way before.

I wonder if it would be simpler to use regex.match instead of regex.exec to just get back an array of all the matches, and then do a forEach or reduce on those? I'm nitpicking though, it's probably fine as-is.

Copy link
Member Author

@Xaenalt Xaenalt Dec 18, 2024

Choose a reason for hiding this comment

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

I'm fine with changing solution, that's just the one that it gave me

Copy link
Contributor

Choose a reason for hiding this comment

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

If it works it works, but I may tinker with an alternative when I have more time to review. Did you still plan on adding / have time to add unit tests here?

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