Skip to content

Commit 19e0970

Browse files
authored
Merge pull request #595 from DagsHub/bug/refresh-cache-on-field-not-found
Bug: refetch fields on has_field failure
2 parents 5dc9ded + 885841f commit 19e0970

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

dagshub/data_engine/model/datasource.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -1324,9 +1324,19 @@ def has_field(self, field_name: str) -> bool:
13241324
"""
13251325
Checks if a metadata field ``field_name`` exists in the datasource.
13261326
"""
1327-
reserved_searchable_fields = ["path"]
1328-
fields = (f.name for f in self.fields)
1329-
return field_name in reserved_searchable_fields or field_name in fields
1327+
1328+
def _check():
1329+
reserved_searchable_fields = ["path"]
1330+
fields = (f.name for f in self.fields)
1331+
return field_name in reserved_searchable_fields or field_name in fields
1332+
1333+
res = _check()
1334+
# Refetch fields once - maybe things got updated
1335+
if not res:
1336+
self.source.get_from_dagshub()
1337+
res = _check()
1338+
1339+
return res
13301340

13311341
def __repr__(self):
13321342
res = f"Datasource {self.source.name}"

0 commit comments

Comments
 (0)