Skip to content

Commit 7794256

Browse files
authored
Merge pull request #396 from DataRecce/feature/drc-577-bug-recce-manifest-reload-failed
[Bug] DRC-577 Handle the updated artifact file is not updated completely
2 parents 2156c77 + bdee9a9 commit 7794256

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

recce/server.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,24 @@ async def lifespan(fastapi: FastAPI):
6868
app = FastAPI(lifespan=lifespan)
6969

7070

71+
def verify_json_file(file_path: str) -> bool:
72+
try:
73+
with open(file_path, 'r') as f:
74+
json.load(f)
75+
except Exception:
76+
return False
77+
return True
78+
79+
7180
def dbt_artifacts_updated_callback(file_changed_event: Any):
7281
src_path = Path(file_changed_event.src_path)
7382
target_type = src_path.parent.name
7483
file_name = src_path.name
84+
85+
if not verify_json_file(file_changed_event.src_path):
86+
logger.debug('Skip to refresh the artifacts because the file is not updated completely.')
87+
return
88+
7589
logger.info(
7690
f'Detect {target_type} file {file_changed_event.event_type}: {file_name}')
7791
ctx = load_context()

0 commit comments

Comments
 (0)