Skip to content

Spark

create_workspace_custom_pool(workspace, display_name=None, *, auto_scale_enabled=None, min_node_count=None, max_node_count=None, dynamic_executor_allocation_enabled=None, min_executors=None, max_executors=None, node_family='MemoryOptimized', node_size='Small', df=True)

Creates a new workspace custom pool in the specified workspace.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
display_name str

The display name for the new workspace custom pool.

None
auto_scale_enabled bool

Whether auto-scaling is enabled.

None
min_node_count int

The minimum number of nodes.

None
max_node_count int

The maximum number of nodes.

None
dynamic_executor_allocation_enabled bool

Whether dynamic executor allocation is enabled.

None
min_executors int

The minimum number of executors.

None
max_executors int

The maximum number of executors. Always less than max_node_count.

None
node_family str

The node family. Default is 'MemoryOptimized'.

'MemoryOptimized'
node_size Literal['Small', 'Medium', 'Large']

The node size. Default is 'Small'.

'Small'
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
Union[DataFrame, Dict[str, Any], None]

The created workspace custom pool details if successful, otherwise None.

Examples:

create_workspace_custom_pool(
    'MyProjectWorkspace',
    'MyNewCustomPool',
    auto_scale_enabled=True,
    min_node_count=1,
    max_node_count=10,
    dynamic_executor_allocation_enabled=True,
    min_executors=1,
    max_executors=9,
    node_family='MemoryOptimized',
    node_size='Small'
)
Source code in src/pyfabricops/items/spark.py
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
@df
def create_workspace_custom_pool(
    workspace: str,
    display_name: str | None = None,
    *,
    auto_scale_enabled: bool | None = None,
    min_node_count: int | None = None,
    max_node_count: int | None = None,
    dynamic_executor_allocation_enabled: bool | None = None,
    min_executors: int | None = None,
    max_executors: int | None = None,
    node_family: str | None = "MemoryOptimized",
    node_size: Literal["Small", "Medium", "Large"] = "Small",
    df: bool | None = True,
) -> DataFrame | dict[str, Any] | None:
    """
    Creates a new workspace custom pool in the specified workspace.

    Args:
        workspace (str): The workspace name or ID.
        display_name (str, optional): The display name for the new workspace custom pool.
        auto_scale_enabled (bool, optional): Whether auto-scaling is enabled.
        min_node_count (int, optional): The minimum number of nodes.
        max_node_count (int, optional): The maximum number of nodes.
        dynamic_executor_allocation_enabled (bool, optional): Whether dynamic executor allocation is enabled.
        min_executors (int, optional): The minimum number of executors.
        max_executors (int, optional): The maximum number of executors. Always less than max_node_count.
        node_family (str, optional): The node family. Default is 'MemoryOptimized'.
        node_size (Literal['Small', 'Medium', 'Large'], optional): The node size. Default is 'Small'.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        (Union[DataFrame, Dict[str, Any], None]): The created workspace custom pool details if successful, otherwise None.

    Examples:
        ```python
        create_workspace_custom_pool(
            'MyProjectWorkspace',
            'MyNewCustomPool',
            auto_scale_enabled=True,
            min_node_count=1,
            max_node_count=10,
            dynamic_executor_allocation_enabled=True,
            min_executors=1,
            max_executors=9,
            node_family='MemoryOptimized',
            node_size='Small'
        )
        ```
    """
    workspace_id = resolve_workspace(workspace)

    payload = {}

    payload["name"] = display_name

    if auto_scale_enabled is not None:
        payload["autoScale"] = {}
        payload["autoScale"]["enabled"] = auto_scale_enabled
    if min_node_count is not None:
        payload["autoScale"]["minNodeCount"] = min_node_count
    if max_node_count is not None:
        payload["autoScale"]["maxNodeCount"] = max_node_count
    if dynamic_executor_allocation_enabled is not None:
        payload["dynamicExecutorAllocation"] = {}
        payload["dynamicExecutorAllocation"]["enabled"] = (
            dynamic_executor_allocation_enabled
        )
    if min_executors is not None:
        payload["dynamicExecutorAllocation"]["minExecutors"] = min_executors
    if max_executors is not None:
        payload["dynamicExecutorAllocation"]["maxExecutors"] = max_executors
    if node_family:
        payload["nodeFamily"] = node_family
    if node_size:
        payload["nodeSize"] = node_size

    return api_request(
        endpoint="/workspaces/" + workspace_id + "/spark/pools",
        method="post",
        payload=payload,
    )

