SDK wrapper, serverless framework, and integration tests#328
Draft
begna112 wants to merge 2 commits intovast-ai:masterfrom
Draft
SDK wrapper, serverless framework, and integration tests#328begna112 wants to merge 2 commits intovast-ai:masterfrom
begna112 wants to merge 2 commits intovast-ai:masterfrom
Conversation
Bug fixes: - Fix mutable default arguments in http_put/post/del - Add missing exception handling in http_request - Fix timezone handling with UTC-aware timestamps - Fix show_instances row rebinding bug - Fix show_machine dict response handling - Fix parse_query field alias data loss - Remove hardcoded if True anti-patterns - Fix raw mode to return parsed JSON consistently - Fix namespace attribute typo - Replace bare except clauses with specific exceptions - Remove shell=True from subprocess calls - Fix self-test instance creation type handling and error messages Infrastructure improvements: - Add request timeout support with configurable defaults - Expand retry logic to cover 502/503/504 and connection errors - Add JSONDecodeError protection to high-risk .json() sites - Consolidate direct requests calls through http_* helpers - Add structured JSON error output for --raw mode - Add raw mode return handling to all command functions - Remove unreachable code after raise_for_status() - Add api_call/output_result/error_output DRY helpers - Add 2FA session expiry handling with automatic key fallback - Filter sensitive fields from show endpoints output CLI improvements: - Improve help text and descriptions for 130+ commands - Add named flags for transfer credit (--sender, --recipient) - Fix argument mismatches in usage strings - Standardize show maints to use --ids instead of -ids - Remove Python 2 compatibility code Test infrastructure: - Add pytest with regression, smoke, and unit test suites - Add CI workflow with lint, test, and smoke-test jobs - Add ruff configuration for code quality - Add dev dependencies to pyproject.toml
Introduce the vastai Python package providing programmatic SDK access to the Vast.ai API, plus a serverless client/server framework for building GPU workers. New packages: - vastai/ - SDK wrapper (sdk.py), base class (vastai_base.py), serverless client and server framework - vastai_sdk/ - Backward-compatibility shim for old import path - examples/ - 17 client/server example scripts - benchmarks/ - Prometheus metrics and docker-compose Test additions: - 7 unit tests for serverless components and VastAIBase - 6 regression tests for SDK integration, lazy imports, exception handling, naming consistency Config updates: - pyproject.toml: add pyparsing dep, serverless optional deps, vastai/vastai_sdk packages, mypy config - ci.yml: add type-check job (mypy vastai/)
5 tasks
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.
Summary
Adds the
vastaiPython SDK package that wraps the CLI for programmatic use, plus a serverless framework for deploying GPU workers.SDK Package (
vastai/)VastAIclass wrapping all CLI commands with Python-native interfaceServerless Framework (
vastai/serverless/)VastClientfor dispatching work to GPU workers with SSL pinning, retry logic, and async I/OVastWorkerbase class for implementing GPU worker endpoints with Prometheus metricsAdditional Files
vastai_sdk/backward-compatibility shimexamples/- 17 client/server usage examplesbenchmarks/- Prometheus metrics and docker-compose setupChanges to Existing Files
pyproject.toml- Addedpyparsingdependency,vastai/vastai_sdkpackages,serverless/alloptional dependency groups, mypy overrides.github/workflows/ci.yml- Addedtype-checkjob (mypy)Stats
Test plan
from vastai import VastAIsucceedspython -m vastai --helpworkspytest tests/)mypy vastai/type checking passes