code: def test_launcher_config_file():
      """verifies that we generate the static caliban launcher config file
      properly for different scenarios"""
  
      # test config file without mlflow
      with tempfile.TemporaryDirectory() as tmpdir:
          cfg = {
              "path": tmpdir,
              "caliban_config": {
                  "base_image": "gcr.io/blueshift-playground/blueshift:cpu",
                  "apt_packages": ["curl"],
              },
          }
  
          cfg_fname = ""
          with um.launcher_config_file(**cfg) as fname:
              cfg_fname = fname
              assert fname is not None
              assert os.path.exists(fname)
              assert fname == os.path.join(
                  tmpdir, um.LAUNCHER_CONFIG_FILE
              )
  
              with open(fname, "r") as f:
                  lcfg = json.load(f)
  
              assert isinstance(lcfg, dict)
              assert "services" in lcfg
              assert "env" in lcfg
              services = lcfg["services"]
              env = lcfg["env"]
              assert isinstance(services, list)
              assert isinstance(env, dict)
              assert len(services) == 0
  
          # make sure we clean up
          assert not os.path.exists(cfg_fname)
  
      # test config file with mlflow
      with tempfile.TemporaryDirectory() as tmpdir:
          project = "foo-project"
          region = "foo-region"
          db = "foo-db"
          user = "foo-user"
          password = "foo-password"
          artifact_root = "foo-artifact-root"
  
          cfg = {
              "path": tmpdir,
              "caliban_config": {
                  "base_image": "gcr.io/blueshift-playground/blueshift:cpu",
                  "apt_packages": ["curl"],
                  "mlflow_config": {
                      "project": project,
                      "region": region,
                      "db": db,
                      "user": user,
                      "password": password,
                      "artifact_root": artifact_root,
                  },
                  "uv": {
                      "mlflow": {
                          "pubsub_topic": "mlflow",
                      }
                  },
              },
          }
  
          proxy_config = {
              "proxy": os.path.join(
                  os.sep, "usr", "bin", "cloud_sql_proxy"
              ),
              "path": "/tmp/cloudsql",
              "project": project,
              "region": region,
              "db": db,
              "creds": "~/.config/gcloud/application_default_credentials.json",
          }
  
          proxy_cmd = [
              "python",
              os.path.join(
                  um.RESOURCE_DIR, um.CLOUD_SQL_WRAPPER_SCRIPT
              ),
              proxy_config,
          ]
  
          cfg_fname = ""
          with um.launcher_config_file(**cfg) as fname:
              cfg_fname == fname
              assert fname is not None
              assert os.path.exists(fname)
              assert fname == os.path.join(
                  tmpdir, um.LAUNCHER_CONFIG_FILE
              )
  
              with open(fname, "r") as f:
                  lcfg = json.load(f)
  
              assert isinstance(lcfg, dict)
              assert "services" in lcfg
              assert "env" in lcfg
  
              services = lcfg["services"]
              env = lcfg["env"]
  
              assert isinstance(services, list)
              assert isinstance(env, dict)
              assert len(services) == 1
  
              cfg_proxy_cmd = services[0]
              assert cfg_proxy_cmd[0] == proxy_cmd[0]
              assert cfg_proxy_cmd[1] == proxy_cmd[1]
              cfg_proxy_config = proxy_cmd[2]
              for k, v in proxy_config.items():
                  assert k in cfg_proxy_config
                  assert cfg_proxy_config[k] == v
  
          # make sure we clean up appropriately
          assert not os.path.exists(cfg_fname)
  
file_path: caliban/tests/caliban/util/test_metrics.py
imports: import json
  import os
  import tempfile
  import caliban.util
  import caliban.util.metrics
label_desc: Use image node_id 4 for calling a global function with example usage: test_launcher_config_file() without return types