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
4d80e2a3
Commit
4d80e2a3
authored
Jul 02, 2019
by
Markus Scheidgen
Browse files
Fixed upload delete admin command. [skip ci]
parent
3031a5d9
Pipeline
#51379
skipped
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nomad/admin/upload.py
View file @
4d80e2a3
...
...
@@ -16,7 +16,7 @@ import click
from
tabulate
import
tabulate
from
mongoengine
import
Q
from
nomad
import
processing
as
proc
,
infrastructure
,
utils
from
nomad
import
processing
as
proc
,
infrastructure
,
utils
,
search
,
files
from
.__main__
import
cli
...
...
@@ -61,9 +61,35 @@ 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
):
logger
=
utils
.
get_logger
(
__name__
)
print
(
'%d uploads selected, deleting ...'
%
uploads
.
count
())
if
with_coe_repo
:
from
nomad
import
coe_repo
infrastructure
.
setup_repository_db
()
for
upload
in
uploads
:
upload
.
delete_upload_local
(
with_coe_repo
=
with_coe_repo
)
# delete repository db entry
if
with_coe_repo
:
coe_repo
.
Upload
.
delete
(
upload
.
upload_id
)
# delete elastic
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
# delete 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