Skip to content

Commit ca10acd

Browse files
committed
fix
1 parent 8f4395a commit ca10acd

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

python/hopsworks/__init__.py

+29-12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
_secrets_api = None
4848
_project_api = None
4949

50+
5051
def hw_formatwarning(message, category, filename, lineno, line=None):
5152
return "{}: {}\n".format(category.__name__, message)
5253

@@ -144,7 +145,7 @@ def login(
144145
elif host is None: # Always do a fallback to Serverless Hopsworks if not defined
145146
host = constants.HOSTS.APP_HOST
146147

147-
is_app = (host == constants.HOSTS.APP_HOST)
148+
is_app = host == constants.HOSTS.APP_HOST
148149

149150
# If port same as default, get HOPSWORKS_HOST environment variable
150151
if port == 443 and "HOPSWORKS_PORT" in os.environ:
@@ -211,7 +212,9 @@ def login(
211212
raise e
212213

213214
if _connected_project is None:
214-
print("Could not find any project, use hopsworks.create_project('my_project') to create one")
215+
print(
216+
"Could not find any project, use hopsworks.create_project('my_project') to create one"
217+
)
215218
else:
216219
print("\nLogged in to project, explore it here " + _connected_project.get_url())
217220

@@ -273,7 +276,9 @@ def _prompt_project(valid_connection, project, is_app):
273276
for index in range(len(saas_projects)):
274277
print("\t (" + str(index + 1) + ") " + saas_projects[index].name)
275278
while True:
276-
project_index = input("\nEnter number corresponding to the project to use: ")
279+
project_index = input(
280+
"\nEnter number corresponding to the project to use: "
281+
)
277282
# Handle invalid input type
278283
try:
279284
project_index = int(project_index)
@@ -300,8 +305,7 @@ def _prompt_project(valid_connection, project, is_app):
300305

301306

302307
def logout():
303-
"""Cleans up and closes the connection for the hopsworks, hsfs and hsml libraries.
304-
"""
308+
"""Cleans up and closes the connection for the hopsworks, hsfs and hsml libraries."""
305309
global _hw_connection
306310
global _project_api
307311
global _secrets_api
@@ -314,10 +318,12 @@ def logout():
314318
_secrets_api = None
315319
_hw_connection = Connection.connection
316320

321+
317322
def _is_connection_active():
318323
global _hw_connection
319324
return isinstance(_hw_connection, Connection)
320325

326+
321327
def get_current_project() -> project.Project:
322328
"""Get a reference to the current logged in project.
323329
@@ -341,15 +347,15 @@ def get_current_project() -> project.Project:
341347
raise ProjectException("No project is set for this session")
342348
return _connected_project
343349

350+
344351
def _initialize_module_apis():
345352
global _project_api
346353
global _secrets_api
347354
_project_api = project_api.ProjectApi()
348355
_secrets_api = secret_api.SecretsApi()
349356

350-
def create_project(
351-
name: str, description: str = None, feature_store_topic: str = None
352-
):
357+
358+
def create_project(name: str, description: str = None, feature_store_topic: str = None):
353359
"""Create a new project.
354360
355361
Example for creating a new project
@@ -377,13 +383,24 @@ def create_project(
377383
if not _is_connection_active():
378384
raise NoHopsworksConnectionError()
379385

380-
new_project = _hw_connection._project_api._create_project(name, description, feature_store_topic)
386+
new_project = _hw_connection._project_api._create_project(
387+
name, description, feature_store_topic
388+
)
381389
if _connected_project is None:
382390
_connected_project = new_project
383-
print("Setting {} as the current project, a reference can be retrieved by calling hopsworks.get_current_project()".format(_connected_project.name))
391+
print(
392+
"Setting {} as the current project, a reference can be retrieved by calling hopsworks.get_current_project()".format(
393+
_connected_project.name
394+
)
395+
)
384396
return _connected_project
385397
else:
386-
print("You are already using the project {}, to access the new project use hopsworks.login(..., project='{}')".format(_connected_project.name, new_project.name))
398+
print(
399+
"You are already using the project {}, to access the new project use hopsworks.login(..., project='{}')".format(
400+
_connected_project.name, new_project.name
401+
)
402+
)
403+
387404

388405
def get_secrets_api():
389406
"""Get the secrets api.
@@ -394,4 +411,4 @@ def get_secrets_api():
394411
global _secrets_api
395412
if not _is_connection_active():
396413
raise NoHopsworksConnectionError()
397-
return _secrets_api
414+
return _secrets_api

0 commit comments

Comments
 (0)