delete_workspace_custom_pool(workspace, workspace_custom_pool)

Delete a custom pool from the specified workspace.

Parameters:

Name Type Description Default
workspace str

The name or ID of the workspace to delete.

required
workspace_custom_pool str

The name or ID of the workspace custom pool to delete.

required

Returns:

Name Type Description
None None

If the workspace custom pool is successfully deleted.

Raises:

Type Description
ResourceNotFoundError

If the specified workspace is not found.

Examples:

delete_workspace_custom_pool('MyProjectWorkspace', 'MyCustomPool')
delete_workspace_custom_pool('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000')
Source code in src/pyfabricops/items/spark.py
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
def delete_workspace_custom_pool(
    workspace: str, workspace_custom_pool: str
) -> None:
    """
    Delete a custom pool from the specified workspace.

    Args:
        workspace (str): The name or ID of the workspace to delete.
        workspace_custom_pool (str): The name or ID of the workspace custom pool to delete.

    Returns:
        None: If the workspace custom pool is successfully deleted.

    Raises:
        ResourceNotFoundError: If the specified workspace is not found.

    Examples:
        ```python
        delete_workspace_custom_pool('MyProjectWorkspace', 'MyCustomPool')
        delete_workspace_custom_pool('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000')
        ```
    """
    workspace_id = resolve_workspace(workspace)

    workspace_custom_pool_id = resolve_workspace_custom_pool(
        workspace_id, workspace_custom_pool
    )

    return api_request(
        endpoint="/workspaces/"
        + workspace_id
        + "/spark/pools/"
        + workspace_custom_pool_id,
        method="delete",
    )

get_workspace_custom_pool(workspace, workspace_custom_pool, *, df=True)

Retrieves a specific custom pool from the workspace.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
workspace_custom_pool str

The name or ID of the workspace custom pool to retrieve.

required
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
Union[DataFrame, Dict[str, Any], None]

The workspace custom pool details as a dictionary or DataFrame, or None if not found.

Examples:

get_workspace_custom_pool('MyProjectWorkspace', 'MyCustomPool')
get_workspace_custom_pool('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000', df=True)
Source code in src/pyfabricops/items/spark.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@df
def get_workspace_custom_pool(
    workspace: str,
    workspace_custom_pool: str,
    *,
    df: bool | None = True,
) -> DataFrame | dict[str, Any] | None:
    """
    Retrieves a specific custom pool from the workspace.

    Args:
        workspace (str): The workspace name or ID.
        workspace_custom_pool (str): The name or ID of the workspace custom pool to retrieve.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        (Union[DataFrame, Dict[str, Any], None]): The workspace custom pool details as a dictionary or DataFrame, or None if not found.

    Examples:
        ```python
        get_workspace_custom_pool('MyProjectWorkspace', 'MyCustomPool')
        get_workspace_custom_pool('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000', df=True)
        ```
    """
    workspace_id = resolve_workspace(workspace)

    workspace_custom_pool_id = resolve_workspace_custom_pool(
        workspace_id, workspace_custom_pool
    )

    return api_request(
        endpoint="/workspaces/"
        + workspace_id
        + "/spark/pools/"
        + workspace_custom_pool_id,
    )

get_workspace_custom_pool_id(workspace, workspace_custom_pool)

Retrieves the ID of a specific custom pool in the workspace.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
workspace_custom_pool str

The name of the workspace custom pool.

required

Returns:

Type Description
str | None

str|None: The ID of the workspace custom pool, or None if not found.

Examples:

get_workspace_custom_pool_id('MyProjectWorkspace', 'SmallPool')
get_workspace_custom_pool_id('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000')
Source code in src/pyfabricops/items/spark.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def get_workspace_custom_pool_id(
    workspace: str, workspace_custom_pool: str
) -> str | None:
    """
    Retrieves the ID of a specific custom pool in the workspace.

    Args:
        workspace (str): The workspace name or ID.
        workspace_custom_pool (str): The name of the workspace custom pool.

    Returns:
        str|None: The ID of the workspace custom pool, or None if not found.

    Examples:
        ```python
        get_workspace_custom_pool_id('MyProjectWorkspace', 'SmallPool')
        get_workspace_custom_pool_id('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000')
        ```
    """
    workspace_custom_pools = list_workspace_custom_pools(
        workspace=resolve_workspace(workspace),
        df=False,
    )

    for _workspace_custom_pool in workspace_custom_pools:
        if _workspace_custom_pool["name"] == workspace_custom_pool:
            return _workspace_custom_pool["id"]
    logger.warning(
        f"Custom pool '{workspace_custom_pool}' not found in workspace '{workspace}'."
    )
    return None

get_workspace_spark_settings(workspace, *, df=True)

Get workspace Spark settings.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
str | None

str|None: The dict with workspace Spark settings.

Examples:

get_workspace_spark_settings('MyProjectWorkspace')
get_workspace_spark_settings('123e4567-e89b-12d3-a456-426614174000')
Source code in src/pyfabricops/items/spark.py
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
@df
def get_workspace_spark_settings(
    workspace: str,
    *,
    df: bool | None = True,
) -> str | None:
    """
    Get workspace Spark settings.

    Args:
        workspace (str): The workspace name or ID.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        str|None: The dict with workspace Spark settings.

    Examples:
        ```python
        get_workspace_spark_settings('MyProjectWorkspace')
        get_workspace_spark_settings('123e4567-e89b-12d3-a456-426614174000')
        ```
    """
    workspace_id = resolve_workspace(workspace)

    return api_request(
        endpoint="/workspaces/" + workspace_id + "/spark/settings"
    )

list_workspace_custom_pools(workspace, *, df=True)

Returns a list of custom pools from the specified workspace. This API supports pagination.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
Union[DataFrame, List[Dict[str, Any]], None]

A list of custom pools. If df=True, returns a DataFrame with flattened keys.

Examples:

list_workspace_custom_pools('MyProjectWorkspace')
list_workspace_custom_pools('MyProjectWorkspace', df=False)
Source code in src/pyfabricops/items/spark.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
@df
def list_workspace_custom_pools(
    workspace: str, *, df: bool | None = True
) -> DataFrame | list[dict[str, Any]] | None:
    """
    Returns a list of custom pools from the specified workspace.
    This API supports pagination.

    Args:
        workspace (str): The workspace name or ID.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        (Union[DataFrame, List[Dict[str, Any]], None]): A list of custom pools. If `df=True`, returns a DataFrame with flattened keys.

    Examples:
        ```python
        list_workspace_custom_pools('MyProjectWorkspace')
        list_workspace_custom_pools('MyProjectWorkspace', df=False)
        ```
    """
    workspace_id = resolve_workspace(workspace)
    return api_request(
        endpoint="/workspaces/" + workspace_id + "/spark/pools",
        support_pagination=True,
    )

resolve_workspace_custom_pool(workspace, workspace_custom_pool)

Resolves a workspace custom pool name to its ID.

Parameters:

Name Type Description Default
workspace str

The ID of the workspace.

required
workspace_custom_pool str

The name of the workspace custom pool.

required

Returns:

Type Description
Union[str, None]

The ID of the workspace custom pool, or None if not found.

Examples:

resolve_workspace_custom_pool('MyProjectWorkspace', 'MyCustoomPool')
resolve_workspace_custom_pool('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000')
Source code in src/pyfabricops/items/spark.py
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def resolve_workspace_custom_pool(
    workspace: str,
    workspace_custom_pool: str,
) -> str | None:
    """
    Resolves a workspace custom pool name to its ID.

    Args:
        workspace (str): The ID of the workspace.
        workspace_custom_pool (str): The name of the workspace custom pool.

    Returns:
        (Union[str, None]): The ID of the workspace custom pool, or None if not found.

    Examples:
        ```python
        resolve_workspace_custom_pool('MyProjectWorkspace', 'MyCustoomPool')
        resolve_workspace_custom_pool('MyProjectWorkspace', '123e4567-e89b-12d3-a456-426614174000')
        ```
    """
    if is_valid_uuid(workspace_custom_pool):
        return workspace_custom_pool
    else:
        return get_workspace_custom_pool_id(
            resolve_workspace(workspace), workspace_custom_pool
        )

update_workspace_custom_pool(workspace, workspace_custom_pool, *, display_name=None, auto_scale_enabled=None, min_node_count=None, max_node_count=None, dynamic_executor_allocation_enabled=None, min_executors=None, max_executors=None, node_family='MemoryOptimized', node_size='Small', df=True)

Updates the properties of the specified workspace custom pool.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
workspace_custom_pool str

The name or ID of the workspace custom pool to update.

required
display_name str

The new display name for the workspace custom pool.

None
auto_scale_enabled bool

Whether auto-scaling is enabled.

None
min_node_count int

The minimum number of nodes.

None
max_node_count int

The maximum number of nodes.

None
dynamic_executor_allocation_enabled bool

Whether dynamic executor allocation is enabled.

None
min_executors int

The minimum number of executors.

None
max_executors int

The maximum number of executors. Always less than max_node_count.

None
node_family str

The node family. Default is 'MemoryOptimized'.

'MemoryOptimized'
node_size Literal['Small', 'Medium', 'Large']

The node size. Default is 'Small'.

'Small'
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
Union[DataFrame, Dict[str, Any], None]

The updated workspace custom pool details if successful, otherwise None.

Examples:

update_workspace_custom_pool(
    'MyProjectWorkspace',
    'MyCustomPool',
    display_name='MyCustomPoolRenamed',
    auto_scale_enabled=True,
    min_node_count=1,
    max_node_count=10,
    dynamic_executor_allocation_enabled=True,
    min_executors=1,
    max_executors=9, # Always less than max_node_count
    node_family='MemoryOptimized',
    node_size='Small'
)
Source code in src/pyfabricops/items/spark.py
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
@df
def update_workspace_custom_pool(
    workspace: str,
    workspace_custom_pool: str,
    *,
    display_name: str | None = None,
    auto_scale_enabled: bool | None = None,
    min_node_count: int | None = None,
    max_node_count: int | None = None,
    dynamic_executor_allocation_enabled: bool | None = None,
    min_executors: int | None = None,
    max_executors: int | None = None,
    node_family: str | None = "MemoryOptimized",
    node_size: Literal["Small", "Medium", "Large"] = "Small",
    df: bool | None = True,
) -> DataFrame | dict[str, Any] | None:
    """
    Updates the properties of the specified workspace custom pool.

    Args:
        workspace (str): The workspace name or ID.
        workspace_custom_pool (str): The name or ID of the workspace custom pool to update.
        display_name (str, optional): The new display name for the workspace custom pool.
        auto_scale_enabled (bool, optional): Whether auto-scaling is enabled.
        min_node_count (int, optional): The minimum number of nodes.
        max_node_count (int, optional): The maximum number of nodes.
        dynamic_executor_allocation_enabled (bool, optional): Whether dynamic executor allocation is enabled.
        min_executors (int, optional): The minimum number of executors.
        max_executors (int, optional): The maximum number of executors. Always less than max_node_count.
        node_family (str, optional): The node family. Default is 'MemoryOptimized'.
        node_size (Literal['Small', 'Medium', 'Large'], optional): The node size. Default is 'Small'.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        (Union[DataFrame, Dict[str, Any], None]): The updated workspace custom pool details if successful, otherwise None.

    Examples:
        ```python
        update_workspace_custom_pool(
            'MyProjectWorkspace',
            'MyCustomPool',
            display_name='MyCustomPoolRenamed',
            auto_scale_enabled=True,
            min_node_count=1,
            max_node_count=10,
            dynamic_executor_allocation_enabled=True,
            min_executors=1,
            max_executors=9, # Always less than max_node_count
            node_family='MemoryOptimized',
            node_size='Small'
        )
        ```
    """
    workspace_id = resolve_workspace(workspace)

    workspace_custom_pool_id = resolve_workspace_custom_pool(
        workspace_id, workspace_custom_pool
    )

    payload = {}

    if display_name:
        payload["name"] = display_name
    if auto_scale_enabled is not None:
        payload["autoScale"] = {}
        payload["autoScale"]["enabled"] = auto_scale_enabled
    if min_node_count is not None:
        payload["autoScale"]["minNodeCount"] = min_node_count
    if max_node_count is not None:
        payload["autoScale"]["maxNodeCount"] = max_node_count
    if dynamic_executor_allocation_enabled is not None:
        payload["dynamicExecutorAllocation"] = {}
        payload["dynamicExecutorAllocation"]["enabled"] = (
            dynamic_executor_allocation_enabled
        )
    if min_executors is not None:
        payload["dynamicExecutorAllocation"]["minExecutors"] = min_executors
    if max_executors is not None:
        payload["dynamicExecutorAllocation"]["maxExecutors"] = max_executors
    if node_family:
        payload["nodeFamily"] = node_family
    if node_size:
        payload["nodeSize"] = node_size

    return api_request(
        endpoint="/workspaces/"
        + workspace_id
        + "/spark/pools/"
        + workspace_custom_pool_id,
        method="patch",
        payload=payload,
    )

update_workspace_spark_settings(workspace, *, automatic_log_enabled=None, high_concurrency_notebook_interactive_run_enabled=None, high_concurrency_notebook_pipeline_run_enabled=None, pool_customize_compute_enabled=None, pool_default_name=None, pool_default_id=None, pool_default_type=None, starter_pool_max_node_count=None, starter_pool_max_executors=None, environment_name=None, environment_runtime_version=None, job_conservative_job_admission_enabled=None, job_session_timeout_in_minutes=None, df=True)

Update workspace Spark settings.

Parameters:

Name Type Description Default
workspace str

The workspace name or ID.

required
automatic_log_enabled bool

Enable or disable automatic logging.

None
high_concurrency_notebook_interactive_run_enabled bool

Enable or disable high concurrency for notebook interactive runs.

None
high_concurrency_notebook_pipeline_run_enabled bool

Enable or disable high concurrency for notebook pipeline runs.

None
pool_customize_compute_enabled bool

Enable or disable custom compute for pools.

None
pool_default_name str

The default pool name.

None
pool_default_id str

The default pool ID.

None
pool_default_type str

The default pool type.

None
starter_pool_max_node_count int

The maximum node count for the starter pool

None
starter_pool_max_executors int

The maximum executors for the starter pool.

None
environment_name str

The name of the environment.

None
environment_runtime_version str

The runtime version for the environment.

None
job_conservative_job_admission_enabled bool

Enable or disable conservative job admission

None
job_session_timeout_in_minutes int

The session timeout in minutes for jobs.

None
df Optional[bool]

If True or not provided, returns a DataFrame with flattened keys. If False, returns a list of dictionaries.

True

Returns:

Type Description
str | None

str|None: The dict with updated workspace Spark settings.

Examples:

update_workspace_spark_settings(
    'MyProjectWorkspace',
    True,
    'mystorageaccount',
    'mysparklogs',
    'logs/'
)
Source code in src/pyfabricops/items/spark.py
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
@df
def update_workspace_spark_settings(
    workspace: str,
    *,
    automatic_log_enabled: bool = None,
    high_concurrency_notebook_interactive_run_enabled: bool = None,
    high_concurrency_notebook_pipeline_run_enabled: bool = None,
    pool_customize_compute_enabled: bool = None,
    pool_default_name: str = None,
    pool_default_id: str = None,
    pool_default_type: str = None,
    starter_pool_max_node_count: int = None,
    starter_pool_max_executors: int = None,
    environment_name: str = None,
    environment_runtime_version: str = None,
    job_conservative_job_admission_enabled: bool = None,
    job_session_timeout_in_minutes: int = None,
    df: bool | None = True,
) -> str | None:
    """
    Update workspace Spark settings.

    Args:
        workspace (str): The workspace name or ID.
        automatic_log_enabled (bool, optional): Enable or disable automatic logging.
        high_concurrency_notebook_interactive_run_enabled (bool, optional): Enable or disable high
            concurrency for notebook interactive runs.
        high_concurrency_notebook_pipeline_run_enabled (bool, optional): Enable or disable high
            concurrency for notebook pipeline runs.
        pool_customize_compute_enabled (bool, optional): Enable or disable custom compute for pools.
        pool_default_name (str, optional): The default pool name.
        pool_default_id (str, optional): The default pool ID.
        pool_default_type (str, optional): The default pool type.
        starter_pool_max_node_count (int, optional): The maximum node count for the starter pool
        starter_pool_max_executors (int, optional): The maximum executors for the starter pool.
        environment_name (str, optional): The name of the environment.
        environment_runtime_version (str, optional): The runtime version for the environment.
        job_conservative_job_admission_enabled (bool, optional): Enable or disable conservative job admission
        job_session_timeout_in_minutes (int, optional): The session timeout in minutes for jobs.
        df (Optional[bool]): If True or not provided, returns a DataFrame with flattened keys.
            If False, returns a list of dictionaries.

    Returns:
        str|None: The dict with updated workspace Spark settings.

    Examples:
        ```python
        update_workspace_spark_settings(
            'MyProjectWorkspace',
            True,
            'mystorageaccount',
            'mysparklogs',
            'logs/'
        )
        ```
    """
    workspace_id = resolve_workspace(workspace)

    payload = {}

    if automatic_log_enabled is not None:
        payload["automaticLog"] = {"enabled": automatic_log_enabled}

    if (high_concurrency_notebook_interactive_run_enabled is not None) or (
        high_concurrency_notebook_pipeline_run_enabled is not None
    ):
        payload["highConcurrency"] = {}
        if high_concurrency_notebook_interactive_run_enabled is not None:
            payload["highConcurrency"]["notebookInteractiveRunEnabled"] = (
                high_concurrency_notebook_interactive_run_enabled
            )
        if high_concurrency_notebook_pipeline_run_enabled is not None:
            payload["highConcurrency"]["notebookPipelineRunEnabled"] = (
                high_concurrency_notebook_pipeline_run_enabled
            )

    if (
        (pool_customize_compute_enabled is not None)
        or (pool_default_name is not None)
        or (pool_default_id is not None)
        or (pool_default_type is not None)
        or (starter_pool_max_node_count is not None)
        or (starter_pool_max_executors is not None)
    ):
        payload["pool"] = {}
        if pool_customize_compute_enabled is not None:
            payload["pool"]["customizeComputeEnabled"] = (
                pool_customize_compute_enabled
            )
        if (
            (pool_default_name is not None)
            or (pool_default_id is not None)
            or (pool_default_type is not None)
        ):
            payload["pool"]["defaultPool"] = {}
            if pool_default_name is not None:
                payload["pool"]["defaultPool"]["name"] = pool_default_name
            if pool_default_id is not None:
                payload["pool"]["defaultPool"]["id"] = pool_default_id
            if pool_default_type is not None:
                payload["pool"]["defaultPool"]["type"] = pool_default_type
        if (starter_pool_max_node_count is not None) or (
            starter_pool_max_executors is not None
        ):
            payload["pool"]["starterPool"] = {}
            if starter_pool_max_node_count is not None:
                payload["pool"]["starterPool"]["maxNodeCount"] = (
                    starter_pool_max_node_count
                )
            if starter_pool_max_executors is not None:
                payload["pool"]["starterPool"]["maxExecutors"] = (
                    starter_pool_max_executors
                )
    if environment_name is not None:
        payload["environment"] = {"name": environment_name}
    if environment_runtime_version is not None:
        payload["environment"] = {
            "runtimeVersion": environment_runtime_version
        }
    if (job_conservative_job_admission_enabled is not None) or (
        job_session_timeout_in_minutes is not None
    ):
        payload["job"] = {}
        if job_conservative_job_admission_enabled is not None:
            payload["job"]["conservativeJobAdmissionEnabled"] = (
                job_conservative_job_admission_enabled
            )
        if job_session_timeout_in_minutes is not None:
            payload["job"]["sessionTimeoutInMinutes"] = (
                job_session_timeout_in_minutes
            )

    return api_request(
        endpoint="/workspaces/" + workspace_id + "/spark/settings",
        method="patch",
        payload=payload,
    )