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

Validation for model names and disabled NIM metrics hyperlink #3314

Merged

Conversation

olavtar
Copy link
Contributor

@olavtar olavtar commented Oct 8, 2024

https://issues.redhat.com/browse/RHOAIENG-13881
https://issues.redhat.com/browse/RHOAIENG-14044

Description

Added validation for model names and disabled the NIM models metrics hyperlink on the Models tab

How Has This Been Tested?

Tested locally.

Test Impact

Tested functionality: Verified that KServe still displays the metrics link.
NIM validation: Confirmed that NIM does not display the metrics link.

Request review criteria:

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)

If you have UI changes:

  • Included any necessary screenshots or gifs if it was a UI change.
  • Included tags to the UX team if it was a UI/UX change.

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

@openshift-ci openshift-ci bot requested review from pnaik1 and ppadti October 8, 2024 21:03
@openshift-ci openshift-ci bot added the needs-ok-to-test The openshift bot needs to label PRs from non members to avoid strain on the CI label Oct 8, 2024
Copy link
Contributor

openshift-ci bot commented Oct 8, 2024

Hi @olavtar. Thanks for your PR.

I'm waiting for a opendatahub-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.04%. Comparing base (6ec1b1b) to head (0169afc).
Report is 40 commits behind head on main.

Files with missing lines Patch % Lines
...projects/NIMServiceModal/DeployNIMServiceModal.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3314      +/-   ##
==========================================
+ Coverage   84.79%   85.04%   +0.25%     
==========================================
  Files        1315     1329      +14     
  Lines       29491    29927     +436     
  Branches     8056     8197     +141     
==========================================
+ Hits        25006    25451     +445     
+ Misses       4485     4476       -9     
Files with missing lines Coverage Δ
...erving/screens/global/InferenceServiceTableRow.tsx 97.29% <100.00%> (+2.29%) ⬆️
...projects/NIMServiceModal/DeployNIMServiceModal.tsx 4.85% <0.00%> (ø)

... and 143 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 6ec1b1b...0169afc. Read the comment docs.

