No project description provided
Project description
FluidStack Python Library
The FluidStack Python Library provides convenient access to the FluidStack API from applications written in Python.
The library includes type definitions for all request and response fields, and offers both synchronous and asynchronous clients powered by httpx.
Installation
Add this dependency to your project's build file:
pip install fluidstack
# or
poetry add fluidstack
Usage
Simply import FluidStack
and start making calls to our API.
from fluidstack.client import FluidStack
client = FluidStack(
api_key="YOUR_API_KEY", # defaults to FLUIDSTACK_API_KEY
)
client.ssh_keys.create(
name="name",
public_key="PUBLIC_KEY",
)
Async Client
The SDK also exports an async client so that you can make non-blocking calls to our API.
from fluidstack.client import AsyncFluidStack
client = AsyncFluidStack(
api_key="YOUR_API_KEY",
)
async def main() -> None:
await client.ssh_keys.create(
name="name",
public_key="PUBLIC_KEY",
)
asyncio.run(main())
Exception Handling
All errors thrown by the SDK will be subclasses of ApiError
.
import fluidstack
try:
client.auth.get_callback(...)
except fluidstack.core.ApiError as e: # Handle all errors
print(e.status_code)
print(e.body)
Advanced
Timeouts
By default, requests time out after 60 seconds. You can configure this with a timeout option at the client or request level.
from fluidstack.client import FluidStack
client = FluidStack(
...,
# All timeouts are 20 seconds
timeout=20.0,
)
# Override timeout for a specific method
client.auth.get_callback(..., {
timeout_in_seconds=20.0
})
Retries
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retriable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).
A request is deemed retriable when any of the following HTTP status codes is returned:
Use the max_retries
request option to configure this behavior.
client.auth.get_callback(..., {
max_retries=1
})
Custom HTTP client
You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports.
import httpx
from fluidstack.client import FluidStack
client = FluidStack(...,
http_client=httpx.Client(
proxies="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
Beta Status
This SDK is in Preview, and there may be breaking changes between versions without a major version update.
To ensure a reproducible environment (and minimize risk of breaking changes), we recommend pinning a specific package version.
Contributing
While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
On the other hand, contributions to the README are always very welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fluidstack-0.0.8.tar.gz
.
File metadata
- Download URL: fluidstack-0.0.8.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1073-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66fb198fd56cbe620408d46ea7d44655a920d59c45c1f508c47a368a289b30b0 |
|
MD5 | 4e26fa7aa05ae70bf3ed65c5c25abf30 |
|
BLAKE2b-256 | 514b57b177c9024a532546a72c03531e93692b18988de79498cdd6bea75d65be |
File details
Details for the file fluidstack-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: fluidstack-0.0.8-py3-none-any.whl
- Upload date:
- Size: 36.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1073-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b9122ac5c34f6dec59afd82af80f51cfa60179cbd5ac83d405b8f8a22d2502b |
|
MD5 | da3ea180bc8632feba3ef94734354d40 |
|
BLAKE2b-256 | 22c688c3b541f0ecaa265ee5adbd3343f7fcaf933910c0e524e5220c3875a227 |