Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# Authors: Sylvain MARIE <sylvain.marie@se.com> 

2# + All contributors to <https://github.com/smarie/python-azureml-client> 

3# 

4# License: 3-clause BSD, <https://github.com/smarie/python-azureml-client/blob/master/LICENSE> 

5from azmlclient.base_databinding import azmltable_to_df 

6 

7 

8class AzuremlWebServiceMock(object): 

9 """ 

10 A mock of azureML exposing web services, compliant with CherryPY 

11 """ 

12 name = None 

13 

14 def GET(self): 

15 return "Hello World! This is service " + self.name 

16 

17 def unpack_azureml_query(self, 

18 json_dct, 

19 input_names=(), 

20 swagger_mode=None, # type: bool 

21 ): 

22 """ 

23 

24 :param json_dct: 

25 :param input_names: 

26 :param swagger_mode: 

27 :return: 

28 """ 

29 # support single string input. convert to tuple in that case 

30 if isinstance(input_names, str): 30 ↛ 33line 30 didn't jump to line 33, because the condition on line 30 was never false

31 input_names = (input_names, ) 

32 

33 inputs_dct = json_dct['Inputs'] 

34 global_params_dct = json_dct['GlobalParameters'] 

35 

36 # return CollectionConverters.azmltables_to_dfs(json_dct['Inputs']), 

37 input_dfs = dict() 

38 for input_name, dict_table in inputs_dct.items(): 

39 if input_name not in input_names: 39 ↛ 40line 39 didn't jump to line 40, because the condition on line 39 was never true

40 raise ValueError("Invalid input received. Supported inputs are: %s" % input_names) 

41 

42 input_dfs[input_name] = azmltable_to_df(dict_table, is_azml_output=False, table_name=input_name, 

43 swagger_mode=swagger_mode) 

44 

45 return input_dfs, global_params_dct