@andrewballantyne
Copy link
Member

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test The openshift bot needs `ok-to-test` to allow non member PRs to run the tests. and removed needs-ok-to-test The openshift bot needs to label PRs from non members to avoid strain on the CI labels Oct 11, 2024
</FormGroup>
);
const ProjectSection: React.FC<ProjectSectionType> = ({ projectName }) => {
const [translatedName] = translateDisplayNameForK8sAndReport(projectName);
Copy link
Member

Choose a reason for hiding this comment

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

The project is not the problem -- it's the name used for the inference service and/or servingruntime, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

>
{displayName}
</Link>
) : kserveMetricsSupported ? (
Copy link
Member

Choose a reason for hiding this comment

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

Curious why you didn't just update the kserveMetricsSupported to include "not NIM"?

Although this code block we have looks very weird lol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did in the beginning but then I saw that modelMeshMetricsSupported and kserveMetricsSupported had duplicated logic, so I chose to add the isKServeNIMEnabled check separately for clarity and to make the logic explicit. I can update the kserveMetricsSupported to handle the "not NIM" case if you think it would make it cleaner.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I noticed that -- the more you change the longer it takes for me to verify and approve. I'll try to get this before my PTO -- but typically stay short and to the point unless the logic is not compatible. Every cleanup you do for us has me testing more to make sure we don't have some other brittle aspect that can slip out in non NIM ways. In the end it's likely a net positive, just expressing how I look at everything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @olavtar pardon me cause I don't have all the context, but shouldn't this produce the same result?

        <ResourceNameTooltip resource={inferenceService}>
          {modelMeshMetricsSupported || kserveMetricsSupported ? (
            <Link
              data-testid={`metrics-link-${displayName}`}
              to={
                isGlobal
                  ? `/modelServing/${inferenceService.metadata.namespace}/metrics/${inferenceService.metadata.name}`
                  : `/projects/${inferenceService.metadata.namespace}/metrics/model/${inferenceService.metadata.name}`
              }
            >
              {displayName}
            </Link>
          ) : (
            displayName
          )}
        </ResourceNameTooltip>

There's value on refactoring duplicate code, but how NIM is going to affect this component if the fallback is the same as having the feature selected? Maybe for readability, but in case we wanna add later metrics, we can add a comment explaining that nim will be enabled when we support metrics.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @lucferbux, the isKServeNIMEnabled check is important because we don’t want to show a link when NIM Metrics isn't enabled, even if other metrics conditions are met. So, removing this condition would change the behavior, as it would allow the link to be displayed when NIM Metrics are not enabled, which is not the intended outcome.

Copy link
Member

@andrewballantyne andrewballantyne Oct 22, 2024

Choose a reason for hiding this comment

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

Yeah we are going to definitely not want fix this logic and also just duplicate other logic.

Go with something like this:

const InferenceServiceTableRow: React.FC<InferenceServiceTableRowProps> = ({
  obj: inferenceService,
  servingRuntime,
  onDeleteInferenceService,
  onEditInferenceService,
  isGlobal,
  columnNames,
}) => {
  const { projects } = React.useContext(ProjectsContext);
  const project = projects.find(byName(inferenceService.metadata.namespace)) ?? null;

  const isKServeNIMEnabled = project ? isProjectNIMSupported(project) : false;

You'll have to move this logic to the top of the component to use it where we need it

  const [modelMetricsEnabled] = useModelMetricsEnabled();
  const kserveMetricsEnabled = useIsAreaAvailable(SupportedArea.K_SERVE_METRICS).status;

  const modelMesh = isModelMesh(inferenceService);
  const modelMeshMetricsSupported = modelMetricsEnabled && modelMesh;
  const kserveMetricsSupported = modelMetricsEnabled && kserveMetricsEnabled && !modelMesh && !isKServeNIMEnabled;

KServe Metrics are not supported when you're NIM -- flip this flag

  const displayName = getDisplayNameFromK8sResource(inferenceService);

  return (
    <>
      <Td dataLabel="Name">
        <ResourceNameTooltip resource={inferenceService}>
          {modelMeshMetricsSupported || kserveMetricsSupported ? (
            <Link
              data-testid={`metrics-link-${displayName}`}
              to={
                isGlobal
                  ? `/modelServing/${inferenceService.metadata.namespace}/metrics/${inferenceService.metadata.name}`
                  : `/projects/${inferenceService.metadata.namespace}/metrics/model/${inferenceService.metadata.name}`
              }
            >
              {displayName}
            </Link>
          ) : (
            displayName
          )}
        </ResourceNameTooltip>
      </Td>

Now it should be just straight forward -- if you have metrics -- show the link -- if not hide the link.

We could go one step further with a variable "hasMetrics" instead of the two checks being OR'ed -- but I don't think that's super needed imo (but won't hurt if you like it more).

@@ -19,6 +20,10 @@ const NIMModelDeploymentNameSection: React.FC<NIMModelDeploymentNameSectionProps
data-testid="model-deployment-name-section"
value={data.name}
onChange={(e, name) => setData('name', name)}
onBlur={() => {
const [translatedName] = translateDisplayNameForK8sAndReport(data.name);
setData('name', translatedName);
Copy link
Member

Choose a reason for hiding this comment

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

Would this not just convert the field for what the user typed? Can we not support this under the hood and then supply it at the end? We have a typical two named set in our world... display name & k8s name -- we don't want to lose the display name to have a clean k8s name... let me see if I can see what guidance I can provide more specifically to solve this.

Copy link
Member

Choose a reason for hiding this comment

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

Hah. funnily enough you're already doing this logic -- I imagine the logic here is not actually going to fix the aforementioned bug on the ticket; all numbers for a name.

What you need to do is this...

The logic behind translateDisplayNameForK8s does not take into account the full digit use-case without a suggested prefix to put before it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andrewballantyne This doesn't resolve the issue of allowing illegal characters. For example, if you enter the name "אקדא אעגכדע" (which contains no digits and includes a space), the problem persists.

Copy link
Member

@andrewballantyne andrewballantyne Oct 24, 2024

Choose a reason for hiding this comment

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

If you make a display name with those characters it should work fine 🤔 (or so I would think) -- k8s names cannot have it. Today we trim those out, which got you 12456 as a resulting resource name -- this had problems being just numbers -- this suggested solution should fix that.

What error are you getting? @olavtar

Copy link
Member

@andrewballantyne andrewballantyne Oct 24, 2024

Choose a reason for hiding this comment

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

This utility is used on the create project modal... this is the result of just using those Hebrew characters:
image

If we supply the nim- as the safeK8sPrefix, it would be that instead; it just updates the gen- to be the safeK8sPrefix instead if provided.
If you have valid k8s characters after that (like a number) you'll get those characters instead.
This generated value only happens if it is fully unaccepted k8s characters.

You can use the translateDisplayNameForK8sAndReport function if you want to see what happened and address the generated use-case differently (with say a static "nim-deployment" or something)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Copy link
Contributor

openshift-ci bot commented Oct 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne

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

The pull request process is described 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

@openshift-merge-bot openshift-merge-bot bot merged commit d9788f8 into opendatahub-io:main Oct 24, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test The openshift bot needs `ok-to-test` to allow non member PRs to run the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants