Reference Cleanup
Utility
Reference Cleanup
Remove stale reference instances, mappings, and personas
USERNAME = "_FILL_ME_IN_" # Your email — used to derive the reference namespaceimport osimport time
from notebook_setup import make_namespacefrom graph_olap import GraphOLAPClient
namespace = make_namespace(USERNAME)analyst_username = f"analyst@e2e.{namespace}.local"
print(f"Cleaning reference namespace: {namespace}")print(f" analyst: {analyst_username}")
# 1. Terminate instancesterminated = 0client = GraphOLAPClient(username=analyst_username)for status in ("running", "starting", "waiting_for_snapshot"): for inst in client.instances.list(owner=analyst_username, status=status, limit=200).items: try: client.instances.terminate(inst.id) terminated += 1 print(f" Terminated instance {inst.id} ({inst.name})") except Exception: passclient.close()
if terminated > 0: print(" Waiting 5s for snapshot cascade...") time.sleep(5)
# 2. Delete mappingsdeleted = 0client = GraphOLAPClient(username=analyst_username)for m in client.mappings.list(owner=analyst_username, limit=200).items: try: client.mappings.delete(m.id) deleted += 1 print(f" Deleted mapping {m.id} ({m.name})") except Exception as e: print(f" Failed to delete mapping {m.id}: {e}")client.close()
# 3. Deactivate personasdeactivated = 0ops_client = GraphOLAPClient(username=ops_username)for role in ("analyst", "admin", "ops"): persona = f"{role}@e2e.{namespace}.local" try: ops_client.users.deactivate(persona) deactivated += 1 print(f" Deactivated persona: {persona}") except Exception: passops_client.close()
print(f"\nDone: {terminated} instances, {deleted} mappings, {deactivated} personas")