Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Transformerlab App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
TransformerLab
Transformerlab App
Commits
2270a533
Commit
2270a533
authored
3 weeks ago
by
sanjaycal
Browse files
Options
Downloads
Patches
Plain Diff
get workflows displaying
parent
3733042f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/renderer/components/Experiment/Workflows/index.tsx
+72
-8
72 additions, 8 deletions
src/renderer/components/Experiment/Workflows/index.tsx
src/renderer/lib/transformerlab-api-sdk.ts
+3
-0
3 additions, 0 deletions
src/renderer/lib/transformerlab-api-sdk.ts
with
75 additions
and
8 deletions
src/renderer/components/Experiment/Workflows/index.tsx
+
72
−
8
View file @
2270a533
...
...
@@ -15,6 +15,9 @@ import '@xyflow/react/dist/style.css';
import
{
PlayIcon
,
WorkflowIcon
}
from
'
lucide-react
'
;
import
{
useState
}
from
'
react
'
;
import
*
as
chatAPI
from
'
../../../lib/transformerlab-api-sdk
'
;
import
useSWR
from
'
swr
'
;
const
initialNodes
=
[
{
id
:
'
1
'
,
...
...
@@ -60,9 +63,65 @@ const initialEdges = [
},
];
const
fetcher
=
(
url
:
any
)
=>
fetch
(
url
).
then
((
res
)
=>
res
.
json
());
export
default
function
Workflows
({
experimentInfo
})
{
const
[
selectedWorkflow
,
setSelectedWorkflow
]
=
useState
(
null
);
const
{
data
:
workflowsData
,
error
:
workflowsError
,
isLoading
:
isLoading
,
}
=
useSWR
(
chatAPI
.
Endpoints
.
Workflows
.
List
(),
fetcher
);
const
workflows
=
workflowsData
;
function
generateNodes
(
workflow
:
any
){
let
out
:
any
[]
=
[];
let
currentTask
=
"
0
"
;
let
position
=
0
;
const
workflowConfig
=
JSON
.
parse
(
workflow
.
config
);
console
.
log
(
workflowConfig
);
while
(
currentTask
<
workflowConfig
.
nodes
.
length
)
{
out
.
push
({
id
:
currentTask
,
position
:
{
x
:
0
,
y
:
position
},
data
:
{
label
:
workflowConfig
.
nodes
[
currentTask
].
name
},
})
position
+=
100
;
currentTask
=
workflowConfig
.
nodes
[
currentTask
].
out
;
}
return
out
;
}
function
generateEdges
(
workflow
:
any
){
let
out
:
any
[]
=
[];
let
currentTask
=
"
0
"
;
let
ids
=
"
0
"
;
const
workflowConfig
=
JSON
.
parse
(
workflow
.
config
);
console
.
log
(
workflowConfig
);
while
(
currentTask
<
workflowConfig
.
nodes
.
length
)
{
out
.
push
({
id
:
ids
,
source
:
currentTask
,
target
:
workflowConfig
.
nodes
[
currentTask
].
out
,
markerEnd
:
{
type
:
'
arrow
'
,
},
})
ids
+=
1
;
currentTask
=
workflowConfig
.
nodes
[
currentTask
].
out
;
}
return
out
;
}
return
(
<
Sheet
sx
=
{
{
...
...
@@ -90,24 +149,29 @@ export default function Workflows({ experimentInfo }) {
<
Typography
level
=
"title-lg"
mb
=
{
2
}
>
Workflows
</
Typography
>
{
workflows
&&
<
List
>
{
[
1
,
2
,
3
].
map
((
i
)
=>
(
<
ListItem
key
=
{
i
}
>
<
ListItemButton
onClick
=
{
()
=>
setSelectedWorkflow
(
i
)
}
>
{
workflows
.
map
((
workflow
)
=>
(
<
ListItem
key
=
{
workflow
.
id
}
>
<
ListItemButton
onClick
=
{
()
=>
setSelectedWorkflow
(
workflow
)
}
>
<
ListItemDecorator
>
<
WorkflowIcon
/>
</
ListItemDecorator
>
<
ListItemContent
>
W
orkflow
{
i
}
</
ListItemContent
>
<
ListItemContent
>
{
w
orkflow
.
name
}
</
ListItemContent
>
→
</
ListItemButton
>
</
ListItem
>
))
}
</
List
>
}
</
Box
>
{
selectedWorkflow
&&
<
Box
flex
=
{
3
}
display
=
"flex"
flexDirection
=
"column"
>
<
Typography
level
=
"title-lg"
mb
=
{
2
}
>
Workflow
{
selectedWorkflow
}
Workflow
{
selectedWorkflow
.
name
}
</
Typography
>
<
Box
sx
=
{
{
display
:
'
flex
'
,
...
...
@@ -118,8 +182,8 @@ export default function Workflows({ experimentInfo }) {
}
}
>
<
ReactFlow
nodes
=
{
initialNodes
}
edges
=
{
initialEdges
}
nodes
=
{
generateNodes
(
selectedWorkflow
)
}
edges
=
{
generateEdges
(
selectedWorkflow
)
}
fitView
style
=
{
{
backgroundColor
:
'
#F7F9FB
'
}
}
>
...
...
@@ -140,7 +204,7 @@ export default function Workflows({ experimentInfo }) {
<
Button
variant
=
"outlined"
>
Fight
</
Button
>
</
Box
>
</
Box
>
</
Box
>
</
Box
>
}
</
Sheet
>
</
Sheet
>
);
...
...
This diff is collapsed.
Click to expand it.
src/renderer/lib/transformerlab-api-sdk.ts
+
3
−
0
View file @
2270a533
...
...
@@ -1008,6 +1008,9 @@ function convertSlashInUrl(url: string) {
return
url
.
replace
(
/
\/
/g
,
'
~~~
'
);
}
Endpoints
.
Workflows
=
{
List
:
()
=>
API_URL
()
+
'
workflows/list
'
,
}
Endpoints
.
Dataset
=
{
Gallery
:
()
=>
API_URL
()
+
'
data/gallery
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment