Skip to content

Remove the transitional Job.compute_profile string field (step 1) - #2466

Draft
Elena Peña Tapia (ElePT) wants to merge 1 commit into
mainfrom
remove-job-compute-profile-string
Draft

Remove the transitional Job.compute_profile string field (step 1)#2466
Elena Peña Tapia (ElePT) wants to merge 1 commit into
mainfrom
remove-job-compute-profile-string

Conversation

@ElePT

@ElePT Elena Peña Tapia (ElePT) commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Important

BLOCKED — needs a change from the billing team before this can merge.

The Kafka usage-event path builds the classical metric type from
job.compute_profile (the string this PR removes):
_build_classical_metric_type in
gateway/core/ibm_cloud/event_streams/kafka_event_streams_client.py.
That file is owned by another team, so this PR deliberately does not touch it.

Before this removal can merge, the billing team needs to repoint that method:

# gateway/core/ibm_cloud/event_streams/kafka_event_streams_client.py
-        if job.compute_profile:
-            parts.append(job.compute_profile)
+        compute_profile = job.compute_profile_id          # FK-backed, added in this PR
+        if compute_profile:
+            parts.append(compute_profile)

Job.compute_profile_id (added here) returns compute_profile_fk.compute_profile_id
(or None), which equals the old string wherever it was set — so the emitted
metric type is unchanged. Until that lands, merging this PR would raise
AttributeError when a usage event is built. The corresponding test
(tests/core/services/ibm_cloud/event_streams/test_event_streams_client.py) is
also left for them to update alongside their change.

Summary

Removes the transitional Job.compute_profile string field. It was introduced
alongside the t-shirt sizes work as a stopgap and superseded by Job.compute_profile_fk
(FK → ComputeProfile), which is the source of truth for the profile a job ran on. The two
were written together on every run and always agreed at creation; this PR retires the string.

This is Step 1 of a two-step removal that keeps every deployed release safe to roll back —
the same pattern used to drop Program.default_compute_profile (#2420#2421):

  • This PR (Step 1): repoint every reader to the FK, then remove the field from Django's
    model state only — the api_job.compute_profile column is left in the database, so
    the previous release (whose Job model still declares the field and lists it in every
    SELECT) stays deployable.
  • Step 2 (separate later PR): the real DROP COLUMN, once no release that still declares
    the field can be deployed.

What changed

Readers repointed to the FK. A new null-safe Job.compute_profile_id property returns
compute_profile_fk.compute_profile_id (or None for Ray / historical rows), preserving the
existing … or settings.DEFAULT_COMPUTE_PROFILE fallback everywhere. Repointed:

  • Fleet-name construction and resource-limit parsing — core/services/runners/fleets_runner.py
  • Admin job timeline — api/domain/job_timeline.py (+ select_related("compute_profile_fk")
    on the two timeline querysets in api/admin.py to avoid an N+1)

The billing/Kafka reader is intentionally not repointed here — see the blocked note above.

Writers. The string is no longer written on the run path (api/use_cases/programs/run.py)
or the filler-jobs path (scheduler/tasks/balance_filler_jobs.py); both already set
compute_profile_fk.

API shape. compute_profile (string) is dropped from the job serializers; compute_profile_fk
(nested ComputeProfileSerializer, already present on the list/retrieve responses) carries the
profile. Client Job loses its compute_profile attribute.

Admin. The compute_profile field is removed from the JobAdmin "Fleets" fieldset
(compute_profile_fk stays).

Migration. 0064_remove_job_compute_profile_state.py — a state-only RemoveField wrapped in
SeparateDatabaseAndState (empty database_operations), mirroring 0057. Its comment also
records the billing-team dependency above.

Out of scope

  • The real DROP COLUMN (Step 2, follow-up PR).
  • The billing/Kafka reader and its test (another team — the blocked note above is their action).
  • The deprecated compute_profile run input kwarg on function.run(...) / the run
    InputSerializer — a separate surface, retired separately. function_size is the replacement.

Notes

Opened as draft for review.

Job.compute_profile (string) was a stopgap superseded by compute_profile_fk
(FK -> ComputeProfile), the source of truth for the profile a job ran on. The
two were written together and always agreed at creation; this retires the string.

Step 1 of a two-step removal (mirrors Program.default_compute_profile, #2420 ->
#2421): repoint readers to the FK via a new null-safe Job.compute_profile_id
property, then remove the field from Django's model STATE only. The DB column is
left in place so the previous release stays deployable; the real DROP COLUMN
ships in a later PR once no field-declaring release can deploy.

- Readers repointed to compute_profile_id: fleet name + resource limits
  (fleets_runner), admin job timeline (+ select_related to avoid an N+1).
- Writers: run path and filler-jobs path no longer write the string (both
  already set compute_profile_fk).
- API: compute_profile dropped from job serializers; compute_profile_fk (already
  present) carries the profile. Client Job loses its compute_profile attribute.
- Admin: field removed from the JobAdmin Fleets fieldset.
- Migration 0064: state-only RemoveField wrapped in SeparateDatabaseAndState.

BLOCKED on the billing team: the Kafka usage-event path
(_build_classical_metric_type in kafka_event_streams_client.py) still reads
job.compute_profile and is owned by another team, so it is deliberately left
untouched here. They must repoint it to job.compute_profile_fk.compute_profile_id
before this removal can merge; until then the model state change would break
their event build.

Out of scope: the DROP COLUMN (step 2) and the deprecated compute_profile run
input kwarg (use function_size).
@ElePT
Elena Peña Tapia (ElePT) force-pushed the remove-job-compute-profile-string branch from a9583e3 to ad04f50 Compare September 4, 2026 12:15
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.

1 participant