Best Python code snippet using lisa_python
data_load.py
Source:data_load.py
...20def metadata_q4():21 folder = 'data/8newsgroup'22 path = os.path.join(folder, 'train.trec')23 data = read_file(os.path.join(path, 'feature_settings.txt'), ',')24 data = get_feature_settings(data)25 return data26def metadata_q4_labels():27 folder = 'data/8newsgroup'28 path = os.path.join(folder, 'train.trec')29 data = read_file(os.path.join(path, 'data_settings.txt'), ',')30 data = get_label_settings(data)31 return data32def get_label_settings(data):33 dsettings = {}34 for i in range(len(data)):35 for j in range(len(data[i])):36 srow = data[i][j].split('=')37 if len(srow) != 2:38 print srow39 else:40 ftype = srow[0]41 fval = srow[1]42 if ftype == 'intId':43 idx = int(fval)44 elif ftype == 'extLabel':45 name = fval46 if name not in dsettings.keys():47 dsettings[name] = [idx]48 else:49 dsettings[name].append(idx)50 return dsettings51def get_feature_settings(data):52 fsettings = {}53 for i in range(len(data)):54 for j in range(len(data[i])):55 srow = data[i][j].split('=')56 if len(srow) != 2:57 print srow58 else:59 ftype = srow[0]60 fval = srow[1]61 if ftype == 'featureIndex':62 idx = int(fval)63 elif ftype == 'featureName':64 name = fval65 if name not in fsettings.keys():...
datamgt.py
Source:datamgt.py
...14 parser.add_argument('--region', type=str, nargs=1, required=False, help='sourceRegion us(default) or eu')15 parser.add_argument('--featureSettings', dest='featureSettings', required=False, action='store_true',16 help='Query Feature Settings')17 return parser18def get_feature_settings(user_api_key, from_file, region):19 acct_ids = store.load_names(from_file)20 feature_settings = [['accountId', 'key','name', 'enabled']]21 for acct_id in acct_ids:22 result = dmc.get_feature_settings(user_api_key, int(acct_id), region)23 logger.info(json.dumps(result))24 for featureSetting in result['response']['data']['actor']['account']['dataManagement']['featureSettings']:25 feature_settings.append([acct_id, featureSetting['key'], featureSetting['name'], featureSetting['enabled']])26 logger.info(feature_settings)27 store.save_feature_settings_csv(feature_settings)28def main():29 parser = configure_parser()30 args = parser.parse_args()31 user_api_key = utils.ensure_user_api_key(args)32 if not user_api_key:33 utils.error_and_exit('userApiKey', 'ENV_USER_API_KEY')34 region = utils.ensure_region(args)35 if args.featureSettings:36 get_feature_settings(user_api_key, args.accounts[0], region)37 else:38 logger.info("pass --featureSettings to fetch featureSettings")39if __name__ == '__main__':...
datamgtclient.py
Source:datamgtclient.py
...7class DataManagementClient:8 def __init__(self):9 pass10 @staticmethod11 def get_feature_settings(user_api_key, account_id, region):12 payload = DataManagementClient._query_feature_settings_payload(account_id)13 logger.debug(json.dumps(payload))14 return nerdgraph.GraphQl.post(user_api_key, payload, region)15 @staticmethod16 def _query_feature_settings_payload(account_id):17 query = '''query($accountId: Int!) { 18 actor {19 account(id: $accountId) { dataManagement {20 featureSettings {21 enabled22 key23 name24 }25 }}...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!