示例#1
0
def stop_orca_context():
    """
    Stop the SparkContext (and stop Ray services across the cluster if necessary).
    """
    from pyspark import SparkContext
    from zoo.ray import RayContext
    ray_ctx = RayContext.get(initialize=False)
    if ray_ctx.initialized:
        ray_ctx.stop()
    sc = SparkContext.getOrCreate()
    if sc.getConf().get("spark.master").startswith("spark://"):
        from zoo import stop_spark_standalone
        stop_spark_standalone()
    sc.stop()
示例#2
0
def stop_orca_context():
    """
    Stop the SparkContext (and stop Ray services across the cluster if necessary).
    """
    from pyspark import SparkContext
    # If users successfully call stop_orca_context after the program finishes,
    # namely when there is no active SparkContext, the registered exit function
    # should do nothing.
    if SparkContext._active_spark_context is not None:
        print("Stopping orca context")
        from zoo.ray import RayContext
        ray_ctx = RayContext.get(initialize=False)
        if ray_ctx.initialized:
            ray_ctx.stop()
        sc = SparkContext.getOrCreate()
        if sc.getConf().get("spark.master").startswith("spark://"):
            from zoo import stop_spark_standalone
            stop_spark_standalone()
        sc.stop()