-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from Tauffer-Consulting/dev
Dev
- Loading branch information
Showing
26 changed files
with
342 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
frontend/src/features/workflowEditor/api/workflowsExample/getWorkflowExamples.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import axios from "axios"; | ||
import { type IWorkflowPieceData } from "features/workflowEditor/context/types"; | ||
import { type Edge, type Node } from "reactflow"; | ||
import useSWR from "swr"; | ||
|
||
const REPO_URL = | ||
"https://raw.githubusercontent.com/Tauffer-Consulting/domino_pieces_gallery/main/workflows_gallery"; | ||
|
||
const getWorkflowsExampleUrl = `${REPO_URL}/index.json`; | ||
|
||
type GithubReposContent = Array<{ | ||
title: string; | ||
description: string; | ||
jsonFile: string; | ||
levelTag: "Advanced" | "Beginner" | "Intermediate"; | ||
}>; | ||
|
||
interface JSONFile { | ||
workflowPieces: Record<string, Piece>; | ||
workflowPiecesData: IWorkflowPieceData; | ||
workflowNodes: Node[]; | ||
workflowEdges: Edge[]; | ||
} | ||
|
||
export type WorkflowsGalleryExamples = Array<{ | ||
title: string; | ||
description: string; | ||
jsonFile: JSONFile; | ||
levelTag: "Advanced" | "Beginner" | "Intermediate"; | ||
}>; | ||
|
||
const getWorkflowsExample: () => Promise<WorkflowsGalleryExamples> = | ||
async () => { | ||
const { data } = await axios.get<GithubReposContent>( | ||
getWorkflowsExampleUrl, | ||
); | ||
const jsons: WorkflowsGalleryExamples = []; | ||
for (const value of data) { | ||
const { data: json } = await axios.get<JSONFile>( | ||
`${REPO_URL}/${value.jsonFile}`, | ||
); | ||
jsons.push({ ...value, jsonFile: json }); | ||
} | ||
|
||
return jsons; | ||
}; | ||
|
||
export const useAuthenticatedGetWorkflowsExamples = (fetch: boolean) => { | ||
const fetcher = async () => await getWorkflowsExample().then((data) => data); | ||
|
||
return useSWR( | ||
fetch ? getWorkflowsExampleUrl : null, | ||
async () => await fetcher(), | ||
{ | ||
revalidateOnFocus: false, | ||
revalidateOnReconnect: false, | ||
}, | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
frontend/src/features/workflowEditor/api/workflowsExample/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./getWorkflowExamples"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .container_resources import ContainerResourcesModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from pydantic import BaseModel, Field | ||
|
||
class SystemRequirementsModel(BaseModel): | ||
cpu: int = Field(default=128) | ||
memory: int = Field(memory=100) | ||
|
||
|
||
class ContainerResourcesModel(BaseModel): | ||
requests: SystemRequirementsModel = Field(default=SystemRequirementsModel(cpu=100, memory=128)) | ||
limits: SystemRequirementsModel = Field(default=SystemRequirementsModel(cpu=100, memory=128)) | ||
use_gpu: bool = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""empty message | ||
Revision ID: 93da7356c3d7 | ||
Revises: f7214a10a4df | ||
Create Date: 2023-11-29 07:55:27.576939 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '93da7356c3d7' | ||
down_revision = 'f7214a10a4df' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column('piece', sa.Column('tags', sa.ARRAY(sa.String()), server_default='{}', nullable=False)) | ||
op.add_column('piece', sa.Column('container_resources', sa.JSON(), server_default=sa.text("'{}'::jsonb"), nullable=False)) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('piece', 'container_resources') | ||
op.drop_column('piece', 'tags') | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.