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
409d57c8
Commit
409d57c8
authored
2 months ago
by
Tony Salomone
Browse files
Options
Downloads
Patches
Plain Diff
Update ImportModelBar to use a jobID so its downloads get a progress bar
parent
268c7528
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/ModelZoo/ImportModelsBar.tsx
+29
-15
29 additions, 15 deletions
src/renderer/components/ModelZoo/ImportModelsBar.tsx
src/renderer/components/ModelZoo/ModelStore.tsx
+3
-3
3 additions, 3 deletions
src/renderer/components/ModelZoo/ModelStore.tsx
with
32 additions
and
18 deletions
src/renderer/components/ModelZoo/ImportModelsBar.tsx
+
29
−
15
View file @
409d57c8
...
@@ -13,10 +13,10 @@ import { PlusIcon } from 'lucide-react';
...
@@ -13,10 +13,10 @@ import { PlusIcon } from 'lucide-react';
import
*
as
chatAPI
from
'
../../lib/transformerlab-api-sdk
'
;
import
*
as
chatAPI
from
'
../../lib/transformerlab-api-sdk
'
;
import
ImportModelsModal
from
'
./ImportModelsModal
'
;
import
ImportModelsModal
from
'
./ImportModelsModal
'
;
// Needs to share
currentlyDownloading
with ModelsStore
// Needs to share
jobId
with ModelsStore
// If you start a download on one it should stop you from starting on the other
// If you start a download on one it should stop you from starting on the other
// Also this is how the import bar tells teh model store to show a download progress bar
// Also this is how the import bar tells teh model store to show a download progress bar
export
default
function
ImportModelsBar
({
currentlyDownloading
,
setCurrentlyDownloading
})
{
export
default
function
ImportModelsBar
({
jobId
,
setJobId
})
{
const
[
importModelsModalOpen
,
setImportModelsModalOpen
]
=
useState
(
false
);
const
[
importModelsModalOpen
,
setImportModelsModalOpen
]
=
useState
(
false
);
return
(
return
(
...
@@ -57,28 +57,42 @@ export default function ImportModelsBar({ currentlyDownloading, setCurrentlyDown
...
@@ -57,28 +57,42 @@ export default function ImportModelsBar({ currentlyDownloading, setCurrentlyDown
// only download if valid model is entered
// only download if valid model is entered
if
(
model
)
{
if
(
model
)
{
// this triggers UI changes while download is in progress
setJobId
(
-
1
);
setCurrentlyDownloading
(
model
);
try
{
const
jobResponse
=
await
fetch
(
chatAPI
.
Endpoints
.
Jobs
.
Create
()
);
const
newJobId
=
await
jobResponse
.
json
();
setJobId
(
newJobId
);
// Try downloading the model
// Try downloading the model
const
response
=
await
chatAPI
.
downloadModelFromHuggingFace
(
model
);
const
response
=
await
chatAPI
.
downloadModelFromHuggingFace
(
if
(
response
?.
status
==
'
error
'
)
{
model
,
alert
(
'
Download failed!
\n
'
+
response
.
message
);
newJobId
}
);
console
.
log
(
response
);
if
(
response
?.
status
==
'
error
'
)
{
alert
(
'
Download failed!
\n
'
+
response
.
message
);
}
// download complete
setJobId
(
null
);
// download complete
}
catch
(
e
)
{
setCurrentlyDownloading
(
null
);
setJobId
(
null
);
//modelGalleryMutate();
console
.
log
(
e
);
return
alert
(
'
Failed to download
'
);
}
}
}
}
}
}
}
startDecorator
=
{
startDecorator
=
{
currentlyDownloading
?
(
jobId
?
(
<
CircularProgress
size
=
"sm"
thickness
=
{
2
}
/>
<
CircularProgress
size
=
"sm"
thickness
=
{
2
}
/>
)
:
(
)
:
(
""
""
)
}
)
}
>
>
{
currentlyDownloading
?
(
{
jobId
?
(
"
Downloading
"
"
Downloading
"
)
:
(
)
:
(
"
Download 🤗 Model
"
"
Download 🤗 Model
"
...
@@ -86,7 +100,7 @@ export default function ImportModelsBar({ currentlyDownloading, setCurrentlyDown
...
@@ -86,7 +100,7 @@ export default function ImportModelsBar({ currentlyDownloading, setCurrentlyDown
</
Button
>
</
Button
>
}
}
sx
=
{
{
width
:
'
500px
'
}
}
sx
=
{
{
width
:
'
500px
'
}
}
disabled
=
{
currentlyDownloading
}
disabled
=
{
jobId
!=
null
}
/>
/>
</
FormControl
>
</
FormControl
>
<
Button
<
Button
...
...
This diff is collapsed.
Click to expand it.
src/renderer/components/ModelZoo/ModelStore.tsx
+
3
−
3
View file @
409d57c8
...
@@ -117,7 +117,7 @@ export default function ModelStore() {
...
@@ -117,7 +117,7 @@ export default function ModelStore() {
}
=
useSWR
(
chatAPI
.
Endpoints
.
Models
.
Gallery
(),
fetcher
);
}
=
useSWR
(
chatAPI
.
Endpoints
.
Models
.
Gallery
(),
fetcher
);
const
{
data
:
modelDownloadProgress
}
=
useSWR
(
const
{
data
:
modelDownloadProgress
}
=
useSWR
(
currentlyDownloading
&&
jobId
&&
jobId
!=
'
-1
'
jobId
&&
jobId
!=
'
-1
'
?
chatAPI
.
Endpoints
.
Jobs
.
Get
(
jobId
)
?
chatAPI
.
Endpoints
.
Jobs
.
Get
(
jobId
)
:
null
,
:
null
,
fetcher
,
fetcher
,
...
@@ -606,8 +606,8 @@ export default function ModelStore() {
...
@@ -606,8 +606,8 @@ export default function ModelStore() {
</
Table
>
</
Table
>
</
Sheet
>
</
Sheet
>
<
ImportModelsBar
<
ImportModelsBar
currentlyDownloading
=
{
currentlyDownloading
}
jobId
=
{
jobId
}
set
CurrentlyDownloading
=
{
setCurrentlyDownloading
}
set
JobId
=
{
setJobId
}
/>
/>
</
Sheet
>
</
Sheet
>
);
);
...
...
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