Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pypelines
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
HaissLab
Data Management
Pypelines
Commits
49dd60ae
Commit
49dd60ae
authored
2 months ago
by
Timothe Jost
Browse files
Options
Downloads
Patches
Plain Diff
adding a fast worker creation method to the celery app
parent
59d460b0
No related branches found
Branches containing commit
Tags
v11.1.0
Tags containing commit
No related merge requests found
Pipeline
#152669
passed
2 months ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pypelines/__init__.py
+1
-1
1 addition, 1 deletion
src/pypelines/__init__.py
src/pypelines/celery_tasks.py
+24
-0
24 additions, 0 deletions
src/pypelines/celery_tasks.py
with
25 additions
and
1 deletion
src/pypelines/__init__.py
+
1
−
1
View file @
49dd60ae
__version__
=
"
0.0.7
8
"
__version__
=
"
0.0.7
9
"
from
.
import
loggs
from
.
import
loggs
from
.pipes
import
*
from
.pipes
import
*
...
...
This diff is collapsed.
Click to expand it.
src/pypelines/celery_tasks.py
+
24
−
0
View file @
49dd60ae
...
@@ -8,6 +8,8 @@ import coloredlogs
...
@@ -8,6 +8,8 @@ import coloredlogs
from
logging
import
getLogger
from
logging
import
getLogger
from
platform
import
node
from
platform
import
node
from
pandas
import
Series
from
pandas
import
Series
import
platform
from
threading
import
Thread
from
typing
import
TYPE_CHECKING
,
List
from
typing
import
TYPE_CHECKING
,
List
...
@@ -832,6 +834,10 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
...
@@ -832,6 +834,10 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
logger
.
error
(
f
"
No handshake result. All workers are busy ?
{
e
}
"
)
logger
.
error
(
f
"
No handshake result. All workers are busy ?
{
e
}
"
)
return
False
return
False
def
single_worker_start
(
self
:
Celery
):
thread
=
CeleryWorkerThread
(
self
)
thread
.
start
()
settings_files
=
get_setting_files_path
(
conf_path
)
settings_files
=
get_setting_files_path
(
conf_path
)
if
len
(
settings_files
)
==
0
:
if
len
(
settings_files
)
==
0
:
...
@@ -893,9 +899,27 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
...
@@ -893,9 +899,27 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
app
.
get_celery_app_tasks
=
MethodType
(
get_celery_app_tasks
,
app
)
# type: ignore
app
.
get_celery_app_tasks
=
MethodType
(
get_celery_app_tasks
,
app
)
# type: ignore
app
.
launch_named_task_remotely
=
MethodType
(
launch_named_task_remotely
,
app
)
# type: ignore
app
.
launch_named_task_remotely
=
MethodType
(
launch_named_task_remotely
,
app
)
# type: ignore
app
.
is_hand_shaken
=
MethodType
(
is_hand_shaken
,
app
)
# type: ignore
app
.
is_hand_shaken
=
MethodType
(
is_hand_shaken
,
app
)
# type: ignore
app
.
single_worker_start
=
MethodType
(
single_worker_start
,
app
)
logger
.
info
(
f
"
The celery app
{
app_name
}
was created successfully.
"
)
logger
.
info
(
f
"
The celery app
{
app_name
}
was created successfully.
"
)
APPLICATIONS_STORE
[
app_name
]
=
app
APPLICATIONS_STORE
[
app_name
]
=
app
return
app
return
app
class
CeleryWorkerThread
(
Thread
):
def
__init__
(
self
,
app
:
Celery
):
super
().
__init__
()
self
.
app
=
app
def
run
(
self
):
self
.
app
.
worker_main
(
argv
=
[
"
worker
"
,
"
--loglevel=INFO
"
,
"
--concurrency=1
"
,
"
--pool=solo
"
])
# self.app.start()
def
stop
(
self
):
worker_stats
=
self
.
app
.
control
.
inspect
().
stats
()
worker_names
=
worker_stats
.
keys
()
if
worker_stats
else
[]
current_node_name
=
f
"
celery@
{
platform
.
node
()
}
"
if
current_node_name
in
worker_names
:
self
.
app
.
control
.
broadcast
(
"
shutdown
"
,
destination
=
[
current_node_name
])
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