Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Scribe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ala
Scribe
Commits
cbc4c653
Commit
cbc4c653
authored
10 months ago
by
Julien B.
Browse files
Options
Downloads
Patches
Plain Diff
fix(trainer): change trainer function
parent
40579d40
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/internal_services/background_worker.py
+2
-13
2 additions, 13 deletions
api/internal_services/background_worker.py
api/internal_services/trainer.py
+19
-0
19 additions, 0 deletions
api/internal_services/trainer.py
microservices/trainer/trainer.py
+9
-6
9 additions, 6 deletions
microservices/trainer/trainer.py
with
30 additions
and
19 deletions
api/internal_services/background_worker.py
+
2
−
13
View file @
cbc4c653
...
@@ -4,6 +4,7 @@ from threading import Thread
...
@@ -4,6 +4,7 @@ from threading import Thread
import
grpc
import
grpc
from
api.internal_services.logger
import
logger
from
api.internal_services.logger
import
logger
from
api.internal_services.trainer
import
start_training
from
api.models.Job
import
JobType
from
api.models.Job
import
JobType
from
api.protos.trainer
import
trainer_pb2_grpc
,
trainer_pb2
from
api.protos.trainer
import
trainer_pb2_grpc
,
trainer_pb2
...
@@ -45,19 +46,7 @@ def process_trainer():
...
@@ -45,19 +46,7 @@ def process_trainer():
if
job
is
None
:
if
job
is
None
:
break
break
with
grpc
.
insecure_channel
(
job
.
job_data
[
'
server_url
'
])
as
channel
:
start_training
(
job
)
stub
=
trainer_pb2_grpc
.
TrainerStub
(
channel
)
request
=
trainer_pb2
.
TrainingInput
(
training_data
=
[],
fondation_model_id
=
job
.
job_data
[
'
fondation_model_id
'
],
finetuned_repo_name
=
job
.
job_data
[
'
finetuned_repo_name
'
],
huggingface_token
=
job
.
job_data
[
'
huggingface_token
'
],
)
logger
.
debug
(
request
)
responses
=
stub
.
StartTraining
(
request
)
for
response
in
responses
:
logger
.
debug
(
f
"
gRPC message :
{
response
.
status
}
"
)
logger
.
debug
(
f
"
fin de la connexion gRPC
"
)
logger
.
info
(
f
"
Ending of the job
{
job
.
job_id
}
"
)
logger
.
info
(
f
"
Ending of the job
{
job
.
job_id
}
"
)
trainer_queue
.
task_done
()
trainer_queue
.
task_done
()
...
...
This diff is collapsed.
Click to expand it.
api/internal_services/trainer.py
0 → 100644
+
19
−
0
View file @
cbc4c653
import
grpc
from
api.internal_services.logger
import
logger
from
api.protos.trainer
import
trainer_pb2_grpc
,
trainer_pb2
def
start_training
(
job
):
with
grpc
.
insecure_channel
(
job
.
job_data
[
'
server_url
'
])
as
channel
:
stub
=
trainer_pb2_grpc
.
TrainerStub
(
channel
)
request
=
trainer_pb2
.
TrainingInput
(
training_data
=
[],
fondation_model_id
=
job
.
job_data
[
'
fondation_model_id
'
],
finetuned_repo_name
=
job
.
job_data
[
'
finetuned_repo_name
'
],
huggingface_token
=
job
.
job_data
[
'
huggingface_token
'
],
)
logger
.
debug
(
request
)
responses
=
stub
.
StartTraining
(
request
)
for
response
in
responses
:
logger
.
debug
(
f
"
gRPC message :
{
response
.
status
}
"
)
logger
.
debug
(
f
"
fin de la connexion gRPC
"
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
microservices/trainer/trainer.py
+
9
−
6
View file @
cbc4c653
...
@@ -30,12 +30,15 @@ class TrainerServicer(trainer_pb2_grpc.TrainerServicer):
...
@@ -30,12 +30,15 @@ class TrainerServicer(trainer_pb2_grpc.TrainerServicer):
if
not
is_busy
:
if
not
is_busy
:
is_busy
=
True
is_busy
=
True
print
(
f
"
incoming request :
{
request
}
"
)
print
(
f
"
incoming request :
{
request
}
"
)
training_process
(
try
:
training_data
=
request
.
training_data
,
training_process
(
fondation_model_id
=
request
.
fondation_model_id
,
training_data
=
request
.
training_data
,
finetuned_repo_name
=
request
.
finetuned_repo_name
,
fondation_model_id
=
request
.
fondation_model_id
,
huggingface_token
=
request
.
huggingface_token
,
finetuned_repo_name
=
request
.
finetuned_repo_name
,
)
huggingface_token
=
request
.
huggingface_token
,
)
except
Exception
as
e
:
print
(
f
"
Error :
{
e
}
"
)
is_busy
=
False
is_busy
=
False
else
:
else
:
print
(
f
"
gRPC server is already busy
"
)
print
(
f
"
gRPC server is already busy
"
)
...
...
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