<#6471 [BUG] KeyError: 'sparkConf' occurs when run...
# flyte-github
c
#6471 [BUG] KeyError: 'sparkConf' occurs when running a Databricks task without spark_conf Issue created by rambrus ### Describe the bug ### CONTEXT I'm trying to run a Flyte task on Databricks using Databricks Connector. Specifying sparkConf is OPTIONAL in Databricks cluster definition. ### STEPS TO REPRODUCE • create a Databricks task with a config where
spark_conf
is not defined, neither under
databricks_conf
nor at top level, eg.
Copy code
task_conf=Databricks(
        databricks_conf={
            "run_name": "flyte agent basic worfkflow test",
            "new_cluster": {
                "apply_policy_default_values": "true",
                "aws_attributes": {
                    "instance_profile_arn": "...",
                    "availability": "ON_DEMAND"                    
                },              
                "docker_image": {
                    "url": "..."
                },                
                "node_type_id": "m5.large",
                "num_workers": 1,
                "policy_id": "...",          
        }
)
  
@task(task_config=task_conf)
def example_task():
      ...
    
@workflow
def wf():
    example_task()
• run the task ### ACTUAL RESULT Task failed with this error:
Copy code
Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/flytekit/extend/backend/agent_service.py", line 102, in wrapper
        res = await func(self, request, context, *args, **kwargs)
      File "/usr/local/lib/python3.10/site-packages/flytekit/extend/backend/agent_service.py", line 120, in CreateTask
        resource_meta = await mirror_async_methods(
      File "/usr/local/lib/python3.10/site-packages/flytekitplugins/spark/agent.py", line 73, in create
        data = json.dumps(_get_databricks_job_spec(task_template, task_execution_metadata))
      File "/usr/local/lib/python3.10/site-packages/flytekitplugins/spark/agent.py", line 45, in _get_databricks_job_spec
        new_cluster["spark_conf"] = custom["sparkConf"]
    KeyError: 'sparkConf'

Message:

    KeyError: 'sparkConf'.
### Expected behavior Task succeeded. This code block should default to an empty dictionary when neither
new_cluster['spark_conf']
nor
custom['sparkConf
]` is defined. ### Additional context to reproduce Either adding a dummy
spark_conf
at top level:
Copy code
task_conf=Databricks(
        spark_conf={
            "x": "y"
        },
        databricks_conf={
            ...
        }
)
or adding under `databricks_conf`:
Copy code
task_conf=Databricks(
        databricks_conf={
          ...,
          spark_conf={
              "x": "y"
          },
          ...
        }
)
can be used as a workaround. ### Screenshots No response ### Are you sure this issue hasn't been raised already? • Yes ### Have you read the Code of Conduct? • Yes flyteorg/flyte