Skip to content

Commit 0241625

Browse files
Merge pull request 'Readme with instruction for Gcloud' (#1) from impl/sky/cloud-deploy_preps into main
Reviewed-on: https://git.myzel.io/PyMC/PyMC-Server/pulls/1
2 parents 9c370fc + 79c4737 commit 0241625

File tree

8 files changed

+454
-43
lines changed

8 files changed

+454
-43
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "nutpie"]
2+
path = nutpie
3+
url = https://github.com/pymc-devs/nutpie

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Quickstart
2+
3+
## Installation
4+
5+
Install this library from PiPy `pip3 install pymc-server`
6+
7+
### Setting up a cloud: Google Cloud
8+
9+
1. Run `pymcs check` to see if you already have credentials setup. If you see a green checkmark for GCP (Google Cloud Platform), skip to the next section
10+
2. Install the google cloud SDK and authenticate.
11+
```bash
12+
conda install -c conda-forge google-cloud-sdk
13+
gcloud init
14+
15+
# Run this if you don't have a credentials file.
16+
# This will generate ~/.config/gcloud/application_default_credentials.json.
17+
gcloud auth application-default login
18+
```
19+
> Tip:
20+
> If you are using multiple GCP projects, list all the projects by gcloud projects list and activate one by gcloud config set project <PROJECT_ID> (see GCP docs).
21+
22+
3. Follow the link to Google and authorize the Google Cloud SDK. This will create and persist credentials on your local computer. Running pymc-server commands via Google Cloud will introduce cost to your Google Cloud bill according to the VMs provisioned by your configuration (see next section).
23+
24+
![Gcloud SDK Auth](./assets/gcloud_auth.png)
25+
26+
Follow through the rest of the GCP configuration in your terminal.
27+
28+
> Tip:
29+
> You can see a global status of active VMs by running `pymcs status`
30+
31+
32+
33+
### Status of your deployments
34+
35+
Running `pymcs status` all your deployments are checked and displayed in a table.
36+
37+
```bash
38+
❯ pymcs status
39+
Clusters
40+
NAME LAUNCHED RESOURCES STATUS AUTOSTOP COMMAND
41+
tc 5 months ago 1x Kubernetes(2CPU--2GB) UP - pymcs launch -c tc hello_sk...
42+
43+
Managed jobs
44+
No in-progress managed jobs. (See: pymcs jobs -h)
45+
46+
Services
47+
No live services. (See: pymcs serve -h)
48+
```

assets/gcloud_auth.png

264 KB
Loading

examples/other_nuts_samplers.ipynb

Lines changed: 42 additions & 43 deletions
Large diffs are not rendered by default.

examples/remote_nuts.ipynb

Lines changed: 302 additions & 0 deletions
Large diffs are not rendered by default.

nutpie

Submodule nutpie added at d94472d

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ nutpie
33
lifetimes
44
numba
55
ray[default]
6+
skypilot
7+
skypilot[gcp]

test.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
# You can run this code outside of the Ray cluster!
5+
import ray
6+
7+
# Starting the Ray client. This connects to a remote Ray cluster.
8+
# ray.init(_node_ip_address='192.168.88.197')
9+
ray.init('ray://192.168.88.197:10002')
10+
11+
12+
# Normal Ray code follows
13+
@ray.remote
14+
def do_work(x):
15+
return x ** x
16+
17+
18+
@ray.remote
19+
def fit_model():
20+
import arviz as az
21+
import matplotlib.pyplot as plt
22+
from lifetimes.datasets import load_cdnow_summary
23+
24+
from pymc_marketing import clv
25+
26+
az.style.use("arviz-darkgrid")
27+
plt.rcParams["figure.figsize"] = [12, 7]
28+
plt.rcParams["figure.dpi"] = 100
29+
plt.rcParams["figure.facecolor"] = "white"
30+
31+
df = (
32+
load_cdnow_summary(index_col=[0])
33+
.reset_index()
34+
.rename(columns={"ID": "customer_id"})
35+
)
36+
sampler_kwargs = {
37+
"draws": 2_000,
38+
"target_accept": 0.9,
39+
"chains": 5,
40+
"random_seed": 42,
41+
}
42+
43+
model = clv.BetaGeoModel(data=df)
44+
idata_nutpie = model.fit(nuts_sampler="nutpie", **sampler_kwargs)
45+
return idata_nutpie
46+
47+
object_ref = fit_model.remote()
48+
x = ray.get(object_ref)
49+
print(x)
50+
51+
"""
52+
object_refs = do_work.remote(2)
53+
x = ray.get(object_refs)
54+
"""
55+
56+

0 commit comments

Comments
 (0)