Skip to content

Commit

Permalink
fix: Get last flow not last tag with /flows
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramimashkouk committed Nov 19, 2024
1 parent 53ea889 commit 0a84d80
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions backend/chatsky_ui/api/api_v1/endpoints/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ async def flows_get(build_id: Optional[int] = None) -> Dict[str, Union[str, Dict

if build_id is not None:
tag = int(build_id)
try:
repo.git.checkout(tag, settings.frontend_flows_path.name)
except GitCommandError as e:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=f"Build_id {tag} not found",
) from e
else:
tag = sorted(repo.tags, key=lambda t: t.commit.committed_datetime)[-1]
try:
repo.git.checkout(tag, settings.frontend_flows_path.name)
except GitCommandError as e:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail=f"Build_id {tag} not found",
) from e
try:
repo.git.checkout("HEAD", settings.frontend_flows_path.name)
except GitCommandError as e:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Failed to checkout the latest commit",
) from e

omega_flows = await read_conf(settings.frontend_flows_path)
dict_flows = OmegaConf.to_container(omega_flows, resolve=True)
Expand Down

0 comments on commit 0a84d80

Please sign in to comment.