Skip to content

feat: Vultr bare-metal cost calculation with provider/machine-type overrides - #19

Open
alinzh wants to merge 3 commits into
masterfrom
feature/vultr-cost
Open

feat: Vultr bare-metal cost calculation with provider/machine-type overrides#19
alinzh wants to merge 3 commits into
masterfrom
feature/vultr-cost

Conversation

@alinzh

@alinzh alinzh commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements Vultr cost calculation (including bare-metal plans) for AiiDA reports. Previously, cost was hardcoded to Hetzner (provider="hetzner"); Vultr rates existed in pricing.py but were never used.

What changed

Pricing (pricing.py):

  • Added Vultr bare-metal plans (vbm-24c-256gb-amd $0.993/h, vbm-8c-132gb-v2 $0.479/h, and 7 more) — prices from Vultr API
  • detect_provider() now recognizes the vbm token
  • read_provider_and_machine_type_from_config() — reads provider and plan from /etc/yascheduler/yascheduler.conf
  • resolve_provider_and_rate() — single shared helper that validates provider+machine_type consistency (no cross-cloud mixing)
  • get_cloud_rate() uses longest-key-first matching (fixes amd vs amd5 collision)
  • Unknown provider/plan returns None instead of 0.0 (no silent "free" cost)
  • UpCloud recognised in config but has no pricing → rate/currency None, cost omitted
  • Removed dead code (duplicate lines after return in get_cloud_rate)

CLI (report_aiida_cli.py, report_cli.py):

  • --provider [hetzner|vultr_usa] — override cloud provider
  • --engine [crystal|fleur] — filter by engine (skips expensive FLEUR enrichment: Seebeck/displacement)
  • --machine-type TEXT — override machine plan (e.g. vbm-24c-256gb-amd)

Report fields (aiida/reporting.py, reporting.py):

  • hetzner_ratecloud_rate, cost_eurcost, added currency (EUR/USD)
  • Breaking: CSV column names changed
  • Cost columns omitted from CSV only when no rate can be determined (all-None auto-dropped)

Cost determination logic

Priority: --provider/--machine-type (CLI) → /etc/yascheduler/yascheduler.confdetect_provider(computer_name)None rate → omit

When no config is available, cost is still attempted via auto-detection from the AiiDA computer name. Cost columns are omitted only when no rate can be determined (e.g. unknown computer name or cross-provider mismatch).

Cross-provider mismatch (e.g. --provider vultr_usa --machine-type ccx13) → rate is None, cost omitted, warning logged.

Tests

81 tests (tests/test_pricing.py, tests/test_reporting_provider.py):

  • Bare-metal rates, amd5 vs amd substring matching
  • detect_provider (incl. vbm token), config read (all via tmp_path, no /etc/ dependency)
  • resolve_provider_and_rate: provider/machine_type override, cross-provider mismatch, auto-detect from computer name
  • Engine filter tests verify QueryBuilder.append() receives process_type filter
  • No-config auto-detect: vultr-ams-vc2-4c-8gb → USD/0.06 without config
  • Unknown plans/providers → None rate (not 0.0)

Verification

Verified on 92 CRYSTAL calcs (2026-06-01): Vultr bare-metal $996.34, Hetzner ccx13 €25.69, default config matches explicit flags.

Closes #17

alinzh added 3 commits August 4, 2026 21:41
…e overrides

- Add bare-metal plans (vbm-*) to CLOUD_PRICING from Vultr API
- Add detect_provider() vbm token, read_provider_and_machine_type_from_config()
- Add --provider, --engine, --machine-type CLI flags to dft-report-aiida/dft-report
- Rename hetzner_rate->cloud_rate, cost_eur->cost, add currency field
- provider+machine_type fallback: CLI flag -> /etc/yascheduler/yascheduler.conf -> skip
- When no provider info available (no flag, no config), cost columns are omitted from CSV
- --engine filter skips expensive FLEUR enrichment (Seebeck/displacement)
- Remove dead code in pricing.py (duplicate lines after return)
- 62 tests: bare-metal rates, config read, skip_cost, provider/engine/machine_type overrides

Closes #17
All tasks complete (62 tests pass, verified on real AiiDA data).
Moved to openspec/changes/archive/2026-08-04-add-vultr-cost-calculation/
- Fix amd5 substring collision: longest-key-first matching in get_cloud_rate
- Unknown provider/plan returns None instead of 0.0 (no silent 'free' cost)
- UpCloud recognised in config but has no pricing → rate/currency None
- resolve_provider_and_rate(): single shared helper, validates provider+machine_type
  consistency (no cross-cloud mixing, e.g. vultr+ccx13 → rate None)
- Remove skip_cost: auto-detect from computer name still works without config
- Currency set even when rate is None (provider known, plan unknown)
- Config tests use tmp_path (no /etc/yascheduler/ dependency)
- Engine filter tests verify QueryBuilder.append() gets process_type filter
- 81 tests: amd5, cross-provider mismatch, unknown plans, no-config auto-detect

Addresses PR #19 review feedback.
@alinzh
alinzh requested review from akvatol and blokhin August 5, 2026 07:59
@alinzh

alinzh commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

Important note: the issue here is that it is impossible to calculate cost for "broken" calculations, as there is no source for their duration.

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.

Add Vultr cost calculation module

1 participant