Forum Discussion
cmilanes932211
1 year agoAdvocate I
Parallelization on Fabric using TF_on Spark
Hi, im trying to print a hello world using this code: import os import datetime import numpy as np import pandas as pd # PySpark / Spark from pyspark.sql import SparkSession # TensorFlo...
Roheveski78
1 year agoNew Member
Your code is mostly correct, but there are a few issues that may prevent it from running properly:
Issues in Your Code
-
Syntax Error in map_fun Definition
- The function definition contains a misplaced : after ctx😞, likely a copy-paste issue.
- Correct syntax:
pythonCopyEditdef map_fun(tf_args, ctx😞
-
Spark Context (sc) Initialization Issue
- TFCluster.run expects sc (SparkContext), but in your code, you are passing spark.sparkContext. This should work, but if any errors arise, explicitly create a SparkContext:
pythonCopyEditfrom pyspark import SparkContext sc = SparkContext.getOrCreate()
- TFCluster.run expects sc (SparkContext), but in your code, you are passing spark.sparkContext. This should work, but if any errors arise, explicitly create a SparkContext:
-
Printing ctx Directly Doesn't Work as Expected
- Instead of print('ctx'), you likely meant to print the actual context:
pythonCopyEditprint(ctx)
- Instead of print('ctx'), you likely meant to print the actual context:
-
Cluster Shutdown
- The line # cluster.shutdown() is commented out. You might want to ensure that the cluster shuts down after execution to free up