8000 feat(rod): extract requested resources from work units using domain resources adapter by janzak-dev · Pull Request #407 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

feat(rod): extract requested resources from work units using domain resources adapter - #407

Merged
janzak-dev merged 20 commits into
mainfrom
feat/rod-pr-8-1b-resource-accumulator
Aug 10, 2026
Merged

janzak-dev merged 20 commits into
mainfrom
feat/rod-pr-8-1b-resource-accumulator

Conversation

@janzak-dev
@janzak-dev janzak-dev commented Aug 10, 2026 •
Copy link
Copy Markdown
Collaborator

Summary

Adds requested resource extraction (extractRequestedResources) to cmd/rod_data_provider, populating the RequestedResources DTO field on DashboardJob protobufs.

It leverages the domain layer's workunit.GetWorkUnitResources to aggregate resources across job specs, replicas, sidecars, and init containers, converting ResourceSet messages into spb.Resource DTOs.

Key Changes

  • Resource Extraction DTO Adapter (cmd/rod_data_provider/resource_accumulator.go):
    • Implemented extractRequestedResources to convert domain ResourceSet objects from workunit.GetWorkUnitResources(wu) into presentation DTOs ([]*spb.Resource).
    • Added CPU millicore to core conversion (float64(millicores) / 1000.0), Memory bytes, GPU type counts, and TPU topology chip calculations (parseTotalChips).
    • Aggregates resource totals by type and returns a consolidated DTO list ([]*spb.Resource).
    • Kept helper functions modular and under 15 lines (accumulateResourceTotals, buildResourceDTOs, accumulateCpuResource, accumulateGpuResource, accumulateTpuResource, parseTotalChips).
  • DTO Mapping Integration (cmd/rod_data_provider/jobs.go): Populated RequestedResources: extractRequestedResources(wu) in mapWorkUnitToDashboardJob.
  • Unit Test Suite (cmd/rod_data_provider/resource_accumulator_test.go): Added a comprehensive table-driven test suite (TestExtractRequestedResources and TestParseTotalChips) covering CPU, Memory, GPU type fallbacks, TPU topology chip math (2x2x4 -> 32 chips), and nil/empty work units.
  • Dependencies (cmd/rod_data_provider/BUILD.bazel): Added "//internal/domain/workunit" to :rod_data_provider_lib.

Verification

  • Bazel Unit Tests: bazel test //internal/storage/spanner/workunit:workunit_unit_test //cmd/rod_data_provider/... — PASSED 100% (6 of 6 targets).
  • Linters: golangci-lint and buildifier — PASSED.

Screenshot

image TAG=agy

@github-actions
github-actions Bot requested a review from VLukiantsev August 10, 2026 08:12
@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

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 resourceAccumulator utility and corresponding tests to extract and aggregate requested resources (CPU, memory, GPU, and TPU) from Kubernetes jobs within a work unit. It also integrates this utility into jobs.go to populate the RequestedResources field. The review feedback highlights a critical issue where the accumulator currently ignores the replica count of each job. The reviewer suggests updating the accumulator helper methods to accept a replica multiplier, adjusting the job resource accumulation logic accordingly, and updating the unit tests to reflect these changes.

@janzak-dev
janzak-dev removed the request for review from VLukiantsev August 10, 2026 08:14
@janzak-dev
janzak-dev marked this pull request as draft August 10, 2026 08:14
@janzak-dev
janzak-dev force-pushed the feat/rod-pr-8-1b-resource-accumulator branch 3 times, most recently from 5a3a24c to 6ada843 Compare August 10, 2026 08:39
@janzak-dev janzak-dev changed the title feat(rod): extract resourceAccumulator to separate file and implement requested_resources mapping refactor(rod): replace custom resource accumulator with domain workunit.GetWorkUnitResources Aug 10, 2026
@janzak-dev janzak-dev added the priority::2-high top of mind. should not wait. label Aug 10, 2026
@janzak-dev janzak-dev changed the title refactor(rod): replace custom resource accumulator with domain workunit.GetWorkUnitResources feat(rod): extract requested resources from work units using domain resources adapter Aug 10, 2026
@janzak-dev
janzak-dev force-pushed the feat/rod-pr-8-1b-resource-accumulator branch 2 times, most recently from c744491 to f7a2dcd Compare August 10, 2026 10:12
@janzak-dev
janzak-dev force-pushed the feat/rod-pr-8-1-mocks-and-dto branch from 0403849 to 9e57844 Compare August 10, 2026 10:28
@janzak-dev
janzak-dev force-pushed the feat/rod-pr-8-1b-resource-accumulator branch from d7e2cc0 to 185ac8a Compare August 10, 2026 10:29
@janzak-dev
janzak-dev force-pushed the feat/rod-pr-8-1-mocks-and-dto branch from 405c7c7 to fddfe0b Compare August 10, 2026 11:04
@janzak-dev
janzak-dev force-pushed the feat/rod-pr-8-1b-resource-accumulator branch from 119b36b to d37df4f Compare August 10, 2026 11:04
Base automatically changed from feat/rod-pr-8-1-mocks-and-dto to main August 10, 2026 11:38
- Implement QueueJobResourcesPipe to map DashboardJob.requestedResources to ResourceChipData array (CPU cores, memory bytes PB/GB, GPU/TPU accelerators).
- Add Resources column to QueueJobsTable standalone component, template, and SCSS layout.
- Update QueueJobsTableHarness, queue_jobs_pipes_test.ts, and queue_jobs_table_test.ts.

TAG=agy
TAG=agy
CONV=6109e3eb-6351-4dc2-a259-9440069fd8ea
…ce[]

- Change QueueJobResourcesPipe.transform signature to accept strictly resources?: Resource[] | null.
- Update template binding in queue_jobs_table.ng.html to pass job.requestedResources | queueJobResources.
- Update unit tests in queue_jobs_pipes_test.ts.

TAG=agy
CONV=6109e3eb-6351-4dc2-a259-9440069fd8ea
@janzak-dev
janzak-dev force-pushed the feat/rod-pr-8-1b-resource-accumulator branch from cab7c62 to 5c0f73d Compare August 10, 2026 11:42
@janzak-dev
janzak-dev marked this pull request as ready for review August 10, 2026 12:26
@github-actions
github-actions Bot requested a review from pachopepe August 10, 2026 12:27
@janzak-dev
janzak-dev requested review from VLukiantsev and removed request for pachopepe August 10, 2026 12:27
@VLukiantsev VLukiantsev left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review item #1

@VLukiantsev VLukiantsev left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review item #2

@VLukiantsev VLukiantsev left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review item #5

@VLukiantsev VLukiantsev left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review item #6

@VLukiantsev VLukiantsev left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review item #7

@VLukiantsev VLukiantsev left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review item #8

Comment thread cmd/rod_data_provider/jobs_test.go Resolved
@VLukiantsev VLukiantsev left a comment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for working on this! Overall the feature implementation is clean and well-structured. I have posted inline feedback items regarding named return values, simplifying closure indirection, handling TPU resource types in the UI, ensuring TotalQueueSize accuracy, and expanding unit test coverage.

Comment thread cmd/rod_data_provider/jobs.go Resolved
Comment thread cmd/rod_data_provider/jobs_test.go Resolved
@janzak-dev
janzak-dev requested a review from VLukiantsev August 10, 2026 13:41
@janzak-dev
janzak-dev enabled auto-merge August 10, 2026 13:56
@janzak-dev
janzak-dev added this pull request to the merge queue Aug 10, 2026
Merged via the queue into main with commit 55aa186 Aug 10, 2026
15 checks passed
@janzak-dev
janzak-dev deleted the feat/rod-pr-8-1b-resource-accumulator branch August 10, 2026 14:12
AntonTyb pushed a commit that referenced this pull request Aug 11, 2026
…esources adapter (#407)

* refactor(rod): populate requested_resources, shorten functions, add ctx checks, and expand unit test coverage

* refactor(rod): extractRequestedResourcesFromSpec directly operates on ExecutableSpec.resources

* refactor(rod): simplify extractRequestedResources to read directly from ResourceSet without job loop or replica multiplier

* refactor(rod): use type switch on ResourceSet.resources in extractRequestedResources

* refactor(rod): use GPU and TPU as default resource type strings

* refactor(rod): aggregate resources across all jobs in jobset without replica multiplier

* refactor(rod): extract resourceAccumulator struct with dedicated helper methods and unit tests

* refactor(rod): refactor jobs_test.go to use proto.Modify and baseline fixtures

* feat(rod): extract resourceAccumulator to separate file and test suite

* refactor(rod): replace custom resourceAccumulator with domain workunit.GetWorkUnitResources adapter

* fix(rod): parse TPU topology dimensions to calculate total TPU chips count

* test(rod): add unit tests for TPU resource extraction and topology chip calculation

* refactor(rod): decompose extractRequestedResources under 15 lines and expand table-driven test suite

* feat(rod): render Resources column in Angular UI for ROD jobs table

- Implement QueueJobResourcesPipe to map DashboardJob.requestedResources to ResourceChipData array (CPU cores, memory bytes PB/GB, GPU/TPU accelerators).
- Add Resources column to QueueJobsTable standalone component, template, and SCSS layout.
- Update QueueJobsTableHarness, queue_jobs_pipes_test.ts, and queue_jobs_table_test.ts.

TAG=agy

* refactor(ui): simplify resource formatting logic in queue jobs table

TAG=agy
CONV=6109e3eb-6351-4dc2-a259-9440069fd8ea

* refactor(ui): restrict QueueJobResourcesPipe input strictly to Resource[]

- Change QueueJobResourcesPipe.transform signature to accept strictly resources?: Resource[] | null.
- Update template binding in queue_jobs_table.ng.html to pass job.requestedResources | queueJobResources.
- Update unit tests in queue_jobs_pipes_test.ts.

TAG=agy
CONV=6109e3eb-6351-4dc2-a259-9440069fd8ea

* refactor(rod): sync jobs.go and jobs_test.go with domain workunit.GetWorkUnitResources adapter

* refactor(rod): format accelerators as ${count} x ${type}, normalize TPU topology parsing, and pre-allocate map capacity

* refactor(rod): extract resource type string literals into constants

* refactor(rod): address PR 407 review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority::2-high top of mind. should not wait.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0