MCPcopy Create free account
hub / github.com/feast-dev/feast / parse_repo

Function parse_repo

sdk/python/feast/repo_operations.py:115–241  ·  view source on GitHub ↗

Collects unique Feast object definitions from the given feature repo. Specifically, if an object foo has already been added, bar will still be added if (bar == foo), but not if (bar is foo). This ensures that import statements will not result in duplicates, but defining two equal o

(repo_root: Path)

Source from the content-addressed store, hash-verified

113
114
115def parse_repo(repo_root: Path) -> RepoContents:
116 """
117 Collects unique Feast object definitions from the given feature repo.
118
119 Specifically, if an object foo has already been added, bar will still be added if
120 (bar == foo), but not if (bar is foo). This ensures that import statements will
121 not result in duplicates, but defining two equal objects will.
122 """
123 res = RepoContents(
124 projects=[],
125 data_sources=[],
126 entities=[],
127 feature_views=[],
128 feature_services=[],
129 on_demand_feature_views=[],
130 stream_feature_views=[],
131 label_views=[],
132 permissions=[],
133 )
134
135 for repo_file in get_repo_files(repo_root):
136 module_path = py_path_to_module(repo_file)
137 module = importlib.import_module(module_path)
138
139 for attr_name in dir(module):
140 obj = getattr(module, attr_name)
141
142 if isinstance(obj, DataSource) and not any(
143 (obj is ds) for ds in res.data_sources
144 ):
145 res.data_sources.append(obj)
146
147 # Handle batch sources defined within stream sources.
148 if (
149 isinstance(obj, PushSource)
150 or isinstance(obj, KafkaSource)
151 or isinstance(obj, KinesisSource)
152 ):
153 batch_source = obj.batch_source
154
155 if batch_source and not any(
156 (batch_source is ds) for ds in res.data_sources
157 ):
158 res.data_sources.append(batch_source)
159 if (
160 isinstance(obj, FeatureView)
161 and not any((obj is fv) for fv in res.feature_views)
162 and not isinstance(obj, StreamFeatureView)
163 and not isinstance(obj, BatchFeatureView)
164 ):
165 res.feature_views.append(obj)
166
167 # Handle batch sources defined with feature views.
168 batch_source = obj.batch_source
169 if batch_source is not None and not any(
170 (batch_source is ds) for ds in res.data_sources
171 ):
172 res.data_sources.append(batch_source)

Callers 3

test_parse_repoFunction · 0.90
_get_repo_contentsFunction · 0.85

Calls 3

RepoContentsClass · 0.90
get_repo_filesFunction · 0.85
py_path_to_moduleFunction · 0.85

Tested by 2

test_parse_repoFunction · 0.72