Skip to content

Commit 3fb312c

Browse files
committed
fix
1 parent ae9fa0b commit 3fb312c

File tree

2 files changed

+55
-24
lines changed

2 files changed

+55
-24
lines changed

python/hopsworks/__init__.py

+27-23
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,27 @@ def login(
7272
) -> project.Project:
7373
"""Connect to [Serverless Hopsworks](https://app.hopsworks.ai) by calling the `hopsworks.login()` function with no arguments.
7474
75-
```python
75+
!!! example "Connect to Serverless"
76+
```python
7677
77-
project = hopsworks.login()
78+
import hopsworks
7879
79-
```
80+
project = hopsworks.login()
81+
82+
```
8083
8184
Alternatively, connect to your own Hopsworks installation by specifying the host, port and api key.
8285
83-
```python
86+
!!! example "Connect to your Hopsworks cluster"
87+
```python
88+
89+
import hopsworks
8490
85-
project = hopsworks.login(host="my.hopsworks.server",
86-
port=8181,
87-
api_key_value="DKN8DndwaAjdf98FFNSxwdVKx")
91+
project = hopsworks.login(host="my.hopsworks.server",
92+
port=8181,
93+
api_key_value="DKN8DndwaAjdf98FFNSxwdVKx")
8894
89-
```
95+
```
9096
9197
In addition to setting function arguments directly, `hopsworks.login()` also reads the environment variables:
9298
HOPSWORKS_HOST, HOPSWORKS_PORT, HOPSWORKS_PROJECT and HOPSWORKS_API_KEY.
@@ -327,17 +333,16 @@ def _is_connection_active():
327333
def get_current_project() -> project.Project:
328334
"""Get a reference to the current logged in project.
329335
330-
Example for creating a new project
336+
!!! example "Example for getting the project reference"
337+
```python
331338
332-
```python
339+
import hopsworks
333340
334-
import hopsworks
341+
hopsworks.login()
335342
336-
hopsworks.login()
343+
project = hopsworks.get_current_project()
337344
338-
project = hopsworks.get_current_project()
339-
340-
```
345+
```
341346
342347
# Returns
343348
`Project`. The Project object to perform operations on
@@ -358,20 +363,19 @@ def _initialize_module_apis():
358363
def create_project(name: str, description: str = None, feature_store_topic: str = None):
359364
"""Create a new project.
360365
361-
!!! warn
366+
!!! warning "Not supported"
362367
This is not supported if you are connected to [Serverless Hopsworks](https://app.hopsworks.ai)
363368
364-
Example for creating a new project
365-
366-
```python
369+
!!! example "Example for creating a new project"
370+
```python
367371
368-
import hopsworks
372+
import hopsworks
369373
370-
hopsworks.login()
374+
hopsworks.login(...)
371375
372-
hopsworks.create_project("my_hopsworks_project", description="An example Hopsworks project")
376+
hopsworks.create_project("my_project", description="An example Hopsworks project")
373377
374-
```
378+
```
375379
# Arguments
376380
name: The name of the project.
377381
description: optional description of the project

python/hopsworks/project.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,19 @@ def get_feature_store(self, name: str = None, engine: str = None) -> feature_sto
109109
Defaulting to the project name of default feature store. To get a
110110
shared feature store, the project name of the feature store is required.
111111
112+
!!! example "Example for getting the Feature Store API of a project"
113+
```python
114+
import hopsworks
115+
116+
project = hopsworks.login()
117+
118+
fs = project.get_feature_store()
119+
```
120+
112121
# Arguments
113122
name: Project name of the feature store.
114123
engine: Which engine to use, `"spark"`, `"python"` or `"training"`.
115-
Defaults to `"python"` when connected to https://c.app.hopsworks.ai/.
124+
Defaults to `"python"` when connected to [Serverless Hopsworks](https://app.hopsworks.ai).
116125
See hsfs.Connection.connection documentation for more information.
117126
# Returns
118127
`hsfs.feature_store.FeatureStore`: The Feature Store API
@@ -138,6 +147,15 @@ def get_feature_store(self, name: str = None, engine: str = None) -> feature_sto
138147
def get_model_registry(self):
139148
"""Connect to Project's Model Registry API.
140149
150+
!!! example "Example for getting the Model Registry API of a project"
151+
```python
152+
import hopsworks
153+
154+
project = hopsworks.login()
155+
156+
mr = project.get_model_registry()
157+
```
158+
141159
# Returns
142160
`hsml.model_registry.ModelRegistry`: The Model Registry API
143161
# Raises
@@ -159,6 +177,15 @@ def get_model_registry(self):
159177
def get_model_serving(self):
160178
"""Connect to Project's Model Serving API.
161179
180+
!!! example "Example for getting the Model Serving API of a project"
181+
```python
182+
import hopsworks
183+
184+
project = hopsworks.login()
185+
186+
ms = project.get_model_serving()
187+
```
188+
162189
# Returns
163190
`hsml.model_serving.ModelServing`: The Model Serving API
164191
# Raises

0 commit comments

Comments
 (0)