Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added synapse-internal to platform detector function #1651

Merged
merged 13 commits into from
Sep 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion core/src/main/python/synapse/ml/core/platform/Platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os


PLATFORM_SYNAPSE_INTERNAL = "synapse_internal"
PLATFORM_SYNAPSE = "synapse"
PLATFORM_BINDER = "binder"
PLATFORM_DATABRICKS = "databricks"
Expand All @@ -13,7 +14,14 @@

def current_platform():
if os.environ.get("AZURE_SERVICE", None) == SYNAPSE_PROJECT_NAME:
return PLATFORM_SYNAPSE
from pyspark.sql import SparkSession

sc = SparkSession.builder.getOrCreate().sparkContext
cluster_type = sc.getConf().get("spark.cluster.type")
if cluster_type == "synapse":
return PLATFORM_SYNAPSE
else:
return PLATFORM_SYNAPSE_INTERNAL
elif "dbfs" in os.listdir("/"):
return PLATFORM_DATABRICKS
elif os.environ.get("BINDER_LAUNCH_HOST", None) is not None:
Expand All @@ -22,6 +30,10 @@ def current_platform():
return PLATFORM_UNKNOWN


def running_on_synapse_internal():
return current_platform() is PLATFORM_SYNAPSE_INTERNAL


def running_on_synapse():
return current_platform() is PLATFORM_SYNAPSE

Expand Down