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
86a86adc
Commit
86a86adc
authored
5 years ago
by
Markus Scheidgen
Browse files
Options
Downloads
Patches
Plain Diff
Added chown cmd to admin cli. [skip ci]
parent
38032188
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!47
V0.4.6 bugfixes
Pipeline
#52001
skipped
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nomad/admin/upload.py
+33
-1
33 additions, 1 deletion
nomad/admin/upload.py
with
33 additions
and
1 deletion
nomad/admin/upload.py
+
33
−
1
View file @
86a86adc
...
...
@@ -15,8 +15,9 @@
import
click
from
tabulate
import
tabulate
from
mongoengine
import
Q
from
pymongo
import
UpdateOne
from
nomad
import
processing
as
proc
,
infrastructure
,
utils
,
search
,
files
from
nomad
import
processing
as
proc
,
infrastructure
,
utils
,
search
,
files
,
coe_repo
from
.__main__
import
cli
...
...
@@ -63,6 +64,37 @@ def ls(ctx, uploads):
headers
=
[
'
id
'
,
'
name
'
,
'
user
'
,
'
status
'
,
'
published
'
]))
@upload.command
(
help
=
'
Change the owner of the upload and all its calcs.
'
)
@click.argument
(
'
USER
'
,
nargs
=
1
)
@click.argument
(
'
UPLOADS
'
,
nargs
=-
1
)
@click.pass_context
def
chown
(
ctx
,
user
,
uploads
):
infrastructure
.
setup_repository_db
()
_
,
uploads
=
query_uploads
(
ctx
,
uploads
)
print
(
'
%d uploads selected, changing its owner ...
'
%
uploads
.
count
())
user_id
=
str
(
user
)
user
=
coe_repo
.
User
.
from_user_id
(
user_id
)
for
upload
in
uploads
:
upload
.
user_id
=
user_id
upload_with_metadata
=
upload
.
to_upload_with_metadata
()
calcs
=
upload_with_metadata
.
calcs
def
create_update
(
calc
):
return
UpdateOne
(
{
'
_id
'
:
calc
.
calc_id
},
{
'
$set
'
:
{
'
metadata.uploader
'
:
user
.
to_popo
()}})
proc
.
Calc
.
_get_collection
().
bulk_write
([
create_update
(
calc
)
for
calc
in
calcs
])
upload
.
save
()
upload_with_metadata
=
upload
.
to_upload_with_metadata
()
calcs
=
upload_with_metadata
.
calcs
search
.
publish
(
calcs
)
@upload.command
(
help
=
'
Delete selected upload
'
)
@click.argument
(
'
UPLOADS
'
,
nargs
=-
1
)
@click.option
(
'
--with-coe-repo
'
,
help
=
'
Also attempt to delete from repository db
'
,
is_flag
=
True
)
...
...
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