Skip to content

Commit fb721dc

Browse files
peaseeSevenannn
andauthored
docs: Update spicepy SDK docs (#818)
* docs: Update spicepy SDK use docs * docs: Update installed version * docs: Fix link formatting * Apply suggestions from code review Co-authored-by: Qianqian <130200611+Sevenannn@users.noreply.github.com> --------- Co-authored-by: Qianqian <130200611+Sevenannn@users.noreply.github.com>
1 parent 02c3ebf commit fb721dc

1 file changed

Lines changed: 56 additions & 5 deletions

File tree

website/docs/sdks/python/index.md

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ https://github.com/spiceai/spicepy
1212
### Install
1313

1414
```shell
15-
pip install git+https://github.com/spiceai/spicepy@v2.0.0
15+
pip install git+https://github.com/spiceai/spicepy@v3.0.0
1616
```
1717

18-
### Connect to spice runtime
18+
### Connect to a local Spice Runtime
19+
20+
By default, the Python SDK will connect to a locally running Spice Runtime:
1921

2022
```python
2123
from spicepy import Client
@@ -29,18 +31,67 @@ data = client.query(
2931
pd = data.read_pandas()
3032
```
3133

32-
Or pass custom flight address:
34+
### Connect to Spice Cloud
35+
36+
To connect to Spice Cloud, specify the required Flight and HTTP URLs to connect to Spice Cloud:
37+
38+
```python
39+
from spicepy import Client
40+
from spicepy.config import (
41+
DEFAULT_FLIGHT_URL,
42+
DEFAULT_HTTP_URL
43+
)
44+
45+
client = Client(
46+
api_key="<YOUR SPICE CLOUD API KEY>",
47+
flight_url=DEFAULT_FLIGHT_URL,
48+
http_url=DEFAULT_HTTP_URL
49+
)
50+
51+
data = client.query(
52+
'SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;',
53+
timeout=5*60
54+
)
55+
pd = data.read_pandas()
56+
```
57+
58+
### Connect to a remote Spice Runtime
59+
60+
By specifying a custom Flight and HTTP URL, the Python SDK can connect to a remote Spice Runtime - for example, a centralised Spice Runtime instance.
61+
62+
Example code:
3363

3464
```python
3565
from spicepy import Client
3666

3767
client = Client(
38-
flight_url="grpc://my_remote_spice_instance:50051"
68+
flight_url="grpc://your-remote-spice-runtime-host:50051",
69+
http_url="http://your-remote-spice-runtime-host:8090"
3970
)
4071

4172
data = client.query(
4273
'SELECT trip_distance, total_amount FROM taxi_trips ORDER BY trip_distance DESC LIMIT 10;',
4374
timeout=5*60
4475
)
4576
pd = data.read_pandas()
46-
```
77+
```
78+
79+
### Refresh an accelerated dataset
80+
81+
The SDK supports refreshing an accelerated dataset with the `Client.refresh_dataset()` method. Refresh a dataset by calling this method on an instance of an SDK client:
82+
83+
```python
84+
from spicepy import Client, RefreshOpts
85+
86+
client = Client()
87+
88+
client.refresh_dataset("taxi_trips", None) # refresh with no refresh options
89+
client.refresh_dataset("taxi_trips", RefreshOpts(refresh_sql="SELECT * FROM taxi_trips LIMIT 10")) # refresh with overridden refresh SQL
90+
91+
# RefreshOpts support all refresh parameters
92+
RefreshOpts(
93+
refresh_sql="SELECT * FROM taxi_trips LIMIT 10",
94+
refresh_mode="full",
95+
refresh_jitter_max="1m"
96+
)
97+
```

0 commit comments

Comments
 (0)