Skip to content

Commit

Permalink
Merge pull request #396 from DataRecce/feature/drc-577-bug-recce-mani…
Browse files Browse the repository at this point in the history
…fest-reload-failed

[Bug] DRC-577 Handle the updated artifact file is not updated completely
  • Loading branch information
kentwelcome authored Aug 6, 2024
2 parents 2156c77 + bdee9a9 commit 7794256
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions recce/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,24 @@ async def lifespan(fastapi: FastAPI):
app = FastAPI(lifespan=lifespan)


def verify_json_file(file_path: str) -> bool:
try:
with open(file_path, 'r') as f:
json.load(f)
except Exception:
return False
return True


def dbt_artifacts_updated_callback(file_changed_event: Any):
src_path = Path(file_changed_event.src_path)
target_type = src_path.parent.name
file_name = src_path.name

if not verify_json_file(file_changed_event.src_path):
logger.debug('Skip to refresh the artifacts because the file is not updated completely.')
return

logger.info(
f'Detect {target_type} file {file_changed_event.event_type}: {file_name}')
ctx = load_context()
Expand Down

0 comments on commit 7794256

Please sign in to comment.