code: def main(unused_argv):
      delete_if_exists(FLAGS.output_file)
  
      # Setup Spark
  
      # Here, we use one worker thread to load the file as 1 partition.
      # For a truly distributed calculation, connect to a Spark cluster (e.g.
      # running on some cloud provider).
      master = "local[1]"  # use one worker thread to load the file as 1 partition
      conf = pyspark.SparkConf().setMaster(master)
      sc = pyspark.SparkContext(conf=conf)
      movie_views = sc.textFile(FLAGS.input_file).mapPartitions(
          parse_partition
      )
  
      # Define the privacy budget available for our computation.
      budget_accountant = pipeline_dp.NaiveBudgetAccountant(
          total_epsilon=1, total_delta=1e-6
      )
  
      # Wrap Spark's RDD into its private version
      private_movie_views = make_private(
          movie_views, budget_accountant, lambda mv: mv.user_id
      )
  
      explain_computation_report = (
          pipeline_dp.ExplainComputationReport()
      )
      # Calculate the private sum
      dp_result = private_movie_views.sum(
          SumParams(
              # Limits to how much one user can contribute:
              # .. at most two movies rated per user
              max_partitions_contributed=2,
              # .. at most one rating for each movie
              max_contributions_per_partition=1,
              # .. with minimal rating of "1"
              min_value=1,
              # .. and maximum rating of "5"
              max_value=5,
              # The aggregation key: we're grouping by movies
              partition_extractor=lambda mv: mv.movie_id,
              # The value we're aggregating: we're summing up ratings
              value_extractor=lambda mv: mv.rating,
          ),
          out_explain_computaton_report=explain_computation_report,
      )
  
      budget_accountant.compute_budgets()
  
      # Generate the Explain Computation Report. It must be called after
      # budget_accountant.compute_budgets().
      print(explain_computation_report.text())
  
      # Save the results
      dp_result.saveAsTextFile(FLAGS.output_file)
  
      return 0
  
file_path: pipelinedp/examples/movie_view_ratings/run_on_spark.py
imports: from absl import app
  from absl import flags
  import pyspark
  import pipeline_dp
  from pipeline_dp.private_spark import make_private
  from pipeline_dp import SumParams
  from common_utils import parse_partition
  from common_utils import delete_if_exists
label_desc: Use image node_id 1 for calling a global function with example usage: main(unused_argv) and returns: int