code: def _edit_ipython_profile(spark_home, sys_path=None):
      """Adds a startup file to the current IPython profile to import pyspark.
  
      The startup file sets the required environment variables and imports pyspark.
  
      Parameters
      ----------
      spark_home : str
          Path to Spark installation.
      sys_path : list(str)
          Paths to be added to sys.path.
          Should include python subdirectory of Spark installation, py4j
      """
      from IPython import get_ipython
  
      ip = get_ipython()
  
      if ip:
          profile_dir = ip.profile_dir.location
      else:
          from IPython.utils.path import locate_profile
  
          profile_dir = locate_profile()
  
      startup_file_loc = os.path.join(
          profile_dir, "startup", "findspark.py"
      )
  
      with open(startup_file_loc, "w") as startup_file:
          # Lines of code to be run when IPython starts
          startup_file.write("import sys, os\n")
          startup_file.write(
              "os.environ['SPARK_HOME'] = {}\n".format(repr(spark_home))
          )
          if sys_path:
              startup_file.write(
                  "sys.path[:0] = {}\n".format(repr(sys_path))
              )
          startup_file.write("import pyspark\n")
  
file_path: findspark/findspark.py
imports: from glob import glob
  import os
  import sys
label_desc: Use image node_id 3 for calling a global function with example usage: _edit_ipython_profile(spark_home, sys_path) without return types