Skip to content

Commit d0233e5

Browse files
committed
Merge branch 'release/v0.1.5'
2 parents fb975eb + cca1bd2 commit d0233e5

6 files changed

Lines changed: 43 additions & 9 deletions

File tree

sclblpy/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@
1313
start_print, _set_toolchain_URL, _set_usermanager_URL, _set_taskmanager_URL
1414
from .version import __version__
1515

16+
# Simple welcome message:
17+
print("\n*** Thanks for importing sclblpy! ***")
18+
print("You can use the 'upload()' function to upload your models.")
19+
print("To inspect your currently uploaded models, use `endpoints()`.")
20+
print("Check the docs at https://pypi.org/project/sclblpy/ for more info. \n")
21+

sclblpy/_globals.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
# Available models:
2626
SUPPORTED_MODELS: dict = {} # List of supported models.
2727

28+
# Pretty printing of example:
29+
EXAMPLE__BASE_URL: str = "https://admin.sclbl.net/run.html"
30+
2831

2932
if __name__ == '__main__':
3033
print("No command line options available for _globals.py.")

sclblpy/_jwt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ def _sign_in(username: str, password: str, _remove_file=True) -> bool:
130130
return False
131131

132132
if result.get("error") is not None:
133+
if not glob.SILENT:
134+
print("JWT authentication error: The server generated an error: " + result.get("error"))
133135
if _remove_file:
134136
_remove_credentials() # Removing user credentials since they are not right
135-
if not glob.SILENT:
136-
print("JWT error: the server generated an error: " + result.get("error"))
137137
if glob.DEBUG:
138138
raise LoginError(result.get("JWT server error: " + result.get("error")))
139139
return False
@@ -305,7 +305,7 @@ def _remove_credentials():
305305
return False
306306
if not glob.SILENT:
307307
print("Your stored user credentials have been removed. \n"
308-
"Please re-enter your username and password next time you try to upload a model.")
308+
"You will have to re-enter your username and password next time.")
309309

310310
return True
311311
else:

sclblpy/main.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# File contains all public methods of the scblpy package
22
import json
33
import sys
4+
import urllib
45

56
import requests
67

@@ -198,7 +199,10 @@ def upload(mod, feature_vector, docs={}, email=True, _keep=False) -> bool:
198199

199200
# user feedback:
200201
if not glob.SILENT:
201-
print("Your model was successfully uploaded. \n")
202+
print("Your model was successfully uploaded to Scailable!")
203+
print("NOTE: After transpiling, we will send you an email and your model will be available at "
204+
"https://admin.sclbl.net.")
205+
print("Or, alternatively, you can use the 'endpoints()' function to list all your uploaded models. \n")
202206

203207
# remove bundle:
204208
if not _keep:
@@ -643,8 +647,7 @@ def endpoints(_verbose=True) -> dict:
643647
result = json.loads(response.text)
644648
except Exception as e:
645649
if not glob.SILENT:
646-
print("We were unable retrieve your endpoints. \n"
647-
"Please try again later.")
650+
print("We were unable retrieve your endpoints.")
648651
if glob.DEBUG:
649652
raise UserManagerError("Unable to retrieve endpoints. " + str(e))
650653
return False
@@ -653,10 +656,27 @@ def endpoints(_verbose=True) -> dict:
653656
if _verbose and not glob.SILENT:
654657
if not result:
655658
print("You currently do not own any active endpoints.")
659+
print("\nNeed help getting started?")
660+
print(" - See the sclblpy docs at https://pypi.org/project/sclblpy/.")
661+
print(" - See our getting started tutorial at "
662+
"https://github.com/scailable/sclbl-tutorials/tree/master/sclbl-101-getting-started.")
663+
print(" - Or, login to your admin at https://admin.sclbl.net. \n")
664+
print("NOTE: if you have just uploaded a model, please check your email; we will let you know when its "
665+
"available!\n")
656666
else:
657-
print("You currently own the following endpoints:")
667+
# Pretty printing of list
668+
baseUrl = glob.EXAMPLE__BASE_URL
669+
i = 1
670+
print("You currently own the following endpoints:\n")
658671
for key in result:
659-
print('Name: {}, cfid: {}.'.format(key['name'], key['cfid']))
672+
url = baseUrl + "?cfid=" + key['cfid']
673+
url += "&exin=" + urllib.parse.quote(key['exampleinput'])
674+
675+
print(' {}: {}, \n'
676+
' - cfid: {} \n'
677+
' - example: {} \n'.format(i, key['name'], key['cfid'], url))
678+
i = i+1
679+
print("Login at https://admin.sclbl.net to administer your endpoints and see integration examples.\n")
660680

661681
return result
662682

sclblpy/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Central place for version numbering:
2-
__version__ = "0.1.4"
2+
__version__ = "0.1.5"

test/test_main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ def test_user_utils():
170170
print(glob.TOOLCHAIN_URL)
171171
print(glob.TASK_MANAGER_URL)
172172

173+
#endpoints()
174+
#test_upload()
175+
#endpoints()
176+
#exit()
177+
173178
if not PRINTING:
174179
stop_print()
175180

0 commit comments

Comments
 (0)