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 sdk runtime #942

Merged
merged 14 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions api-contracts/dispatcher/dispatcher.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ message WorkerLabels {
optional int32 intValue = 2;
}

enum SDKS {
UNKNOWN = 0;
GO = 1;
PYTHON = 2;
TYPESCRIPT = 3;
}

message RuntimeInfo {
optional string sdkVersion = 1;
optional SDKS language = 2;
optional string languageVersion = 3;
optional string os = 4;
optional string extra = 5;
}

message WorkerRegisterRequest {
// the name of the worker
string workerName = 1;
Expand All @@ -59,6 +74,10 @@ message WorkerRegisterRequest {

// (optional) webhookId is the id of the webhook that the worker is associated with (if any)
optional string webhookId = 6;

// (optional) information regarding the runtime environment of the worker
optional RuntimeInfo runtimeInfo = 7;

}

message WorkerRegisterResponse {
Expand Down
4 changes: 4 additions & 0 deletions api-contracts/openapi/components/schemas/_index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ StepRunArchive:
$ref: "./workflow_run.yaml#/StepRunArchive"
StepRunArchiveList:
$ref: "./workflow_run.yaml#/StepRunArchiveList"
WorkerRuntimeInfo:
$ref: "./worker.yaml#/WorkerRuntimeInfo"
WorkerRuntimeSDKs:
$ref: "./worker.yaml#/WorkerRuntimeSDKs"
WorkerList:
$ref: "./worker.yaml#/WorkerList"
SemaphoreSlots:
Expand Down
22 changes: 22 additions & 0 deletions api-contracts/openapi/components/schemas/worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ Worker:
type: string
description: The webhook ID for the worker.
format: uuid
runtimeInfo:
$ref: "#/WorkerRuntimeInfo"
required:
- metadata
- name
Expand All @@ -164,3 +166,23 @@ WorkerList:
items:
$ref: "#/Worker"
type: array

WorkerRuntimeSDKs:
type: string
enum:
- GOLANG
- PYTHON
- TYPESCRIPT

WorkerRuntimeInfo:
properties:
sdkVersion:
type: string
language:
$ref: "#/WorkerRuntimeSDKs"
languageVersion:
type: string
os:
type: string
runtimeExtra:
type: string
224 changes: 123 additions & 101 deletions api/v1/server/oas/gen/openapi.gen.go

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions api/v1/server/oas/transformers/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ func ToWorkerLabels(labels []*dbsqlc.ListWorkerLabelsRow) *[]gen.WorkerLabel {
return &resp
}

func ToWorkerRuntimeInfo(worker *dbsqlc.Worker) *gen.WorkerRuntimeInfo {

runtime := &gen.WorkerRuntimeInfo{
SdkVersion: &worker.SdkVersion.String,
LanguageVersion: &worker.LanguageVersion.String,
Os: &worker.Os.String,
RuntimeExtra: &worker.RuntimeExtra.String,
}

if worker.Language.Valid {
lang := gen.WorkerRuntimeSDKs(worker.Language.WorkerSDKS)
runtime.Language = &lang
}

return runtime
}

func ToWorkerSqlc(worker *dbsqlc.Worker, remainingSlots *int, webhookUrl *string, actions []pgtype.Text) *gen.Worker {

dispatcherId := uuid.MustParse(pgUUIDToStr(worker.DispatcherId))
Expand Down Expand Up @@ -108,6 +125,7 @@ func ToWorkerSqlc(worker *dbsqlc.Worker, remainingSlots *int, webhookUrl *string
MaxRuns: &maxRuns,
AvailableRuns: &availableRuns,
WebhookUrl: webhookUrl,
RuntimeInfo: ToWorkerRuntimeInfo(worker),
}

if worker.WebhookId.Valid {
Expand Down
15 changes: 15 additions & 0 deletions frontend/app/src/lib/api/generated/data-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,20 @@ export interface StepRunArchiveList {
rows?: StepRunArchive[];
}

export interface WorkerRuntimeInfo {
sdkVersion?: string;
language?: WorkerRuntimeSDKs;
languageVersion?: string;
os?: string;
runtimeExtra?: string;
}

export enum WorkerRuntimeSDKs {
GOLANG = 'GOLANG',
PYTHON = 'PYTHON',
TYPESCRIPT = 'TYPESCRIPT',
}

export interface WorkerList {
pagination?: PaginationResponse;
rows?: Worker[];
Expand Down Expand Up @@ -1059,6 +1073,7 @@ export interface Worker {
* @format uuid
*/
webhookId?: string;
runtimeInfo?: WorkerRuntimeInfo;
}

export interface WorkerLabel {
Expand Down
31 changes: 31 additions & 0 deletions frontend/app/src/pages/main/workers/$worker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,37 @@ export default function ExpandedWorkflowRun() {
))
)}
</div>
{worker.runtimeInfo && (
<>
<Separator className="my-4" />
<h3 className="text-xl font-bold leading-tight text-foreground mb-4">
Worker Runtime Info
</h3>
<div className="mb-4 text-sm text-gray-700 dark:text-gray-300">
{worker.runtimeInfo?.sdkVersion && (
<div>
<b>Hatchet SDK</b>: {worker.runtimeInfo?.sdkVersion}
</div>
)}
{worker.runtimeInfo?.languageVersion && (
<div>
<b>Runtime</b>: {worker.runtimeInfo?.language}{' '}
{worker.runtimeInfo?.languageVersion}
</div>
)}
{worker.runtimeInfo?.os && (
<div>
<b>OS</b>: {worker.runtimeInfo?.os}
</div>
)}
{worker.runtimeInfo?.runtimeExtra && (
<div>
<b>Runtime Extra</b>: {worker.runtimeInfo?.runtimeExtra}
</div>
)}
</div>
</>
)}
</div>
</div>
);
Expand Down
31 changes: 31 additions & 0 deletions frontend/app/src/pages/main/workers/components/sdk-info.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { WorkerRuntimeSDKs } from '@/lib/api';

import { BiLogoGoLang, BiLogoPython, BiLogoTypescript } from 'react-icons/bi';
import { IconType } from 'react-icons';
import React from 'react';

export const SdkInfo: React.FC<{
runtimeInfo?: { language?: WorkerRuntimeSDKs; sdkVersion?: string };
iconOnly?: boolean;
}> = ({ runtimeInfo, iconOnly = false }) => {
const SdkIcons: Record<WorkerRuntimeSDKs, IconType> = {
GOLANG: BiLogoGoLang,
PYTHON: BiLogoPython,
TYPESCRIPT: BiLogoTypescript,
};

if (!runtimeInfo) {
return null;
}

const Icon = runtimeInfo.language
? SdkIcons[runtimeInfo.language]
: undefined;

return (
<div className="flex flex-row gap-2 items-center">
{Icon && React.createElement(Icon)}
{!iconOnly && runtimeInfo.sdkVersion}
</div>
);
};
10 changes: 10 additions & 0 deletions frontend/app/src/pages/main/workers/components/worker-columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DataTableColumnHeader } from '../../../../components/molecules/data-tab
import { Worker } from '@/lib/api';
import { Link } from 'react-router-dom';
import RelativeDate from '@/components/molecules/relative-date';
import { SdkInfo } from './sdk-info';

export const columns: ColumnDef<Worker>[] = [
{
Expand Down Expand Up @@ -88,4 +89,13 @@ export const columns: ColumnDef<Worker>[] = [
enableSorting: false,
enableHiding: true,
},
{
accessorKey: 'runtime',
header: ({ column }) => (
<DataTableColumnHeader column={column} title="SDK Version" />
),
cell: ({ row }) => <SdkInfo runtimeInfo={row.original.runtimeInfo} />,
enableSorting: false,
enableHiding: true,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { WorkerStatus, isHealthy } from '../$worker';
import { ColumnFiltersState } from '@tanstack/react-table';
import RelativeDate from '@/components/molecules/relative-date';
import { Badge } from '@/components/ui/badge';
import { SdkInfo } from './sdk-info';

export function WorkersTable() {
const { tenant } = useOutletContext<TenantContextType>();
Expand Down Expand Up @@ -104,7 +105,11 @@ export function WorkersTable() {
<WorkerStatus status={data.status} health={isHealthy(data)} />
</div>
<h3 className="text-lg leading-6 font-medium text-foreground">
<Link to={`/workers/${data.metadata?.id}`}>
<Link
to={`/workers/${data.metadata?.id}`}
className="flex flex-row gap-2 hover:underline"
>
<SdkInfo runtimeInfo={data?.runtimeInfo} iconOnly={true} />
{data.webhookUrl || data.name}
</Link>
</h3>
Expand Down
Loading
Loading