MCPcopy
hub / github.com/feast-dev/feast / diff_infra_protos

Function diff_infra_protos

sdk/python/feast/diff/infra_diff.py:112–187  ·  view source on GitHub ↗
(
    current_infra_proto: InfraProto,
    new_infra_proto: InfraProto,
    project: Optional[str] = None,
)

Source from the content-addressed store, hash-verified

110
111
112def diff_infra_protos(
113 current_infra_proto: InfraProto,
114 new_infra_proto: InfraProto,
115 project: Optional[str] = None,
116) -> InfraDiff:
117 infra_diff = InfraDiff()
118
119 infra_object_class_types_to_str = {
120 DATASTORE_INFRA_OBJECT_CLASS_TYPE: "datastore table",
121 SQLITE_INFRA_OBJECT_CLASS_TYPE: "sqlite table",
122 }
123
124 for infra_object_class_type in infra_object_class_types_to_str:
125 current_infra_objects = get_infra_object_protos_by_type(
126 current_infra_proto, infra_object_class_type
127 )
128 new_infra_objects = get_infra_object_protos_by_type(
129 new_infra_proto, infra_object_class_type
130 )
131
132 # Filter infra objects by project prefix when using shared online stores
133 # Table names include project prefix: {project}_{table_name}
134 if project:
135 project_prefix = f"{project}_"
136 current_infra_objects = [
137 obj
138 for obj in current_infra_objects
139 if obj.name.startswith(project_prefix)
140 ]
141 new_infra_objects = [
142 obj for obj in new_infra_objects if obj.name.startswith(project_prefix)
143 ]
144 (
145 infra_objects_to_keep,
146 infra_objects_to_delete,
147 infra_objects_to_add,
148 ) = tag_infra_proto_objects_for_keep_delete_add(
149 current_infra_objects,
150 new_infra_objects,
151 )
152
153 for e in infra_objects_to_add:
154 infra_diff.infra_object_diffs.append(
155 InfraObjectDiff(
156 e.name,
157 infra_object_class_types_to_str[infra_object_class_type],
158 None,
159 e,
160 [],
161 TransitionType.CREATE,
162 )
163 )
164 for e in infra_objects_to_delete:
165 infra_diff.infra_object_diffs.append(
166 InfraObjectDiff(
167 e.name,
168 infra_object_class_types_to_str[infra_object_class_type],
169 e,

Callers 2

planMethod · 0.90
test_diff_infra_protosFunction · 0.90

Calls 5

InfraDiffClass · 0.85
InfraObjectDiffClass · 0.85
diff_betweenFunction · 0.70

Tested by 1

test_diff_infra_protosFunction · 0.72