Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nomad-FAIR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Service Desk
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
nomad-lab
nomad-FAIR
Commits
9eb6f7ae
Commit
9eb6f7ae
authored
11 months ago
by
Theodore Chang
Browse files
Options
Downloads
Plain Diff
Merge branch 'single-worker-dev-env' into 'develop'
Add workers config See merge request
!1926
parents
5f25325a
9adb97f9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1926
Add workers config
Pipeline
#209647
passed
11 months ago
Stage: build
Stage: test
Stage: deploy
Stage: release
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nomad/cli/admin/run.py
+43
-18
43 additions, 18 deletions
nomad/cli/admin/run.py
nomad/processing/base.py
+1
-0
1 addition, 0 deletions
nomad/processing/base.py
with
44 additions
and
18 deletions
nomad/cli/admin/run.py
+
43
−
18
View file @
9eb6f7ae
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
# limitations under the License.
# limitations under the License.
#
#
import
functools
import
click
import
click
from
nomad
import
utils
from
nomad
import
utils
...
@@ -61,6 +60,7 @@ def app(with_gui: bool, **kwargs):
...
@@ -61,6 +60,7 @@ def app(with_gui: bool, **kwargs):
def
run_app
(
def
run_app
(
*
,
with_gui
:
bool
=
False
,
with_gui
:
bool
=
False
,
gunicorn
:
bool
=
False
,
gunicorn
:
bool
=
False
,
host
:
str
=
None
,
host
:
str
=
None
,
...
@@ -165,11 +165,16 @@ def run_app(
...
@@ -165,11 +165,16 @@ def run_app(
server
.
run
()
server
.
run
()
def
run_worker
():
def
run_worker
(
*
,
workers
=
None
):
config
.
meta
.
service
=
'
worker
'
config
.
meta
.
service
=
'
worker
'
from
nomad
import
processing
from
nomad
import
processing
processing
.
app
.
worker_main
([
'
worker
'
,
'
--loglevel=INFO
'
,
'
-B
'
,
'
-Q
'
,
'
celery
'
])
params
=
[
'
worker
'
,
'
--loglevel=INFO
'
,
'
-B
'
,
'
-Q
'
,
'
celery
'
]
if
workers
is
not
None
:
params
.
append
(
f
'
--concurrency=
{
workers
}
'
)
processing
.
app
.
worker_main
(
params
)
def
run_hub
():
def
run_hub
():
...
@@ -194,36 +199,56 @@ def run_hub():
...
@@ -194,36 +199,56 @@ def run_hub():
)
)
def
task_app
(
*
args
,
**
kwargs
):
def
task_app
(
**
kwargs
):
logger
=
utils
.
get_logger
(
'
app
'
)
logger
=
utils
.
get_logger
(
'
app
'
)
try
:
try
:
run_app
(
*
args
,
**
kwargs
)
run_app
(
**
kwargs
)
except
Exception
as
error
:
except
Exception
as
error
:
logger
.
exception
(
error
)
logger
.
exception
(
error
)
def
task_worker
():
def
task_worker
(
**
kwargs
):
logger
=
utils
.
get_logger
(
'
worker
'
)
logger
=
utils
.
get_logger
(
'
worker
'
)
try
:
try
:
run_worker
()
run_worker
(
**
kwargs
)
except
Exception
as
error
:
except
Exception
as
error
:
logger
.
exception
(
error
)
logger
.
exception
(
error
)
def
appworker_
(
app_host
=
None
,
app_port
=
None
):
def
run_appworker
(
*
,
app_host
:
str
=
None
,
app_port
:
int
=
None
,
fastapi_workers
:
int
=
None
,
celery_workers
:
int
=
None
,
dev
:
bool
=
False
,
):
from
concurrent
import
futures
as
concurrent_futures
from
concurrent
import
futures
as
concurrent_futures
import
asyncio
app_kwargs
=
{
'
host
'
:
app_host
,
'
port
'
:
app_port
}
if
dev
:
fastapi_workers
=
1
celery_workers
=
1
executor
=
concurrent_futures
.
ProcessPoolExecutor
(
2
)
with
concurrent_futures
.
ProcessPoolExecutor
(
2
)
as
executor
:
loop
=
asyncio
.
get_event_loop
()
executor
.
submit
(
task_worker
,
workers
=
celery_workers
)
# type: ignore
loop
.
run_in_executor
(
executor
,
functools
.
partial
(
task_app
,
**
app_kwargs
))
executor
.
submit
(
task_app
,
workers
=
fastapi_workers
,
host
=
app_host
,
port
=
app_port
)
# type: ignore
loop
.
run_in_executor
(
executor
,
task_worker
)
@run.command
(
help
=
'
Run both app and worker.
'
)
@run.command
(
help
=
'
Run both app and worker.
'
)
@click.option
(
'
--app-host
'
,
type
=
str
,
help
=
'
Passed as app host parameter.
'
)
@click.option
(
@click.option
(
'
--app-port
'
,
type
=
int
,
help
=
'
Passed as app port parameter.
'
)
'
--app-host
'
,
type
=
str
,
default
=
None
,
help
=
'
Passed as app host parameter.
'
def
appworker
(
app_host
:
str
=
None
,
app_port
:
int
=
None
):
)
appworker_
(
app_host
,
app_port
)
@click.option
(
'
--app-port
'
,
type
=
int
,
default
=
None
,
help
=
'
Passed as app port parameter.
'
)
@click.option
(
'
--fastapi-workers
'
,
type
=
int
,
default
=
None
,
help
=
'
Number of FastAPI workers.
'
)
@click.option
(
'
--celery-workers
'
,
type
=
int
,
default
=
None
,
help
=
'
Number of Celery workers.
'
)
@click.option
(
'
--dev
'
,
is_flag
=
True
,
default
=
False
,
help
=
'
Use one worker (for dev. env.).
'
)
def
appworker
(
**
kwargs
):
run_appworker
(
**
kwargs
)
This diff is collapsed.
Click to expand it.
nomad/processing/base.py
+
1
−
0
View file @
9eb6f7ae
...
@@ -104,6 +104,7 @@ app.conf.update(worker_max_memory_per_child=config.celery.max_memory)
...
@@ -104,6 +104,7 @@ app.conf.update(worker_max_memory_per_child=config.celery.max_memory)
if
config
.
celery
.
routing
==
CELERY_WORKER_ROUTING
:
if
config
.
celery
.
routing
==
CELERY_WORKER_ROUTING
:
app
.
conf
.
update
(
worker_direct
=
True
)
app
.
conf
.
update
(
worker_direct
=
True
)
app
.
conf
.
broker_connection_retry_on_startup
=
True
app
.
conf
.
task_queue_max_priority
=
10
app
.
conf
.
task_queue_max_priority
=
10
app
.
conf
.
worker_redirect_stdouts
=
config
.
process
.
redirect_stdouts
app
.
conf
.
worker_redirect_stdouts
=
config
.
process
.
redirect_stdouts
app
.
conf
.
worker_redirect_stdouts_level
=
'
INFO
'
app
.
conf
.
worker_redirect_stdouts_level
=
'
INFO
'
...
...
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