Spaces:
Running
Running
mike boone commited on
Commit ·
e343cfd
1
Parent(s): 7aff9ba
fix: normalize ThoughtSpot TML import object responses
Browse filesFiles changed (2)
146 unmodified lines147148149146 unmodified linesassert "retrying full {retry_kind} payload once" in sourceassert "connection_fqn=connection_fqn" in sourceassert "wait_for_model_answer_ready" in source146 unmodified lines147148149150146 unmodified linesassert "retrying full {retry_kind} payload once" in sourceassert "connection_fqn=connection_fqn" in sourceassert "wait_for_model_answer_ready" in sourceassert 'if "status" in obj or "header" in obj' in source
2345 unmodified lines23462347234823492350235123522353235423552356235723582359236023612362236385 unmodified lines2449245024512452245324542455245624572458245924604 unmodified lines2465246624672468246924702345 unmodified linesbatch1_start = time.time()log_progress(f"Batch 1/2: Creating {table_count} tables...")def _normalize_tml_import_objects(result):if isinstance(result, list):return resultif isinstance(result, dict) and 'object' in result:return result['object']return Nonedef _tml_objects_by_name(expected_names, objects):named = {}for idx, obj in enumerate(objects or []):header = obj.get('response', {}).get('header', {}) if isinstance(obj, dict) else {}raw_name = header.get('name') or header.get('display_name')table_name = (raw_name or (expected_names[idx] if idx < len(expected_names) else f"TABLE_{idx}")).upper()named[table_name] = objreturn named85 unmodified linesobject_count = len(objects) if isinstance(objects, list) else 0object_statuses = []object_names = []for obj in objects or []:obj_response = obj.get('response', {}) if isinstance(obj, dict) else {}status = obj_response.get('status', {})header = obj_response.get('header', {})object_statuses.append(status.get('status_code'))object_names.append(header.get('name') or header.get('display_name'))if _slog:_slog.log("thoughtspot",4 unmodified linesobject_count=object_count,object_statuses=object_statuses,object_names=[name for name in object_names if name],)if objects is None:error = f"{phase_label} failed: Unexpected response format: {type(response_json)}"2345 unmodified lines234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237685 unmodified lines246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324844 unmodified lines24892490249124922493249424952345 unmodified linesbatch1_start = time.time()log_progress(f"Batch 1/2: Creating {table_count} tables...")def _normalize_tml_import_object(obj):if not isinstance(obj, dict):return objif "response" in obj:return objif "status" in obj or "header" in obj:return {"response": obj}return objdef _normalize_tml_import_objects(result):if isinstance(result, list):return [_normalize_tml_import_object(obj) for obj in result]if isinstance(result, dict) and 'object' in result:return [_normalize_tml_import_object(obj) for obj in result['object']]return Nonedef _tml_objects_by_name(expected_names, objects):named = {}for idx, obj in enumerate(objects or []):header = obj.get('response', {}).get('header', {}) if isinstance(obj, dict) else {}raw_name = (header.get('name')or header.get('display_name')or header.get('displayName'))table_name = (raw_name or (expected_names[idx] if idx < len(expected_names) else f"TABLE_{idx}")).upper()named[table_name] = objreturn named85 unmodified linesobject_count = len(objects) if isinstance(objects, list) else 0object_statuses = []object_names = []object_errors = []for obj in objects or []:obj_response = obj.get('response', {}) if isinstance(obj, dict) else {}status = obj_response.get('status', {})header = obj_response.get('header', {})object_statuses.append(status.get('status_code'))object_names.append(header.get('name') or header.get('display_name') or header.get('displayName'))if status.get('error_message'):object_errors.append(str(status.get('error_message'))[:300])status_summary = ", ".join(str(status) for status in object_statuses if status)if status_summary:log_progress(f" {phase_label}: response objects={object_count}; "f"statuses={status_summary}")if object_errors:log_progress(f" {phase_label}: first object error: {object_errors[0]}")if _slog:_slog.log("thoughtspot",4 unmodified linesobject_count=object_count,object_statuses=object_statuses,object_names=[name for name in object_names if name],object_errors=object_errors[:5],)if objects is None:error = f"{phase_label} failed: Unexpected response format: {type(response_json)}"
tests/test_liveboard_creation_context.py+1
thoughtspot_deployer.py+29-4