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
ddcfd699
Commit
ddcfd699
authored
Jul 17, 2019
by
Markus Scheidgen
Browse files
Migration script fixes. [skip ci]
parent
6b5945a0
Pipeline
#52029
skipped
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nomad/admin/upload.py
View file @
ddcfd699
...
...
@@ -74,8 +74,8 @@ def chown(ctx, user, uploads):
print
(
'%d uploads selected, changing its owner ...'
%
uploads
.
count
())
user_id
=
str
(
user
)
user
=
coe_repo
.
User
.
from_user_id
(
user_id
)
user_id
=
user
user
=
coe_repo
.
User
.
from_user_id
(
int
(
user_id
)
)
for
upload
in
uploads
:
upload
.
user_id
=
user_id
...
...
ops/scripts/find_duplicates.py
View file @
ddcfd699
...
...
@@ -81,6 +81,8 @@ while True:
for
upload
,
(
dup
,
single
)
in
upload_dict
.
items
():
if
dup
>
0
:
package_id
=
uploads
.
find_one
({
'_id'
:
upload
})[
'name'
]
source_upload_id
=
packages
.
find_one
({
'_id'
:
package_id
})[
'upload_id'
]
print
(
'%s, %s, %s (%d vs %d)'
%
(
source_upload_id
,
package_id
,
upload
,
dup
,
single
))
pkg
=
packages
.
find_one
({
'_id'
:
package_id
})
source_upload_id
=
pkg
[
'upload_id'
]
pkg_path
=
pkg
[
'package_path'
]
print
(
'%s, %s, %s, %s (%d vs %d)'
%
(
source_upload_id
,
package_id
,
pkg_path
,
upload
,
dup
,
single
))
break
ops/scripts/migration_fix_embargo.py
View file @
ddcfd699
...
...
@@ -11,24 +11,17 @@ infrastructure.setup_elastic()
def
check_and_fix
(
upload
):
example
=
calcs
.
find_one
({
'upload_id'
:
upload
,
'metadata.pid'
:
{
'$exists'
:
True
}})
if
example
is
None
:
# can happen on multi package uploads
return
pid
=
example
[
'metadata'
][
'pid'
]
truth
=
index
.
find_one
({
'_id'
:
pid
})
if
truth
[
'metadata'
][
'with_embargo'
]
!=
example
[
'metadata'
][
'with_embargo'
]:
print
(
'need to fix %s'
%
upload
)
calcs
.
update_many
(
{
'upload_id'
:
upload
,
'metadata.with_embargo'
:
True
},
{
'$set'
:
{
'changed'
:
True
,
'metadata.with_embargo'
:
False
}})
calcs
.
update_many
(
{
'upload_id'
:
upload
,
'metadata.with_embargo'
:
False
,
'changed'
:
True
},
{
'$unset'
:
{
'changed'
:
1
},
'$set'
:
{
'metadata.with_embargo'
:
True
}})
u
=
uploads_col
.
find_one
({
'_id'
:
upload
})
print
(
'need to fix from user %d, %s package id %s'
%
(
example
[
'metadata'
][
'uploader'
][
'id'
],
upload
,
u
[
'name'
]))
upload_proc
=
processing
.
Upload
.
get_by_id
(
upload
)
upload_with_metadata
=
upload_proc
.
to_upload_with_metadata
(
upload_proc
.
metadata
)
calcs_with_metadata
=
upload_with_metadata
.
calcs
search
.
publish
(
calcs_with_metadata
)
for
upload
in
calcs
.
distinct
(
'upload_id'
):
...
...
Write
Preview
Supports
Markdown
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