code: def getMasterAddress(
      namespace: str,
      service_name: str,
      master_port: str,
      node_port: str,
      service_host: str,
      service_port: str,
      token: str,
  ) -> str:
      target_service = f"determined-master-service-{service_name}"
  
      if node_port != "true":
          for i in range(300):  # 5 minutes
              services = requests.get(
                  url=f"https://{service_host}:{service_port}/api/v1/namespaces/{namespace}/services",
                  headers={"Authorization": f"Bearer {token}"},
                  verify=False,
              ).json()
  
              for svc in services["items"]:
                  if target_service in svc["metadata"]["name"]:
                      status = svc["status"]["loadBalancer"]
                      if (
                          "ingress" not in svc["status"]["loadBalancer"]
                          or status["ingress"] is None
                      ):
                          time.sleep(1)  # 1 second and loop
                          break
                      if status["ingress"][0].get("hostname"):
                          # use hostname over ip address, if available
                          return f"{status['ingress'][0]['hostname']}:{master_port}"
                      else:
                          return f"{status['ingress'][0]['ip']}:{master_port}"
      else:
          services = requests.get(
              url=f"https://{service_host}:{service_port}/api/v1/namespaces/{namespace}/services",
              headers={"Authorization": f"Bearer {token}"},
              verify=False,
          ).json()
  
          for svc in services["items"]:
              if target_service in svc["metadata"]["name"]:
                  # entrypoint = f"{svc['spec']['cluster_ip']}:{master_port}"
                  entrypoint = (
                      f"{svc['spec']['clusterIP']}:{master_port}"
                  )
                  checkPortAlive(entrypoint)
  
                  return entrypoint
      return ""
  
file_path: determined/helm/charts/determined/scripts/k8s-password-change.py
imports: import json
  import sys
  import time
  from typing import List
  import requests
label_desc: Use image node_id 3 for calling a global function with example usage: getMasterAddress(namespace, service_name, master_port, node_port, service_host, service_port, token) and returns: str, entrypoint, status, str, master_port, status, str, master_port