Skip to content
GitLab
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
28708bc2
Commit
28708bc2
authored
Jul 16, 2019
by
Markus Scheidgen
Browse files
Add skip parameters to admin upload delete cli command. [skip ci]
parent
8e9c2431
Pipeline
#51959
skipped
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nomad/admin/upload.py
View file @
28708bc2
...
...
@@ -60,7 +60,10 @@ def ls():
@
upload
.
command
(
help
=
'Delete selected upload'
)
@
click
.
option
(
'--with-coe-repo'
,
help
=
'Also attempt to delete from repository db'
,
is_flag
=
True
)
def
rm
(
with_coe_repo
):
@
click
.
option
(
'--skip-es'
,
help
=
'Keep the elastic index version of the data.'
,
is_flag
=
True
)
@
click
.
option
(
'--skip-mongo'
,
help
=
'Keep uploads and calcs in mongo.'
,
is_flag
=
True
)
@
click
.
option
(
'--skip-files'
,
help
=
'Keep all related files.'
,
is_flag
=
True
)
def
rm
(
with_coe_repo
,
skip_es
,
skip_mongo
,
skip_files
):
logger
=
utils
.
get_logger
(
__name__
)
print
(
'%d uploads selected, deleting ...'
%
uploads
.
count
())
...
...
@@ -74,22 +77,26 @@ def rm(with_coe_repo):
coe_repo
.
Upload
.
delete
(
upload
.
upload_id
)
# delete elastic
search
.
delete_upload
(
upload_id
=
upload
.
upload_id
)
if
not
skip_es
:
search
.
delete_upload
(
upload_id
=
upload
.
upload_id
)
# delete files
for
_
in
range
(
0
,
2
):
upload_files
=
files
.
UploadFiles
.
get
(
upload_id
=
upload
.
upload_id
)
try
:
if
upload_files
is
not
None
:
upload_files
.
delete
()
except
Exception
as
e
:
logger
.
error
(
'could not delete files'
,
exc_info
=
e
)
break
if
not
skip_files
:
# do it twice to get the two potential versions 'public' and 'staging'
for
_
in
range
(
0
,
2
):
upload_files
=
files
.
UploadFiles
.
get
(
upload_id
=
upload
.
upload_id
)
try
:
if
upload_files
is
not
None
:
upload_files
.
delete
()
except
Exception
as
e
:
logger
.
error
(
'could not delete files'
,
exc_info
=
e
)
break
# delete mongo
proc
.
Calc
.
objects
(
upload_id
=
upload
.
upload_id
).
delete
()
upload
.
delete
()
if
not
skip_mongo
:
proc
.
Calc
.
objects
(
upload_id
=
upload
.
upload_id
).
delete
()
upload
.
delete
()
@
upload
.
command
(
help
=
'Attempt to abort the processing of uploads.'
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment