File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
src/codeflare_sdk/ray/cluster Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 21
21
from time import sleep
22
22
from typing import List , Optional , Tuple , Dict
23
23
import copy
24
- import dataclasses
25
24
26
25
from ray .job_submission import JobSubmissionClient , JobStatus
27
26
import time
@@ -1060,9 +1059,7 @@ def get_cluster(
1060
1059
)
1061
1060
# 1. Prepare RayClusterSpec from ClusterConfiguration
1062
1061
# Create a temporary config with appwrapper=False to ensure build_ray_cluster returns RayCluster YAML
1063
- temp_cluster_config_dict = dataclasses .asdict (cluster_config )
1064
- # Filter out None values similar to exclude_none=True in Pydantic
1065
- temp_cluster_config_dict = {k : v for k , v in temp_cluster_config_dict .items () if v is not None }
1062
+ temp_cluster_config_dict = cluster_config .dict (exclude_none = True )
1066
1063
temp_cluster_config_dict ["appwrapper" ] = False
1067
1064
# Set overwrite_default_resource_mapping=True to avoid conflicts when extended_resource_mapping
1068
1065
# already contains the combined default and custom mappings from the original object
Original file line number Diff line number Diff line change @@ -289,3 +289,19 @@ def check_type(value, expected_type):
289
289
return isinstance (value , expected_type )
290
290
291
291
return check_type (value , expected_type )
292
+
293
+ def dict (self , exclude_none : bool = False ):
294
+ """
295
+ Convert the ClusterConfiguration to a dictionary.
296
+
297
+ Args:
298
+ exclude_none (bool): If True, exclude fields with None values.
299
+
300
+ Returns:
301
+ dict: Dictionary representation of the ClusterConfiguration.
302
+ """
303
+ import dataclasses
304
+ result = dataclasses .asdict (self )
305
+ if exclude_none :
306
+ result = {k : v for k , v in result .items () if v is not None }
307
+ return result
You can’t perform that action at this time.
0 commit comments