yggdrasil.enums.nodetype¶
nodetype ¶
Centralized Databricks compute node-type identifiers.
Databricks accepts a free-form node_type_id string ("rd-fleet.xlarge",
"m5.4xlarge", "Standard_D8ds_v5", "n2-standard-8", …). Every
caller used to spell its own default, which made size / cloud changes a
search-and-replace exercise and made it easy to typo a SKU.
:class:NodeType pins the convention to one place:
- canonical members for the SKUs Yggdrasil's compute services prefer (Fleet sizes for AWS Databricks, common Azure/GCP families);
- :attr:
NodeType.DEFAULT— the workspace-cloud-agnostic Fleet default; - semantic aliases (:attr:
SMALL/ :attr:MEDIUM/ :attr:LARGE/ :attr:XLARGE) that map to Fleet sizes; - :meth:
from_and :meth:to_idfor forgiving coercion at API boundaries — unknown SKUs pass through as plain strings rather than rejecting valid cloud-specific identifiers callers may use.
Members subclass :class:str, so a :class:NodeType member is interchangeable
with the raw node_type_id string everywhere the Databricks SDK / REST API
expects one.
Usage::
from yggdrasil.enums import NodeType
# Direct use — the member is a str.
spec = {"node_type_id": NodeType.DEFAULT}
# Forgiving coercion (returns the original string for unknown SKUs).
node_type_id = NodeType.to_id(user_provided_value)
# Membership / known-SKU check.
if NodeType.is_known(value):
...
NodeType ¶
Bases: str, Enum
Canonical Databricks node_type_id values.
Member values are the exact strings the Databricks SDK expects. Use
:attr:NodeType.DEFAULT for the codebase-wide default node type, the
semantic-size aliases (:attr:SMALL / :attr:MEDIUM / :attr:LARGE /
:attr:XLARGE) for intent-driven sizing, or the explicit cloud-specific
members when you need a precise SKU.
The enum is intentionally not exhaustive — Databricks publishes
hundreds of SKUs per cloud and most callers want a small, opinionated
set. Coerce caller-provided strings through :meth:to_id /
:meth:from_ so unknown SKUs round-trip as plain strings instead of
raising.
from_
classmethod
¶
Coerce value into a :class:NodeType member.
Accepts:
- :class:
NodeType(returned as-is); - any string in :data:
_NODETYPE_ALIASES, case-insensitive; - a bare member name (
"FLEET_XLARGE"); None— returns default if supplied, else :attr:NodeType.DEFAULT.
Raises :class:ValueError for unknown strings unless default is
supplied. To accept arbitrary SKU strings (without rejecting valid
cloud-specific identifiers), call :meth:to_id instead.
to_id
classmethod
¶
to_id(
value: Union[str, "NodeType", None],
*,
default: Optional[Union[str, "NodeType"]] = None
) -> str
Coerce value to a Databricks node_type_id string.
Unlike :meth:from_, this is forgiving: arbitrary SKU strings
round-trip unchanged so callers can pass cloud-specific identifiers
the enum does not enumerate ("r5d.metal", custom marketplace
images, …). Aliases are resolved when present.
Resolution order:
NodeTypemember → its string value.- Alias / member name / value match → the canonical string.
- Bare string → trimmed and returned as-is.
None→defaultif supplied, else :attr:NodeType.DEFAULT.
NodeSpec
dataclass
¶
NodeSpec(
cpu_cores: int,
ram_gib: float,
gpu_count: int = 0,
local_disk_gib: float = 0.0,
cloud: str = "",
)
Hardware specs for a :class:NodeType member.
The numbers reflect the vendor's published per-VM characteristics for
a single worker (or driver) — not the cluster-wide totals. ram_gib
is binary GiB (1024 ** 3 bytes), matching every cloud's own
documentation convention.
Attributes¶
cpu_cores
Virtual CPU count exposed to Spark.
ram_gib
Memory available to Spark, in IEC GiB.
gpu_count
Number of GPUs (0 for non-GPU SKUs).
local_disk_gib
Local SSD/NVMe storage attached to the instance. 0 when the
SKU has no local disk (relies on remote/elastic storage).
cloud
Cloud family identifier ("fleet" / "aws" / "azure" /
"gcp") used by :meth:NodeType.from_cpu_and_ram when
prefer is set.