Skip to content

Adopt upstream sizing logic from ComputeManager - #26

Merged
dotsdl merged 4 commits into
mainfrom
autoscaling-sizing-upstream
Jun 9, 2026
Merged

dotsdl merged 4 commits into
mainfrom
autoscaling-sizing-upstream

Conversation

@dotsdl

@dotsdl dotsdl commented May 4, 2026

Copy link
Copy Markdown
Member

Draft until OpenFreeEnergy/alchemiscale#502 merges. This PR depends on the new _compute_jobs_to_create method and max_submit_per_cycle field added there.

Summary

Drops the inline sizing math from K8SManager.create_compute_services in favor of the upstream _compute_jobs_to_create method on alchemiscale.compute.manager.ComputeManager. Same formula (min(num_tasks, max_submit_per_cycle, remaining_capacity) // claim_limit with floor-to-1), one source of truth.

Changes

K8SManager.create_compute_services signature: (data) -> int(data, target) -> int. The local block computing jobs_to_create is removed; the cycle now passes target as a kwarg. The backend-specific jobs_pending() gate stays (and becomes the early-return guard, simplifying the control flow).

K8SManagerSettings.job_creation_rate is deprecated. The upstream ComputeManagerSettings now provides max_submit_per_cycle for the same purpose. A model_validator(mode="before") accepts the old name on input, emits a DeprecationWarning, and migrates the value to max_submit_per_cycle. Configs that set both names use the new one and warn that the old one is ignored.

This means existing K8s deployments keep working with their current YAML configs — they just see a warning until they rename the field.

Tests

New tests/test_settings.py:

  • test_max_submit_per_cycle_default_inherited — without specifying anything, we get the upstream default of 1
  • test_max_submit_per_cycle_explicit — explicit override works
  • test_job_creation_rate_migrated_with_warning — old configs continue to work but emit DeprecationWarning
  • test_job_creation_rate_ignored_when_new_name_also_set — when both are set, new name wins
  • test_job_creation_rate_no_longer_a_fieldmodel_fields no longer contains the deprecated name

5/5 pass against the alchemiscale#502 branch. Note: existing tests/test_compute_manager.py was a stub (raise NotImplementedError) before this PR and remains so — out of scope here.

Test plan

🤖 Generated with Claude Code

Drops the inline jobs_to_create math from K8SManager.create_compute_services
in favor of the upstream _compute_jobs_to_create method on
alchemiscale.compute.manager.ComputeManager (added in
OpenFreeEnergy/alchemiscale#502).

Changes
-------

* K8SManager.create_compute_services signature is now
  (data, target) -> int. The local sizing block (min(num_tasks,
  job_creation_rate, max - len(server_job_names)) // claim_limit, with
  floor-to-1) is removed; the cycle now passes target as a kwarg.

* K8SManagerSettings.job_creation_rate is deprecated. The upstream
  ComputeManagerSettings now provides max_submit_per_cycle for the same
  purpose. A model_validator(mode="before") accepts the old name on
  input, emits a DeprecationWarning, and migrates the value to
  max_submit_per_cycle. Configs that set both names use the new name and
  warn that the old one is ignored.

Tests
-----

* New tests/test_settings.py covers the deprecated-alias migration:
  default-inherited, explicit max_submit_per_cycle, old-name warns and
  migrates, both-set warns and prefers new name, old name is no longer
  a real field.

Depends on
----------

* OpenFreeEnergy/alchemiscale#502 (must merge first; this PR will not
  pass tests until the upstream max_submit_per_cycle field is available).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dotsdl
dotsdl marked this pull request as ready for review June 8, 2026 21:06
dotsdl and others added 3 commits June 8, 2026 15:26
Sets up the conda env, overlays alchemiscale from git main (until #502 is
on a conda-forge release), installs the package, and runs the test suite.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use a dedicated devtools/conda-envs/test.yml listing alchemiscale's runtime
deps explicitly (the conda-forge alchemiscale-compute build solved in CI
lacked diskcache), and ignore the unimplemented test_compute_manager stub.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the hand-listed deps with the full OpenFreeEnergy/alchemiscale
devtools/conda-envs/test.yml (main), plus python-kubernetes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@dotsdl dotsdl left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm happy with this! Merging!

@dotsdl
dotsdl merged commit d323f8f into main Jun 9, 2026
3 checks passed
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