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
56e60eb7
Commit
56e60eb7
authored
1 year ago
by
Timothe Jost
Browse files
Options
Downloads
Patches
Plain Diff
fixin an issue in is_hand_shaken and adding options to get_celery_app_tasks
parent
29698c1a
No related branches found
No related tags found
No related merge requests found
Pipeline
#127822
passed
1 year 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
+9
-7
9 additions, 7 deletions
src/pypelines/celery_tasks.py
with
10 additions
and
8 deletions
src/pypelines/__init__.py
+
1
−
1
View file @
56e60eb7
__version__
=
"
0.0.5
2
"
__version__
=
"
0.0.5
3
"
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
+
9
−
7
View file @
56e60eb7
...
@@ -451,18 +451,20 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
...
@@ -451,18 +451,20 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
return
{
"
workers
"
:
workers
,
"
task_names
"
:
task_names
}
return
{
"
workers
"
:
workers
,
"
task_names
"
:
task_names
}
def
get_celery_app_tasks
(
self
,
refresh
=
False
):
def
get_celery_app_tasks
(
self
,
refresh
=
False
,
auto_refresh
=
3600
*
24
,
failed_refresh
=
60
*
5
,
initial_timeout
=
10
,
refresh_timeout
=
2
):
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
auto_refresh_time
=
timedelta
(
0
,
(
3600
*
24
)
)
# a full day (24 hours of 3600 seconds)
auto_refresh_time
=
timedelta
(
0
,
seconds
=
auto_refresh
)
# a full day (24 hours of 3600 seconds)
failed_refresh_retry_time
=
timedelta
(
0
,
(
60
*
5
)
)
# try to refresh after 5 minutes
failed_refresh_retry_time
=
timedelta
(
0
,
failed_refresh
)
# try to refresh after 5 minutes
app_task_data
=
getattr
(
self
,
"
task_data
"
,
None
)
app_task_data
=
getattr
(
self
,
"
task_data
"
,
None
)
if
app_task_data
is
None
:
if
app_task_data
is
None
:
try
:
try
:
task_data
=
self
.
tasks
[
f
"
{
app_name
}
.tasks_infos
"
].
delay
(
app_name
).
get
(
timeout
=
10
)
task_data
=
self
.
tasks
[
f
"
{
app_name
}
.tasks_infos
"
].
delay
(
app_name
).
get
(
timeout
=
initial_timeout
)
# we set timeout to 10 sec if the task data doesn't exist.
# we set timeout to 10 sec if the task data doesn't exist.
# It's long to wait for a webpage to load, but sometimes the workers take time to come out of sleep
# It's long to wait for a webpage to load, but sometimes the workers take time to come out of sleep
app_task_data
=
{
"
task_data
"
:
task_data
,
"
refresh_time
"
:
datetime
.
now
()
+
auto_refresh_time
}
app_task_data
=
{
"
task_data
"
:
task_data
,
"
refresh_time
"
:
datetime
.
now
()
+
auto_refresh_time
}
...
@@ -484,7 +486,7 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
...
@@ -484,7 +486,7 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
if
refresh
:
if
refresh
:
try
:
try
:
task_data
=
self
.
tasks
[
f
"
{
app_name
}
.tasks_infos
"
].
delay
(
app_name
).
get
(
timeout
=
2
)
task_data
=
self
.
tasks
[
f
"
{
app_name
}
.tasks_infos
"
].
delay
(
app_name
).
get
(
timeout
=
refresh_timeout
)
# if the data needs to be refreshed, we don't wait for as long as for a first get of infos.
# if the data needs to be refreshed, we don't wait for as long as for a first get of infos.
app_task_data
=
{
"
task_data
"
:
task_data
,
"
refresh_time
"
:
now
+
auto_refresh_time
}
app_task_data
=
{
"
task_data
"
:
task_data
,
"
refresh_time
"
:
now
+
auto_refresh_time
}
logger
.
warning
(
"
Refreshed celery tasks data sucessfully
"
)
logger
.
warning
(
"
Refreshed celery tasks data sucessfully
"
)
...
@@ -511,8 +513,8 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
...
@@ -511,8 +513,8 @@ def create_celery_app(conf_path, app_name="pypelines", v_host=None) -> "Celery |
result
=
self
.
tasks
[
f
"
{
app_name
}
.handshake
"
].
delay
().
get
(
timeout
=
1
)
result
=
self
.
tasks
[
f
"
{
app_name
}
.handshake
"
].
delay
().
get
(
timeout
=
1
)
logger
.
warning
(
f
"
Handshake result :
{
result
}
"
)
logger
.
warning
(
f
"
Handshake result :
{
result
}
"
)
return
True
return
True
except
ValueError
:
except
Exception
as
e
:
logger
.
error
(
"
No handshake result. All workers are busy ?
"
)
logger
.
error
(
f
"
No handshake result. All workers are busy ?
{
e
}
"
)
return
False
return
False
settings_files
=
get_setting_files_path
(
conf_path
)
settings_files
=
get_setting_files_path
(
conf_path
)
...
...
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