Skip to content

feat: implement RayJob drawer Details tab (RHOAIENG-49276)#6693

Open
dpanshug wants to merge 2 commits intoopendatahub-io:mainfrom
dpanshug:ray-job-details-drawer
Open

feat: implement RayJob drawer Details tab (RHOAIENG-49276)#6693
dpanshug wants to merge 2 commits intoopendatahub-io:mainfrom
dpanshug:ray-job-details-drawer

Conversation

@dpanshug
Copy link
Contributor

@dpanshug dpanshug commented Mar 12, 2026

RHOAIENG-49276

Description

Screenshot 2026-03-12 at 10 55 21 AM

How Has This Been Tested?

Check the ray jobs drawer.

Test Impact

Added cypress test

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)
  • The code follows our Best Practices (React coding standards, PatternFly usage, performance considerations)

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

@tobiastal

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Ray Job Details tab displaying key job information including ray version, cluster name, shutdown policy, entrypoint command, and submission mode for better visibility into job configurations.
  • Tests

    • Expanded test coverage for Ray Job details and cluster resource handling with comprehensive mocking and integration tests.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 12, 2026

[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 lucferbux for approval. For more information see the Code Review Process.

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

Details 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2026

📝 Walkthrough

Walkthrough

This PR introduces UI and API support for Ray job details display. It adds a new RayJobDetailsTab component rendering job summary (with Ray version), executions (entrypoint and submission mode), and management sections (shutdown policy and cluster name). Supporting infrastructure includes a getRayCluster API function, a useRayClusterSpec hook that fetches or uses inline cluster specs, a mockRayClusterK8sResource factory, and updates to mockRayJobK8sResource to support rayVersion, shutdownAfterJobFinishes, and clusterSelector fields. Test coverage validates hook behavior and component rendering with mocked data.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes


Security & Implementation Review Points

Clipboard API handling: The copy-to-clipboard implementation in RayJobDetailsTab requires verification. Ensure it uses the modern Clipboard API with proper error handling rather than deprecated document.execCommand(), which can fail silently and create UX/security gaps. Validate that copied content doesn't expose sensitive values unintentionally.

Async error boundaries: The useRayClusterSpec hook's NotReadyError handling and useFetch integration need validation. Confirm error propagation doesn't silently fail—callers must handle the error field. If this feeds into UI rendering, unhandled promise rejections could trigger Unhandled Promise Rejection (related to CWE-391).

clusterSelector propagation: The mockRayJobK8sResource now conditionally includes clusterSelector vs. rayClusterSpec. Verify the actual component and API correctly handle both paths—mixing inline specs with cluster selectors could cause undefined behavior if both are present or neither is present.

Fetch error state: The hook returns loaded: true when "no workspace cluster" exists. Clarify the contract: does this mean the component should treat absence of clusterSpec as success rather than failure? This logic path needs explicit testing to avoid silent failures.

Test data assumptions: Mock tests increase row counts (4→6, 5→7) based on new RayJob entries. Verify filters/sorting logic still functions correctly with the expanded dataset—filtering bugs can emerge at boundaries.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main feature being implemented: a RayJob drawer Details tab, with a specific issue reference.
Description check ✅ Passed Description includes issue reference, screenshot, testing approach, and completed checklist items covering manual testing, test addition, and code standards.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@dpanshug dpanshug changed the title ray version feat: implement RayJob drawer Details tab (RHOAIENG-49276) Mar 12, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/model-training/src/__mocks__/mockRayJobK8sResource.ts`:
- Line 27: The mock factory in mockRayJobK8sResource currently defaults
status.rayClusterName to `${name}-raycluster` even when clusterSelector is
provided; update the factory that builds the mock (mockRayJobK8sResource / the
workspace-cluster mock block) so that if clusterSelector is present and no
explicit rayClusterName is provided, you derive status.rayClusterName from
clusterSelector (for example use the selected cluster name from clusterSelector,
e.g. clusterSelector["ray.ibm.com/cluster"] or equivalent key used in your code)
instead of `${name}-raycluster`; ensure you apply this change wherever
rayClusterName is set (references to status.rayClusterName, rayClusterName,
clusterSelector) including the other instances noted (lines ~53 and ~119-126).

In `@packages/model-training/src/global/rayJobDetailsDrawer/RayJobDetailsTab.tsx`:
- Around line 35-40: The handleCopy callback should await
navigator.clipboard.writeText and handle rejections: update handleCopy to be
async, wrap the await navigator.clipboard.writeText(job.spec.entrypoint) in a
try/catch, call setCopied(true) only after a successful await, and handle errors
in the catch (e.g., setCopied(false) and log or surface the error) to avoid
unhandled promise rejections; references: handleCopy, job.spec.entrypoint, and
setCopied.

In `@packages/model-training/src/hooks/useRayVersion.ts`:
- Around line 12-18: The hook fails to reset derived state when the job changes,
causing stale fetchedVersion or a stuck loaded; update the relevant
React.useEffect blocks in useRayVersion to depend on the job (or a stable job
identifier) and reset state before starting a new fetch by calling
setFetchedVersion(undefined) and setLoaded(!!inlineVersion ||
!workspaceClusterName) (and also ensure pending fetches are cancelled/ignored in
the fetchRayVersion flow); apply the same reset logic to the other affected
effects (the ones around lines showing initialization and the fetch completion
handlers) so fetchedVersion and loaded are reinitialized whenever the
job/workspaceClusterName/inlineVersion context changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: facb4627-e93d-4165-899d-589dd1812148

📥 Commits

Reviewing files that changed from the base of the PR and between c6b29d4 and 8e3abe5.

📒 Files selected for processing (7)
  • packages/cypress/cypress/pages/modelTraining.ts
  • packages/cypress/cypress/tests/mocked/modelTraining/modelTrainingRayJobs.cy.ts
  • packages/model-training/src/__mocks__/mockRayClusterK8sResource.ts
  • packages/model-training/src/__mocks__/mockRayJobK8sResource.ts
  • packages/model-training/src/global/rayJobDetailsDrawer/RayJobDetailsDrawer.tsx
  • packages/model-training/src/global/rayJobDetailsDrawer/RayJobDetailsTab.tsx
  • packages/model-training/src/hooks/useRayVersion.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/model-training/src/api/rayClusters.ts`:
- Around line 8-12: getRayCluster currently returns the k8sGetResource result
typed as RayClusterKind but lacks runtime validation, so malformed payloads can
reach useRayClusterSpec and the drawer; add a runtime guard in getRayCluster
that checks required fields (e.g., spec, metadata,
spec.headGroupSpec/workerGroupSpecs as applicable) on the fetched object and
reject (throw or return a rejected Promise) if missing or invalid, using the
RayClusterKind/RayClusterModel types to guide which properties to validate and
ensure callers only receive validated RayClusterKind instances.

In `@packages/model-training/src/hooks/__tests__/useRayClusterSpec.spec.ts`:
- Around line 111-124: The test is hitting the inline-spec path because
mockRayJobK8sResource injects spec.rayClusterSpec by default; update the test to
construct a job that truly lacks rayClusterSpec (so the "no inline spec" branch
is exercised). Modify the test to call mockRayJobK8sResource with an override
that removes or sets rayClusterSpec to undefined (or use a dedicated factory
helper) so the job returned has no spec.rayClusterSpec, then keep the existing
assertions against useRayClusterSpec (and mocked useFetch via useFetchMock) to
verify loaded === true and clusterSpec is defined from the no-selector path.

In `@packages/model-training/src/hooks/useRayClusterSpec.ts`:
- Around line 17-35: The hook returns a stale error when it short-circuits;
update useRayClusterSpec so that the returned error is cleared whenever the hook
is not actively fetching (i.e., when inlineSpec is present or
workspaceClusterName is falsy). Concretely, keep using the useFetch result
(fetchedCluster, fetchLoaded, error) but change the returned error to be
masked/reset when short-circuited (reference inlineSpec, workspaceClusterName,
fetchedCluster, fetchLoaded, and error) so the hook returns undefined (or null)
for error unless the fetch path is actually active.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 9caf0f3a-4a0c-4cfd-958c-f7f296090d78

📥 Commits

Reviewing files that changed from the base of the PR and between 8e3abe5 and cf47678.

📒 Files selected for processing (6)
  • packages/model-training/src/__mocks__/mockRayJobK8sResource.ts
  • packages/model-training/src/api/__tests__/rayClusters.spec.ts
  • packages/model-training/src/api/rayClusters.ts
  • packages/model-training/src/global/rayJobDetailsDrawer/RayJobDetailsTab.tsx
  • packages/model-training/src/hooks/__tests__/useRayClusterSpec.spec.ts
  • packages/model-training/src/hooks/useRayClusterSpec.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/model-training/src/api/tests/rayClusters.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/model-training/src/global/rayJobDetailsDrawer/RayJobDetailsTab.tsx

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 77.24551% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.00%. Comparing base (ba87395) to head (cf47678).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rc/global/rayJobDetailsDrawer/RayJobDetailsTab.tsx 79.36% 26 Missing ⚠️
...ages/model-training/src/hooks/useRayClusterSpec.ts 72.72% 9 Missing ⚠️
packages/model-training/src/api/rayClusters.ts 66.66% 2 Missing ⚠️
...global/rayJobDetailsDrawer/RayJobDetailsDrawer.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6693      +/-   ##
==========================================
- Coverage   64.02%   64.00%   -0.03%     
==========================================
  Files        2499     2504       +5     
  Lines       75200    75535     +335     
  Branches    18956    19028      +72     
==========================================
+ Hits        48149    48346     +197     
- Misses      27051    27189     +138     
Files with missing lines Coverage Δ
...global/rayJobDetailsDrawer/RayJobDetailsDrawer.tsx 74.38% <50.00%> (-1.03%) ⬇️
packages/model-training/src/api/rayClusters.ts 36.36% <66.66%> (+17.61%) ⬆️
...ages/model-training/src/hooks/useRayClusterSpec.ts 72.72% <72.72%> (ø)
...rc/global/rayJobDetailsDrawer/RayJobDetailsTab.tsx 79.36% <79.36%> (ø)

... and 22 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 c6b29d4...cf47678. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant