You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否通过Databricks Connect创建Job Cluster?求PyCharm替代创建方案

绕过Databricks Connect在PyCharm中创建Job Cluster的方案

有几种可行的替代方案,不需要依赖Databricks Connect就能在PyCharm里创建Job Cluster:

1. 使用Databricks CLI直接创建

在PyCharm的终端中配置Databricks CLI,通过命令行直接创建Job Cluster:

  • 先安装CLI:pip install databricks-cli
  • 配置Workspace认证:databricks configure --token,输入Workspace URL和个人访问令牌
  • 创建一个JSON配置文件(比如job-cluster-config.json),内容示例:
{
  "spark_version": "13.3.x-scala2.12",
  "node_type_id": "Standard_DS3_v2",
  "num_workers": 2,
  "autoscale": {
    "min_workers": 1,
    "max_workers": 4
  },
  "cluster_name": "temp-job-cluster",
  "spark_env_vars": {
    "PYSPARK_PYTHON": "/databricks/python3/bin/python3"
  },
  "termination_time_minutes": 60
}
  • 执行创建命令:databricks clusters create --json-file job-cluster-config.json

2. 调用Databricks REST API编写脚本创建

在PyCharm里写Python脚本,直接调用Databricks的集群创建API:

import requests

# 配置Workspace信息和认证令牌
workspace_url = "https://<your-workspace-url>.databricks.com"
token = "<your-personal-access-token>"
headers = {"Authorization": f"Bearer {token}"}

# 构造Job Cluster配置
cluster_config = {
    "spark_version": "13.3.x-scala2.12",
    "node_type_id": "Standard_DS3_v2",
    "num_workers": 2,
    "cluster_name": "api-created-job-cluster",
    "termination_time_minutes": 60
}

# 发送创建请求
response = requests.post(
    f"{workspace_url}/api/2.0/clusters/create",
    json=cluster_config,
    headers=headers
)

if response.status_code == 200:
    print(f"Cluster created successfully, ID: {response.json()['cluster_id']}")
else:
    print(f"Failed to create cluster: {response.text}")

运行这个脚本就能直接创建Job Cluster,还可以根据需求修改配置参数。

3. 使用PyCharm的Databricks插件

在PyCharm的插件市场搜索并安装官方或第三方的Databricks插件(比如"Databricks Integration"),配置好Workspace连接后:

  • 打开插件的集群管理界面
  • 点击创建集群选项,选择Job Cluster类型
  • 填写集群的Spark版本、节点类型、worker数量等参数
  • 确认后直接创建,整个过程在IDE界面完成,不需要写代码或命令

注意事项

  • Job Cluster是临时集群,任务执行完毕后会自动终止,创建时可以设置termination_time_minutes来控制闲置超时时间
  • 确保使用的认证令牌有足够的权限创建集群(需要clusters.create权限)
  • 配置集群参数时,要匹配你的任务资源需求,避免资源浪费或不足

内容的提问来源于stack exchange,提问作者Sandesh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 18:50:26