Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(engine): Basic implementation for pull-based executor and remove internal executor endpoints #758

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
24 changes: 0 additions & 24 deletions frontend/src/client/services.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ import type {
RegistryRepositoriesGetRegistryRepositoryResponse,
RegistryRepositoriesListRegistryRepositoriesResponse,
RegistryRepositoriesReloadRegistryRepositoriesResponse,
RegistryRepositoriesSyncExecutorFromRegistryRepositoryData,
RegistryRepositoriesSyncExecutorFromRegistryRepositoryResponse,
RegistryRepositoriesSyncRegistryRepositoryData,
RegistryRepositoriesSyncRegistryRepositoryResponse,
RegistryRepositoriesUpdateRegistryRepositoryData,
Expand Down Expand Up @@ -1894,28 +1892,6 @@ export const registryRepositoriesSyncRegistryRepository = (
})
}

/**
* Sync Executor From Registry Repository
* @param data The data for the request.
* @param data.repositoryId
* @returns void Successful Response
* @throws ApiError
*/
export const registryRepositoriesSyncExecutorFromRegistryRepository = (
data: RegistryRepositoriesSyncExecutorFromRegistryRepositoryData
): CancelablePromise<RegistryRepositoriesSyncExecutorFromRegistryRepositoryResponse> => {
return __request(OpenAPI, {
method: "POST",
url: "/registry/repos/{repository_id}/sync-executor",
path: {
repository_id: data.repositoryId,
},
errors: {
422: "Validation Error",
},
})
}

/**
* List Registry Repositories
* List all registry repositories.
Expand Down
22 changes: 0 additions & 22 deletions frontend/src/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1884,13 +1884,6 @@ export type RegistryRepositoriesSyncRegistryRepositoryData = {

export type RegistryRepositoriesSyncRegistryRepositoryResponse = void

export type RegistryRepositoriesSyncExecutorFromRegistryRepositoryData = {
repositoryId: string
}

export type RegistryRepositoriesSyncExecutorFromRegistryRepositoryResponse =
void

export type RegistryRepositoriesListRegistryRepositoriesResponse =
Array<RegistryRepositoryReadMinimal>

Expand Down Expand Up @@ -3015,21 +3008,6 @@ export type $OpenApiTs = {
}
}
}
"/registry/repos/{repository_id}/sync-executor": {
post: {
req: RegistryRepositoriesSyncExecutorFromRegistryRepositoryData
res: {
/**
* Successful Response
*/
204: void
/**
* Validation Error
*/
422: HTTPValidationError
}
}
}
"/registry/repos": {
get: {
res: {
Expand Down
139 changes: 4 additions & 135 deletions frontend/src/components/registry/registry-repos-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { RegistryRepositoryReadMinimal } from "@/client"
import { DropdownMenuLabel } from "@radix-ui/react-dropdown-menu"
import { DotsHorizontalIcon } from "@radix-ui/react-icons"
import {
ArrowRightToLineIcon,
CopyIcon,
LoaderCircleIcon,
RefreshCcw,
Expand Down Expand Up @@ -54,8 +53,6 @@ export function RegistryRepositoriesTable() {
syncRepo,
syncRepoIsPending,
deleteRepo,
syncExecutor,
syncExecutorIsPending,
} = useRegistryRepositories()
const [selectedRepo, setSelectedRepo] =
useState<RegistryRepositoryReadMinimal | null>(null)
Expand Down Expand Up @@ -101,7 +98,7 @@ export function RegistryRepositoriesTable() {
label: (
<div className="flex items-center space-x-2">
<RefreshCcw className="size-4" />
<span>Sync only</span>
<span>Sync</span>
</div>
),
action: async () => {
Expand Down Expand Up @@ -130,120 +127,6 @@ export function RegistryRepositoriesTable() {
}
},
},
{
label: (
<div className="flex items-center space-x-2">
<ArrowRightToLineIcon className="size-4" />
<span>Sync and push to executor</span>
</div>
),
action: async () => {
if (!selectedRepo) {
console.error("No repository selected")
return
}
console.log("Reloading repository", selectedRepo.origin)
try {
await syncRepo({ repositoryId: selectedRepo.id })
toast({
title: "Successfully synced repository",
description: (
<div className="flex flex-col space-y-2">
<div>
Successfully reloaded actions from{" "}
<b className="inline-block">{selectedRepo.origin}</b>
</div>
</div>
),
})
await syncExecutor({ repositoryId: selectedRepo.id })
toast({
title: "Successfully pushed to executor",
description: (
<div className="flex flex-col space-y-2">
<div>
Successfully pushed actions from{" "}
<b className="inline-block">{selectedRepo.origin}</b>
</div>
</div>
),
})
} catch (error) {
console.error("Error reloading repository", error)
} finally {
setSelectedRepo(null)
}
},
},
],
}
case AlertAction.SYNC_EXECUTOR:
return {
title: "Push to executor",
description: (
<div className="flex flex-col space-y-2">
<span>
You are about to push the current version of the repository{" "}
</span>
<b className="font-mono tracking-tighter">
{selectedRepo?.origin}
</b>
<span>to the executor.</span>
{selectedRepo?.commit_sha && (
<div className="text-sm text-muted-foreground">
<span>Current SHA: </span>
<Badge className="font-mono text-xs" variant="secondary">
{selectedRepo.commit_sha}
</Badge>
</div>
)}
{selectedRepo?.last_synced_at && (
<div className="text-sm text-muted-foreground">
<span>Last synced: </span>
<span>
{new Date(selectedRepo.last_synced_at).toLocaleString()}
</span>
</div>
)}
<p>
Are you sure you want to proceed? This will reload all existing
modules from this repository on the executor.
</p>
</div>
),
actions: [
{
label: (
<div className="flex items-center space-x-2">
<ArrowRightToLineIcon className="size-4" />
<span>Push to executor</span>
</div>
),
action: async () => {
if (!selectedRepo) {
console.error("No repository selected")
return
}
try {
await syncExecutor({ repositoryId: selectedRepo.id })
toast({
title: "Successfully synced executor",
description: (
<div className="flex flex-col space-y-2">
<div>
Successfully reloaded actions from{" "}
<b className="inline-block">{selectedRepo.origin}</b>
</div>
</div>
),
})
} catch (error) {
console.error("Error syncing executor", error)
} finally {
setSelectedRepo(null)
}
},
},
],
}
case AlertAction.DELETE:
Expand Down Expand Up @@ -402,11 +285,11 @@ export function RegistryRepositoriesTable() {
>
<span className="sr-only">Open menu</span>
{row.original.id === selectedRepo?.id &&
(syncRepoIsPending || syncExecutorIsPending) ? (
syncRepoIsPending ? (
<div className="flex items-center space-x-2">
<LoaderCircleIcon className="size-4 animate-spin" />
<span className="text-xs text-muted-foreground">
{syncRepoIsPending ? "Pulling..." : "Pushing..."}
Pulling...
</span>
</div>
) : (
Expand Down Expand Up @@ -473,20 +356,6 @@ export function RegistryRepositoriesTable() {
<RefreshCcw className="mr-2 size-4" />
<span>Sync from remote</span>
</DropdownMenuItem>
{row.original.last_synced_at !== null && (
<DropdownMenuItem
className="flex items-center text-xs"
onClick={(e) => {
e.stopPropagation() // Prevent row click
setSelectedRepo(row.original)
setAlertAction(AlertAction.SYNC_EXECUTOR)
setAlertOpen(true)
}}
>
<ArrowRightToLineIcon className="mr-2 size-4" />
<span>Push to executor</span>
</DropdownMenuItem>
)}
<DropdownMenuItem
className="flex items-center text-xs text-rose-600"
onClick={(e) => {
Expand Down Expand Up @@ -526,7 +395,7 @@ export function RegistryRepositoriesTable() {
setAlertOpen(false)
await action.action()
}}
disabled={syncRepoIsPending || syncExecutorIsPending}
disabled={syncRepoIsPending}
>
{action.label}
</AlertDialogAction>
Expand Down
39 changes: 0 additions & 39 deletions frontend/src/lib/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import {
RegistryRepositoriesDeleteRegistryRepositoryData,
registryRepositoriesListRegistryRepositories,
registryRepositoriesReloadRegistryRepositories,
registryRepositoriesSyncExecutorFromRegistryRepository,
RegistryRepositoriesSyncExecutorFromRegistryRepositoryData,
registryRepositoriesSyncRegistryRepository,
RegistryRepositoriesSyncRegistryRepositoryData,
RegistryRepositoryReadMinimal,
Expand Down Expand Up @@ -1159,40 +1157,6 @@ export function useRegistryRepositories() {
},
})

const {
mutateAsync: syncExecutor,
isPending: syncExecutorIsPending,
error: syncExecutorError,
} = useMutation({
mutationFn: async (
params: RegistryRepositoriesSyncExecutorFromRegistryRepositoryData
) => await registryRepositoriesSyncExecutorFromRegistryRepository(params),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["registry_repositories"] })
queryClient.invalidateQueries({ queryKey: ["registry_actions"] })
toast({
title: "Synced executor",
description: "Executor synced successfully.",
})
},
onError: (error: TracecatApiError) => {
const apiError = error as TracecatApiError
switch (apiError.status) {
case 403:
toast({
title: "You cannot perform this action",
description: `${apiError.message}: ${apiError.body.detail}`,
})
break
default:
toast({
title: "Failed to sync executor",
description: `An unexpected error occurred while syncing the executor. ${apiError.message}: ${apiError.body.detail}`,
})
}
},
})

return {
repos,
reposIsLoading,
Expand All @@ -1203,9 +1167,6 @@ export function useRegistryRepositories() {
deleteRepo,
deleteRepoIsPending,
deleteRepoError,
syncExecutor,
syncExecutorIsPending,
syncExecutorError,
}
}

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dependencies = [
"tenacity==8.3.0",
"uv==0.4.10",
"uvicorn==0.29.0",
"virtualenv==20.27.0",
]
dynamic = ["version"]

Expand Down
Loading
Loading