fix(sdk): unbreak spore.truffle/spore.spawn, launch(), and find() parsing (#2) - #3
Merged
Conversation
…ng (#2) The SDK's two documented entry points both failed, and no tests caught it. - Module shadowing: spore.truffle/spore.spawn resolved to the same-named SUBMODULE (no .find/.launch), because importing it (Client does, internally) rebinds the package attr and shadows the __getattr__ hook. Rename impl modules to _truffle/_spawn (private); expose spore.truffle/spore.spawn as robust lazy proxies to a default client; re-export public classes from the top level. - launch() raised TypeError: constructed Instance(private_ip=, availability_zone=) with fields that didn't exist. Add them to Instance; launch() now builds via _parse (single source of truth). - find() returned zeroed memory/gpu-mem/AZs: parser read mangled keys (memory_mi_b, gpu_memory_mi_b, available_a_zs) the API never sends. Read the real keys (memory_mib, gpu_memory_mib, availability_zones, vcpus, gpus). - Add tests/test_sdk.py (quickstart + parsers vs real API JSON); CI now gates on pytest instead of swallowing 'No tests yet'. Bump 0.1.2 -> 0.1.3. Fixes #2
The module-level '_default: Client | None' annotation executes at import; on py3.9 (requires-python >=3.9) PEP 604 unions aren't runtime-valid -> TypeError. Add 'from __future__ import annotations' (matches the impl modules). Surfaced by the new test suite running on the 3.9 matrix leg.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2. The SDK's two documented entry points both failed on first use, and no tests caught it because CI swallowed a missing suite.
Fixes
spore.truffle/spore.spawnwere the method-less modules.spore.truffle.find(...)(the documented quickstart) raised AttributeError: the same-named submodule shadowed the__getattr__sugar hook, and importing it is unavoidable (the client doesfrom .truffle import ...internally, which permanently rebinds the package attr). Fix: rename impl modules tospore._truffle/spore._spawn(private, no collision); exposespore.truffle/spore.spawnas robust lazy proxies to a default client's sub-clients (noClient()side effect onimport spore); re-export public classes:from spore import Client, SpawnClient, TruffleClient, Instance, InstanceType, SpotPrice, QuotaInfo.spawn.launch()raised TypeError — builtInstance(private_ip=…, availability_zone=…)with nonexistent fields. Added them toInstance(the launch REST response returns them);launch()now builds via_parse.truffle.find()returned zeroed memory / GPU-mem / AZs — parser read mangled keys (memory_mi_b,gpu_memory_mi_b,available_a_zs) the REST API never sends. Now reads the realtruffleaws.InstanceTypeResultkeys (memory_mib,gpu_memory_mib,availability_zones,vcpus,gpus).Tests + CI
New
tests/test_sdk.py(10 tests) covering the quickstart entry points and both parsers against the real REST API JSON keys — including a torture test that imports the private submodule first (the original bug's trigger). CI'stestjob previously ranpytest … || echo "No tests yet"(swallowed absence and failure); now it gates. Verified: full suite green 3.9–3.12-style locally,ruffclean onspore/+tests/,python -m build+ fresh-install smoke pass.Notes / out of scope
spore.spawn/spore.truffleare now proxies, and the impl modules are private (_spawn/_truffle). Public classes are re-exported fromspore, sofrom spore import SpawnClientetc. is the supported path. The documentedspore.truffle.find(...)/spore.spawn.launch(...)sugar is unchanged and now actually works. Bump 0.1.2 → 0.1.3.truffle/bindings/python(native CGO) is non-functional/never-committed — separate concern, not touched here (belongs in a spore-host/truffle issue).