Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
4a5ac8b1
Commit
4a5ac8b1
authored
Aug 02, 2019
by
Markus Scheidgen
Browse files
Added dry option to index cli command. [skip ci]
parent
2771c58a
Pipeline
#53082
skipped
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nomad/cli/admin/admin.py
View file @
4a5ac8b1
...
...
@@ -30,7 +30,8 @@ def admin(ctx):
@
admin
.
command
(
help
=
'(Re-)index all calcs.'
)
@
click
.
option
(
'--threads'
,
type
=
int
,
default
=
1
,
help
=
'Number of threads to use.'
)
def
index
(
threads
):
@
click
.
option
(
'--dry'
,
is_flag
=
True
,
help
=
'Do not index, just compute entries.'
)
def
index
(
threads
,
dry
):
infrastructure
.
setup_logging
()
infrastructure
.
setup_mongo
()
infrastructure
.
setup_elastic
()
...
...
@@ -43,15 +44,20 @@ def index(threads):
with
utils
.
ETA
(
all_calcs
,
' index %10d or %10d calcs, ETA %s'
)
as
eta
:
for
calc
in
proc
.
Calc
.
objects
():
eta
.
add
()
entry
=
None
entry
=
search
.
Entry
.
from_calc_with_metadata
(
datamodel
.
CalcWithMetadata
(
**
calc
.
metadata
))
entry
=
entry
.
to_dict
(
include_meta
=
True
)
entry
[
'_op_type'
]
=
'index'
yield
entry
if
dry
:
for
_
in
elastic_updates
():
pass
if
threads
>
1
:
print
(
' use %d threads'
%
threads
)
for
_
in
elasticsearch
.
helpers
.
parallel_bulk
(
infrastructure
.
elastic_client
,
elastic_updates
(),
chunk_size
=
10
00
,
infrastructure
.
elastic_client
,
elastic_updates
(),
chunk_size
=
5
00
,
thread_count
=
threads
):
pass
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment