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
1e2ac44f
Commit
1e2ac44f
authored
11 months ago
by
Tony Salomone
Browse files
Options
Downloads
Patches
Plain Diff
Update import modal to report error or success message
parent
f9d378a4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/renderer/components/ModelZoo/ImportModelsModal.tsx
+45
-2
45 additions, 2 deletions
src/renderer/components/ModelZoo/ImportModelsModal.tsx
with
45 additions
and
2 deletions
src/renderer/components/ModelZoo/ImportModelsModal.tsx
+
45
−
2
View file @
1e2ac44f
...
@@ -37,20 +37,63 @@ export default function ImportModelsModal({ open, setOpen}) {
...
@@ -37,20 +37,63 @@ export default function ImportModelsModal({ open, setOpen}) {
);
);
const
models
=
modelsData
?.
data
;
const
models
=
modelsData
?.
data
;
// model_ids is an iterator
/*
* This funciton takes an Iterator with model information and tries to import
* each of those models through individual calls to the backend.
*
* When it completes it displays an alert with results.
*/
async
function
importRun
(
model_ids
:
Iterator
)
{
async
function
importRun
(
model_ids
:
Iterator
)
{
// storing results
let
totalImports
=
0
;
let
successfulImports
=
0
;
let
error_msg
=
""
;
let
next
=
model_ids
.
next
();
let
next
=
model_ids
.
next
();
while
(
!
next
.
done
)
{
while
(
!
next
.
done
)
{
// In the iterator, each iteam is a key (model_id) and a value (blank)
// In the iterator, each iteam is a key (model_id) and a value (blank)
// this is just how it gets produced from the form
// this is just how it gets produced from the form
const
model_id
=
next
.
value
[
0
];
const
model_id
=
next
.
value
[
0
];
console
.
log
(
"
Importing
"
+
model_id
);
console
.
log
(
"
Importing
"
+
model_id
);
await
fetch
(
const
response
=
await
fetch
(
// TODO: Hardcoding hugging face as model source for now as it's the only source
// TODO: Hardcoding hugging face as model source for now as it's the only source
chatAPI
.
Endpoints
.
Models
.
ImportLocal
(
"
huggingface
"
,
model_id
)
chatAPI
.
Endpoints
.
Models
.
ImportLocal
(
"
huggingface
"
,
model_id
)
);
);
// Read the response to see if it was successful and report any errors
let
response_error
=
""
;
if
(
response
.
ok
)
{
const
response_json
=
await
response
.
json
();
if
(
response_json
.
status
==
"
success
"
)
{
successfulImports
++
;
}
else
if
(
"
message
"
in
response_json
)
{
response_error
=
response_json
.
message
;
}
else
{
response_error
=
"
Unspecified error
"
;
}
}
else
{
response_error
=
"
API error
"
;
}
// Log errors
if
(
response_error
)
{
const
new_error
=
`
${
model_id
}
:
${
response_error
}
`
;
console
.
log
(
new_error
);
error_msg
+=
`
${
new_error
}
\n`
;
}
totalImports
++
;
next
=
model_ids
.
next
();
next
=
model_ids
.
next
();
}
}
const
result_msg
=
`
${
successfulImports
}
of
${
totalImports
}
models imported.`
;
console
.
log
(
result_msg
);
if
(
error_msg
)
{
alert
(
`
${
result_msg
}
\n\nErrors:\n
${
error_msg
}
`
);
}
else
{
alert
(
result_msg
);
}
return
;
return
;
}
}
...
...
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