code: def test_update_py_params(
      tmp_dir, scm, dvc, session_queue, copy_script
  ):
      tmp_dir.gen("params.py", "INT = 1\n")
      stage = dvc.run(
          cmd="python copy.py params.py metrics.py",
          metrics_no_cache=["metrics.py"],
          params=["params.py:INT"],
          name="copy-file",
      )
      scm.add(
          ["dvc.yaml", "dvc.lock", "copy.py", "params.py", "metrics.py"]
      )
      scm.commit("init")
  
      results = dvc.experiments.run(
          stage.addressing, params=["params.py:INT=2"], tmp_dir=True
      )
      exp_a = first(results)
  
      fs = scm.get_fs(exp_a)
      with fs.open("params.py", mode="r", encoding="utf-8") as fobj:
          assert fobj.read().strip() == "INT = 2"
      with fs.open("metrics.py", mode="r", encoding="utf-8") as fobj:
          assert fobj.read().strip() == "INT = 2"
  
      tmp_dir.gen(
          "params.py",
          (
              "INT = 1\nFLOAT = 0.001\nDICT = {'a': 1}\n\n"
              "class Train:\n    seed = 2020\n\n"
              "class Klass:\n    def __init__(self):\n        self.a = 111\n"
          ),
      )
      stage = dvc.run(
          cmd="python copy.py params.py metrics.py",
          metrics_no_cache=["metrics.py"],
          params=["params.py:INT,FLOAT,DICT,Train,Klass"],
          name="copy-file",
      )
      scm.add(
          ["dvc.yaml", "dvc.lock", "copy.py", "params.py", "metrics.py"]
      )
      scm.commit("init")
  
      results = dvc.experiments.run(
          stage.addressing,
          params=[
              "params.py:FLOAT=0.1",
              "params.py:Train.seed=2121",
              "params.py:Klass.a=222",
          ],
          tmp_dir=True,
      )
      exp_a = first(results)
  
      result = (
          "INT = 1\nFLOAT = 0.1\nDICT = {'a': 1}\n\n"
          "class Train:\n    seed = 2121\n\n"
          "class Klass:\n    def __init__(self):\n        self.a = 222"
      )
  
      def _dos2unix(text):
          if os.name != "nt":
              return text
  
          # NOTE: git on windows will use CRLF, so we have to convert it to LF
          # in order to compare with the original
          return text.replace("\r\n", "\n")
  
      fs = scm.get_fs(exp_a)
      with fs.open("params.py", mode="r", encoding="utf-8") as fobj:
          assert _dos2unix(fobj.read().strip()) == result
      with fs.open("metrics.py", mode="r", encoding="utf-8") as fobj:
          assert _dos2unix(fobj.read().strip()) == result
  
      tmp_dir.gen("params.py", "INT = 1\n")
      stage = dvc.run(
          cmd="python copy.py params.py metrics.py",
          metrics_no_cache=["metrics.py"],
          params=["params.py:INT"],
          name="copy-file",
      )
      scm.add(
          ["dvc.yaml", "dvc.lock", "copy.py", "params.py", "metrics.py"]
      )
      scm.commit("init")
  
      with pytest.raises(PythonFileCorruptedError):
          dvc.experiments.run(
              stage.addressing,
              params=["params.py:INT=2a"],
              tmp_dir=True,
          )
  
imports: import itertools
  import logging
  import os
  import stat
  from textwrap import dedent
  import pytest
  from configobj import ConfigObj
  from funcy import first
  from dvc.dvcfile import PROJECT_FILE
  from dvc.env import DVC_EXP_BASELINE_REV, DVC_EXP_NAME, DVC_ROOT, DVC_STUDIO_OFFLINE, DVC_STUDIO_REPO_URL, DVC_STUDIO_TOKEN, DVC_STUDIO_URL
  from dvc.exceptions import DvcException, ReproductionError
  from dvc.repo.experiments.exceptions import ExperimentExistsError
  from dvc.repo.experiments.queue.base import BaseStashQueue
  from dvc.repo.experiments.refs import CELERY_STASH
  from dvc.repo.experiments.utils import exp_refs_by_rev
  from dvc.scm import SCMError, resolve_rev
  from dvc.stage.exceptions import StageFileDoesNotExistError
  from dvc.testing.scripts import COPY_SCRIPT
  from dvc.utils.serialize import PythonFileCorruptedError
label_desc: Use image node_id 6 for calling a global function with example usage: test_update_py_params(tmp_dir, scm, dvc, session_queue, copy_script) and returns: text, text