Skip to content

Commit 3ec2248

Browse files
authored
Add engine parameter to hopsworks.login (logicalclocks#378)
* Add engine parameter to hopsworks.login * Remove engine param from get_feature_store * Remove redundant code from get_feature_store * Bump version to 4.0.0-RC1
1 parent 426f730 commit 3ec2248

File tree

10 files changed

+23
-31
lines changed

10 files changed

+23
-31
lines changed

java/beam/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsfs-parent</artifactId>
77
<groupId>com.logicalclocks</groupId>
8-
<version>4.0.0-RC0</version>
8+
<version>4.0.0-RC1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

java/flink/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsfs-parent</artifactId>
77
<groupId>com.logicalclocks</groupId>
8-
<version>4.0.0-RC0</version>
8+
<version>4.0.0-RC1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

java/hsfs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsfs-parent</artifactId>
77
<groupId>com.logicalclocks</groupId>
8-
<version>4.0.0-RC0</version>
8+
<version>4.0.0-RC1</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>com.logicalclocks</groupId>
88
<artifactId>hsfs-parent</artifactId>
99
<packaging>pom</packaging>
10-
<version>4.0.0-RC0</version>
10+
<version>4.0.0-RC1</version>
1111
<modules>
1212
<module>hsfs</module>
1313
<module>spark</module>

java/spark/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<artifactId>hsfs-parent</artifactId>
2424
<groupId>com.logicalclocks</groupId>
25-
<version>4.0.0-RC0</version>
25+
<version>4.0.0-RC1</version>
2626
</parent>
2727
<modelVersion>4.0.0</modelVersion>
2828

python/hopsworks/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import tempfile
2323
import warnings
2424
from pathlib import Path
25+
from typing import Literal, Union
2526

2627
from hopsworks import client, constants, project, version
2728
from hopsworks.client.exceptions import (
@@ -83,6 +84,7 @@ def login(
8384
api_key_file: str = None,
8485
hostname_verification: bool = False,
8586
trust_store_path: str = None,
87+
engine: Union[None, Literal["spark"], Literal["python"], Literal["training"]] = None,
8688
) -> project.Project:
8789
"""Connect to [Serverless Hopsworks](https://app.hopsworks.ai) by calling the `hopsworks.login()` function with no arguments.
8890
@@ -122,6 +124,13 @@ def login(
122124
api_key_file: Path to file wih Api Key
123125
hostname_verification: Whether to verify Hopsworks' certificate
124126
trust_store_path: Path on the file system containing the Hopsworks certificates
127+
engine: Which engine to use, `"spark"`, `"python"` or `"training"`. Defaults to `None`,
128+
which initializes the engine to Spark if the environment provides Spark, for
129+
example on Hopsworks and Databricks, or falls back to Python if Spark is not
130+
available, e.g. on local Python environments or AWS SageMaker. This option
131+
allows you to override this behaviour. `"training"` engine is useful when only
132+
feature store metadata is needed, for example training dataset location and label
133+
information when Hopsworks training experiment is conducted.
125134
# Returns
126135
`Project`: The Project object to perform operations on
127136
# Raises
@@ -138,7 +147,7 @@ def login(
138147

139148
# If inside hopsworks, just return the current project for now
140149
if "REST_ENDPOINT" in os.environ:
141-
_hw_connection = _hw_connection(hostname_verification=hostname_verification)
150+
_hw_connection = _hw_connection(hostname_verification=hostname_verification, engine=engine)
142151
_connected_project = _hw_connection.get_project()
143152
_initialize_module_apis()
144153
print("\nLogged in to project, explore it here " + _connected_project.get_url())
@@ -207,6 +216,7 @@ def login(
207216
_hw_connection = _hw_connection(
208217
host=host,
209218
port=port,
219+
engine=engine,
210220
api_key_file=api_key_path,
211221
hostname_verification=hostname_verification,
212222
trust_store_path=trust_store_path,
@@ -246,6 +256,7 @@ def login(
246256
_hw_connection = _hw_connection(
247257
host=host,
248258
port=port,
259+
engine=engine,
249260
api_key_value=api_key,
250261
hostname_verification=hostname_verification,
251262
trust_store_path=trust_store_path,

python/hopsworks_common/connection.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Connection:
9999
Defaults to `None`.
100100
engine: Which engine to use, `"spark"`, `"python"` or `"training"`. Defaults to `None`,
101101
which initializes the engine to Spark if the environment provides Spark, for
102-
example on Hopsworks and Databricks, or falls back on Hive in Python if Spark is not
102+
example on Hopsworks and Databricks, or falls back to Python if Spark is not
103103
available, e.g. on local Python environments or AWS SageMaker. This option
104104
allows you to override this behaviour. `"training"` engine is useful when only
105105
feature store metadata is needed, for example training dataset location and label
@@ -150,7 +150,6 @@ def __init__(
150150
def get_feature_store(
151151
self,
152152
name: Optional[str] = None,
153-
engine: Optional[str] = None,
154153
): # -> feature_store.FeatureStore
155154
# the typing is commented out due to circular dependency, it breaks auto_doc.py
156155
"""Get a reference to a feature store to perform operations on.
@@ -160,25 +159,10 @@ def get_feature_store(
160159
161160
# Arguments
162161
name: The name of the feature store, defaults to `None`.
163-
engine: Which engine to use, `"spark"`, `"python"` or `"training"`. Defaults to `None`,
164-
which initializes the engine to Spark if the environment provides Spark, for
165-
example on Hopsworks and Databricks, or falls back on Hive in Python if Spark is not
166-
available, e.g. on local Python environments or AWS SageMaker. This option
167-
allows you to override this behaviour. `"training"` engine is useful when only
168-
feature store metadata is needed, for example training dataset location and label
169-
information when Hopsworks training experiment is conducted.
170162
171163
# Returns
172164
`FeatureStore`. A feature store handle object to perform operations on.
173165
"""
174-
# Ensure the engine is initialized and of right type
175-
from hsfs import engine as hsfs_engine
176-
177-
if engine:
178-
global _hsfs_engine_type
179-
_hsfs_engine_type = engine
180-
hsfs_engine.get_instance()
181-
182166
if not name:
183167
name = client.get_instance()._project_name
184168
return self._feature_store_api.get(util.append_feature_store_suffix(name))
@@ -525,7 +509,7 @@ def connection(
525509
Defaults to `None`.
526510
engine: Which engine to use, `"spark"`, `"python"` or `"training"`. Defaults to `None`,
527511
which initializes the engine to Spark if the environment provides Spark, for
528-
example on Hopsworks and Databricks, or falls back on Hive in Python if Spark is not
512+
example on Hopsworks and Databricks, or falls back to Python if Spark is not
529513
available, e.g. on local Python environments or AWS SageMaker. This option
530514
allows you to override this behaviour. `"training"` engine is useful when only
531515
feature store metadata is needed, for example training dataset location and label

python/hopsworks_common/project.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def project_namespace(self):
109109
return self._project_namespace
110110

111111
def get_feature_store(
112-
self, name: Optional[str] = None, engine: Optional[str] = None
112+
self, name: Optional[str] = None
113113
): # -> hsfs.feature_store.FeatureStore
114114
"""Connect to Project's Feature Store.
115115
@@ -127,15 +127,12 @@ def get_feature_store(
127127
128128
# Arguments
129129
name: Project name of the feature store.
130-
engine: Which engine to use, `"spark"`, `"python"` or `"training"`.
131-
Defaults to `"python"` when connected to [Serverless Hopsworks](https://app.hopsworks.ai).
132-
See [`hopsworks.connection`](connection.md#connection) documentation for more information.
133130
# Returns
134131
`hsfs.feature_store.FeatureStore`: The Feature Store API
135132
# Raises
136133
`RestAPIError`: If unable to connect
137134
"""
138-
return client.get_connection().get_feature_store(name, engine)
135+
return client.get_connection().get_feature_store(name)
139136

140137
def get_model_registry(self):
141138
"""Connect to Project's Model Registry API.

python/hopsworks_common/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
# limitations under the License.
1515
#
1616

17-
__version__ = "4.0.0rc0"
17+
__version__ = "4.0.0rc1"

utils/java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.logicalclocks</groupId>
77
<artifactId>hsfs-utils</artifactId>
8-
<version>4.0.0-RC0</version>
8+
<version>4.0.0-RC1</version>
99

1010
<properties>
1111
<hops.version>3.2.0.0-SNAPSHOT</hops.version>

0 commit comments

Comments
 (0)