Skip to content

Commit 3124fe9

Browse files
John-Braggrobert-closekennydanielJohn Bragg
authored
Dev 316 (#91)
* INSIGHTS-12 Initial structure of insight functionality * INSIGHTS-12 Added todo statements * INSIGHTS-12 Moved Insights out of client * INSIGHTS-12 Adjusted insight methods to reside in the client class. Removed the ability to collect insights before sending, now the every time the user invokes the collectInsights method, it will also send. This prevents any State issues with the algorithm. * INSIGHTS-12 Added a todo. Tests fail for unknown reasons at this time * INSIGHTS-12 Fixed method call. Added a todo to get url from config if necessary. * INSIGHTS-12 Fixed method call. * INSIGHTS-12 added json serialization. might not be needed * INSIGHTS-12 commented test temporarily * INSIGHTS-12 comment updates and json .encode change * INSIGHTS-12 comment update * INSIGHTS-12 changed method signatures to match documentation https://insights1.enthalpy.click/developers/clients/python#publishing-algorithmia-insights * INSIGHTS-12 Added system property for queue reader url * INSIGHTS-12 Fixed URL to not be https * INSIGHTS-12 minor version update * INSIGHTS-12 revert change * INSIGHTS-12 removed todo * INSIGHTS-12 uncommented test. May start failing again in the pipeline. * INSIGHTS-12 commented test. * INSIGHTS-12 changed version. Removed unused import. * INSIGHTS-12 changed url to include /v1/ * Allow listing of non-data:// files on cli * Allow catting non-data:// files on cli * Fix tests * adding list languages to library and CLI * adding error check in test * adding client unit test * change assertion in unit test Co-authored-by: robert-close <[email protected]> Co-authored-by: Kenny Daniel <[email protected]> Co-authored-by: Kenny Daniel <[email protected]> Co-authored-by: John Bragg <[email protected]>
1 parent 7c2de07 commit 3124fe9

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

Algorithmia/CLI.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,20 @@ def cp(self, src, dest, client):
287287
else:
288288
print("at least one of the operands must be a path to a remote data source data://")
289289

290+
291+
def list_languages(self, client):
292+
response = client.get_supported_languages()
293+
return response
294+
295+
290296
def getBuildLogs(self, user, algo, client):
291297
api_response = client.algo(user+'/'+algo).build_logs()
292298

293299
if "error" in api_response:
294300
return json.dumps(api_response)
295301
return json.dumps(api_response['results'], indent=1)
296302

303+
297304
def getconfigfile(self):
298305
if(os.name == "posix"):
299306
#if!windows

Algorithmia/__main__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,17 @@ def main():
107107
parser_cat.add_argument('path', nargs = '*', help = 'file(s) to concatenate and print')
108108
parser_cat.add_argument('--profile', action = 'store', type = str, default = 'default')
109109

110+
111+
#sub parser for listing languages
112+
subparsers.add_parser('languages', help = 'lists supported languages')
113+
110114
#sub parser for builds
111115
parser_builds = subparsers.add_parser('builds', help = 'builds <user> <algo> gets build logs for algorithm')
112116
parser_builds.add_argument('user')
113117
parser_builds.add_argument('algo',help='algorithm name')
114118

115119
#sub parser for help
120+
116121
subparsers.add_parser('help')
117122
parser.add_argument('--profile', action = 'store', type = str, default = 'default')
118123

@@ -185,6 +190,12 @@ def main():
185190

186191
elif args.cmd == 'cat':
187192
print(CLI().cat(args.path, client))
193+
194+
elif args.cmd == 'languages':
195+
response = CLI().list_languages(client)
196+
print("{:<25} {:<35}".format('Name','Description'))
197+
for lang in response:
198+
print("{:<25} {:<35}".format(lang['name'],lang['display_name']))
188199

189200
elif args.cmd == 'builds':
190201
print(CLI().getBuildLogs(args.user, args.algo, client))

Algorithmia/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ def invite_to_org(self,orgname,username):
114114
response = self.putHelper(url,data={})
115115
return response
116116

117+
def get_supported_languages(self):
118+
url ="/v1/algorithm-environments/edge/languages"
119+
response = self.getHelper(url)
120+
return response.json()
121+
117122

118123
# Used to send insight data to Algorithm Queue Reader in cluster
119124
def report_insights(self, insights):

Test/CLI_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ def test_auth_cert(self):
171171
self.assertEqual(resultA, address)
172172
self.assertEqual(resultC, cacert)
173173

174+
def test_list_languages(self):
175+
result = CLI().list_languages(self.client)
176+
if("error" in result):
177+
print(result)
178+
self.assertTrue(result is not None and "name" in result[0])
179+
180+
174181
def test_rm(self):
175182
localfile = "./TestFiles/testRM.txt"
176183

Test/client_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ def test_edit_org(self):
6767
response = self.c.edit_org(orgname,obj)
6868
self.assertEqual(204,response.status_code)
6969

70+
def test_get_supported_languages(self):
71+
client = Algorithmia.client(api_key=os.environ.get('ALGORITHMIA_API_KEY'))
72+
response = client.get_supported_languages()
73+
language_found = any('anaconda3' in languages['name'] for languages in response)
74+
if("error" in response):
75+
print(response)
76+
self.assertTrue(response is not None and language_found)
77+
7078
def test_invite_to_org(self):
7179
response = self.c.invite_to_org("a_myOrg38","a_Mrtest4")
7280
self.assertEqual(200,response.status_code)

0 commit comments

Comments
 (0)