def main(): print('Test: Default') api.set_port_callback(inports[0]['name'], call_on_input) print('Test: config') config = api.config config.columns = 'All' config.info_only = True df = pd.DataFrame({ 'icol': [1, 1, 1, 1, 1], 'xcol2': ['A', 'A', 'B', 'B', 'C'], 'xcol3': ['A', 'A', 'C', 'D', 'E'], 'xcol4': ['A', 'A', 'b', 'a', 'c'], 'xcol5': ['A', 'A', 'A', 'A', 'A'] }) test_msg = api.Message(attributes={'name': 'test1'}, body=df) log, data, trans = api.call(config, test_msg) print('Attributes: ', data.attributes) print('Body: ', str(data.body)) print('Attributes: ', trans.attributes) print('Body: ', str(trans.body)) print('Logging: ') print(log) gs.gensolution(os.path.realpath(__file__), config, inports, outports, override_readme=True)
def main(): print('Test: Default') api.set_port_callback(inports[0]['name'], call_on_input) print('Test: config') config = api.config config.label = 'icol' config.split = 0.2 config.to_category = True df = pd.DataFrame({ 'icol': [1, 1, 3, 3, 3], 'col2': [1, 2, None, 4, 5], 'col3': [2, 3, 4, 5, 6], 'col4': [5, 6.5, 7.5, 8, 9], 'col5': [6, 6.7, 8.2, None, 10.1], 'col6': ['A', 'A', 'B', 'B', 'C'] }) attributes = {'format': 'csv', 'name': 'DF_name'} input_msg = api.Message(attributes=attributes, body=df) log, train_msg, test_msg = api.call(config, input_msg) print('Input') print(input_msg.body) print('Train') print(train_msg.body) print('Test') print(test_msg.body) print('Logging: ') print(log) gs.gensolution(os.path.realpath(__file__), config, inports, outports, override_readme=True)
def main(): print('Test: Default') api.set_port_callback(inports[0]['name'], call_on_input) print('Test: config') config = api.config config.to_nan = '0' config.anonymize_cols = 'col3,col4,col5' config.anonymize_to_int_cols = 'icol, col2' config.enumerate_cols = 'col3, col4, col5' config.prefix_cols = 'Att' df = pd.DataFrame( {'icol': [1, 2, 3, 4, 5], 'col2': ['Cydia', 'Cydia', None, 'Dani', 'Liza'], \ 'col3': ['Frank', 'Stephen', 'Hubert', 'Hubert', 'Sue'], 'col4': [5, 6.5, 7.5, 8, 9], 'col5': [6, 7, 8, 9, 10]}) attributes = {'format': 'csv', 'name': 'DF_name', 'process_list': []} print(df.dtypes) test_msg = api.Message(attributes=attributes, body=df) log, new_msg = api.call(config, test_msg) print('Attributes: ', new_msg.attributes) print('Body: ', str(new_msg.body)) print('Logging: ') print(log) gs.gensolution(os.path.realpath(__file__), config, inports, outports, override_readme=True)
def main(): print('Test: Default') #api.set_port_callback(inports[0]['name'], call_on_input) print('Test: config') config = api.config config.train_cols = 'icol, col2, col3, col4' config.label_col = 'col5' df = pd.DataFrame({ 'icol': [1, 1, 3, 3, 3], 'col2': [1, 2, 3, 4, 5], 'col3': [2, 3, 4, 5, 6], 'col4': [5, 6.5, 7.5, 8, 9], 'col5': [6, 6.7, 8.2, 9, 10.1] }) attributes = {'format': 'csv', 'name': 'DF_name'} train_msg = api.Message(attributes=attributes, body=df) log, new_msg = api.call(config, train_msg) print('Attributes: ', new_msg.attributes) print('Body: ', str(new_msg.body)) print('Logging: ') print(log) gs.gensolution(os.path.realpath(__file__), config, inports, outports, override_readme=True)
def main() : print('Test: Default') api.set_port_callback(inports[0]['name'], call_on_input) print('Test: config') config = api.config config.var1 = 'own foo' config.var12 = 'own bar' test_msg = api.Message(attributes={'name':'test1'},body =4) new_msg, log = api.call(config,test_msg) print('Attributes: ', new_msg.attributes) print('Body: ', str(new_msg.body)) print('Logging: ') print(log) gs.gensolution(os.path.realpath(__file__), config, inports, outports,override_readme=True)
outports = [{'name': 'log', 'type': 'string', "description": "Logging data"}, \ {'name': 'data', 'type': 'message', "description": "sql statement"}] #api.add_generator(process) def test_operator(): api.config.columns = '"ID", "TEXT_AS_NVARCHAR" as "TEXT"' api.config.debug_mode = True api.config.table_name = '"${schema}"."bpanceditor.db::news.V_editorInbox_TextAs_nvarchar" where "ARTIFACT_TYPE" not in (\'NEWSTICKER\')' process() if __name__ == '__main__': test_operator() if True: subprocess.run([ "rm", '-r', '/Users/d051079/OneDrive - SAP SE/GitHub/di_textanalysis/solution/operators/textanalysis_' + api.config.version ]) gs.gensolution(os.path.realpath(__file__), api.config, None, outports) solution_name = api.config.operator_name + '_' + api.config.version subprocess.run(["vctl", "solution", "bundle", '/Users/d051079/OneDrive - SAP SE/GitHub/di_textanalysis/solution/operators/textanalysis_'+ api.config.version,\ "-t", solution_name]) subprocess.run( ["mv", solution_name + '.zip', '../../../solution/operators'])