Skip to content

Commit d6bd928

Browse files
committed
clean up docs
1 parent 9bdfeed commit d6bd928

16 files changed

Lines changed: 305 additions & 14 deletions

File tree

python/docs/index.md

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,68 @@
1-
# Welcome to MkDocs
1+
# Sift Python Client Library
2+
Welcome to the official Python client library for Sift! This library provides a high-level Python API on top of Sift's protocol buffers, designed to ergonomically interface with the Sift gRPC API and simplify the process of streaming data.
23

3-
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
4+
Sift provides official client libraries for select languages, designed to simplify the process of streaming data over gRPC. These client libraries utilize ingestion-config-based streaming to facilitate data transmission.
45

5-
## Commands
6+
Check out the [repository](https://github.com/sift-stack/sift) for a list of all available client libraries.
67

7-
* `mkdocs new [dir-name]` - Create a new project.
8-
* `mkdocs serve` - Start the live-reloading docs server.
9-
* `mkdocs build` - Build the documentation site.
10-
* `mkdocs -h` - Print help message and exit.
8+
## Installation
119

12-
## Project layout
10+
To install the Sift Python library:
1311

14-
mkdocs.yml # The configuration file.
15-
docs/
16-
index.md # The documentation homepage.
17-
... # Other markdown pages, images and other files.
12+
```bash
13+
pip install sift-stack-py
14+
```
15+
16+
## API Documentation
17+
18+
This documentation covers two Python APIs for interacting with Sift:
19+
20+
### Sift Py API (Legacy)
21+
22+
The original low-level Python API that provides direct access to Sift's protocol buffer interfaces.
23+
24+
Browse the [**Sift Py API**][sift_py] section for complete reference documentation.
25+
26+
**Use this API if you need:**
27+
28+
- Direct protocol buffer access
29+
- Fine-grained control over gRPC connections
30+
- Legacy compatibility with existing code
31+
32+
### Sift Client API (New)
33+
34+
!!! warning
35+
The Sift Client is experimental and is subject to change.
36+
37+
38+
The modern, high-level client library that provides all the ergonomic features missing from the original API. This new client offers intuitive Python interfaces, strong type safety, automatic connection management, and both synchronous and asynchronous support.
39+
40+
Explore the [**Sift Client API (New)**][sift_client] section for the complete API reference.
41+
42+
**Key improvements over Sift Py:**
43+
44+
- **Ergonomic Design** - Pythonic interfaces instead of raw protocol buffers
45+
- **Type Safety** - Full type hints and Pydantic model validation
46+
- **Dual APIs** - Both sync and async support for all operations
47+
- **Auto Connection Management** - No manual gRPC connection handling
48+
- **Rich Object Models** - Immutable types with convenient methods
49+
- **Modern Patterns** - Context managers, iterators, and Python best practices
50+
51+
52+
## Getting Help
53+
54+
- **API Reference** - Browse the complete API documentation in the navigation
55+
- **Examples** - Check out code examples throughout the documentation
56+
- **GitHub** - Visit our [repository](https://github.com/sift-stack/sift) for issues and contributions
57+
58+
## What's Next?
59+
60+
Ready to dive deeper? Explore the API documentation to learn about:
61+
62+
- **Sift Resources** - Creating, updating, and organizing your assets and other data
63+
- **Data Streaming** - Efficient methods for ingesting data
64+
- **Advanced Filtering** - Powerful query capabilities
65+
- **Error Handling** - Best practices for robust applications
66+
- **Performance Optimization** - Tips for high-throughput scenarios
67+
68+
Get started by exploring the API reference in the navigation menu!

python/docs/overrides/main.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{% extends "base.html" %}
2+
3+
{% block outdated %}
4+
You're not viewing the latest version.
5+
<a href="{{ '../' ~ base_url }}">
6+
7+
8+
<strong>Click here to go to latest.</strong>
9+
</a>
10+
{% endblock %}

python/lib/sift_client/__init__.py

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,209 @@
1+
2+
"""
3+
!!! warning
4+
The Sift Client is experimental and is subject to change.
5+
6+
7+
# Sift Client Library
8+
9+
This library provides a high-level Python client for interacting with Sift APIs. It offers both synchronous and
10+
asynchronous interfaces, strong type checking, and a Pythonic API design.
11+
12+
## Installation
13+
14+
```bash
15+
pip install sift-stack-py
16+
```
17+
18+
## Getting Started
19+
20+
### Initializing the Client
21+
22+
You can initialize the Sift client with your API key and service URLs:
23+
24+
```python
25+
from sift_client import SiftClient
26+
from datetime import datetime
27+
28+
# Initialize with individual parameters
29+
client = SiftClient(
30+
api_key="your-api-key",
31+
grpc_url="your-sift-grpc-url",
32+
rest_url="your-sift-rest-url"
33+
)
34+
35+
# Or use a connection configuration
36+
from sift_client.transport import SiftConnectionConfig
37+
38+
config = SiftConnectionConfig(
39+
api_key="your-api-key",
40+
grpc_url="your-sift-grpc-url",
41+
rest_url="your-sift-rest-url"
42+
)
43+
client = SiftClient(connection_config=config)
44+
```
45+
46+
The `SiftConnectionConfig` provides access to additional configuration options such as `use_ssl` and `cert_via_openssl`.
47+
48+
### Using Synchronous and Asynchronous APIs
49+
50+
The Sift client provides both synchronous and asynchronous versions of all APIs. You can choose the one that best fits
51+
your application's needs.
52+
53+
#### Synchronous API
54+
55+
The synchronous API is perfect for scripts, notebooks, and applications that don't need asynchronous operation:
56+
57+
```python
58+
# Get an asset by ID
59+
asset = client.assets.get(asset_id="asset123")
60+
61+
# List assets with filtering
62+
assets = client.assets.list_(
63+
name_contains="example",
64+
created_after=datetime(2023, 1, 1),
65+
include_archived=False
66+
)
67+
68+
# Find a single asset matching criteria
69+
asset = client.assets.find(name="my-asset")
70+
```
71+
72+
#### Asynchronous API
73+
74+
The asynchronous API is ideal for high-performance applications and services that need to make concurrent API calls:
75+
76+
```python
77+
import asyncio
78+
79+
80+
async def get_asset_async():
81+
# Get an asset by ID asynchronously
82+
asset = await client.assets_async.get(asset_id="asset123")
83+
84+
# Running Sync within async also works
85+
some_other_asset = client.assets.get(asset_id="asset456")
86+
87+
return asset
88+
89+
90+
# Run in an async context
91+
asset = asyncio.run(get_asset_async())
92+
93+
```
94+
95+
### Working with Sift Types
96+
97+
Sift types (like `Asset`, `Run`, etc.) are immutable Pydantic models that provide a convenient interface for working
98+
with Sift resources.
99+
100+
#### Accessing Properties
101+
102+
```python
103+
# Get an asset
104+
asset = client.assets.get(asset_id="asset123")
105+
106+
# Access properties
107+
print(f"Asset name: {asset.name}")
108+
print(f"Created on: {asset.created_date}")
109+
print(f"Tags: {', '.join(asset.tags)}")
110+
print(f"Is archived: {asset.is_archived}")
111+
```
112+
113+
#### Using Methods on Sift Types
114+
115+
Sift types have convenient methods for common operations. These methods use the synchronous API internally.
116+
**Using these methods will update the instance in-place.**
117+
118+
```python
119+
# Get an asset
120+
asset = client.assets.get(asset_id="asset123")
121+
122+
# Archive the asset
123+
asset.archive(archive_runs=True)
124+
125+
# Update the asset
126+
asset.update({
127+
"tags": ["updated", "example"]
128+
})
129+
```
130+
131+
> **Note:** Type methods only work with the synchronous API. If you need to use the asynchronous API, you should use the
132+
> resource APIs directly.
133+
134+
#### Creating Update Models
135+
136+
For more complex updates, you can create update models (instead of a key-value dictionary):
137+
138+
```python
139+
from sift_client.types.asset import AssetUpdate
140+
141+
# Create an update model
142+
update = AssetUpdate(tags=["new", "tags"])
143+
144+
# Apply the update
145+
asset = client.assets.update(asset="asset123", update=update)
146+
147+
# Or using the asset method
148+
asset = client.assets.get(asset_id="asset123").update(update)
149+
```
150+
151+
## Advanced Usage
152+
153+
### Working with Tags
154+
155+
Tags are a powerful way to organize and filter your assets:
156+
157+
```python
158+
# Add tags when updating an asset
159+
asset.update({
160+
"tags": ["production", "model-v1", "trained"]
161+
})
162+
163+
# Filter assets by tags
164+
production_assets = client.assets.list_(
165+
tags=["production"]
166+
)
167+
```
168+
169+
### Filtering Assets
170+
171+
The client provides various ways to filter different Sift types:
172+
173+
```python
174+
# Filter by name (exact match)
175+
assets = client.assets.list_(name="my-model")
176+
177+
# Filter by name (contains)
178+
assets = client.assets.list_(name_contains="model")
179+
180+
# Filter by name (regex)
181+
assets = client.assets.list_(name_regex="model-v[0-9]+")
182+
183+
# Filter by creation date
184+
assets = client.assets.list_(
185+
created_after=datetime(2023, 1, 1),
186+
created_before=datetime(2023, 12, 31)
187+
)
188+
189+
# Filter by modification date
190+
assets = client.assets.list_(
191+
modified_after=datetime(2023, 6, 1)
192+
)
193+
194+
# Include archived assets
195+
all_assets = client.assets.list_(include_archived=True)
196+
197+
# Limit the number of results
198+
recent_assets = client.assets.list_(
199+
limit=10,
200+
order_by="modified_date desc"
201+
)
202+
```
203+
204+
205+
"""
206+
207+
1208
from sift_client.client import SiftClient
2209
from sift_client.transport import SiftConnectionConfig
File renamed without changes.

python/lib/sift_client/tests/_internal/test_gen_pyi.py renamed to python/lib/sift_client/_tests/_internal/test_gen_pyi.py

File renamed without changes.

python/lib/sift_client/tests/_internal/test_stub_module/__init__.py renamed to python/lib/sift_client/_tests/_internal/test_stub_module/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

33
from sift_client._internal.sync_wrapper import generate_sync_api
4-
from sift_client.tests._internal.test_stub_module.test_py import MockClassAsync
4+
from sift_client._tests._internal.test_stub_module.test_py import MockClassAsync
55

66
MockClass: type = generate_sync_api(MockClassAsync, "MockClass")

python/lib/sift_client/tests/_internal/test_stub_module/test_py.py renamed to python/lib/sift_client/_tests/_internal/test_stub_module/test_py.py

File renamed without changes.

python/lib/sift_client/tests/_internal/test_sync_wrapper.py renamed to python/lib/sift_client/_tests/_internal/test_sync_wrapper.py

File renamed without changes.

python/lib/sift_client/tests/integrated/calculated_channels.py renamed to python/lib/sift_client/_tests/integrated/calculated_channels.py

File renamed without changes.

0 commit comments

Comments
 (0)