Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Packages
chemical_checker
Commits
c8ed0dd7
Commit
c8ed0dd7
authored
Feb 11, 2021
by
nsoler
Browse files
admin cc scripts
parent
7eb3d3b9
Pipeline
#2388
failed with stages
in 2 minutes and 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
package/scripts/add_metadata.py
View file @
c8ed0dd7
...
@@ -12,6 +12,32 @@ import h5py
...
@@ -12,6 +12,32 @@ import h5py
#VERSION= "2020_02"
#VERSION= "2020_02"
from
get_repo_version
import
cc_repo_version
from
get_repo_version
import
cc_repo_version
def
remove_backups
(
cc_repo
):
"""
Removes the previous signx_BACKUP.h5 so that the next function can generate them
DANGEROUS script! Be careful.
"""
for
molset
in
(
'full'
,
'reference'
):
for
space
in
"ABCDE"
:
for
num
in
"12345"
:
for
sign
in
signatures
:
signature
=
'sign'
+
sign
data_code
=
space
+
num
+
'.001'
fichero
=
os
.
path
.
join
(
cc_repo
,
molset
,
space
,
space
+
num
,
data_code
,
signature
,
signature
+
'_BACKUP.h5'
)
if
os
.
path
.
exists
(
fichero
):
try
:
shutil
.
rmtree
(
fichero
)
except
Exception
as
e
:
print
(
"WARINING"
,
e
)
continue
else
:
print
(
"Deleted:"
,
fichero
)
def
add_metadata
(
cc_repo
=
None
,
signatures
=
'0123'
,
backup
=
True
):
def
add_metadata
(
cc_repo
=
None
,
signatures
=
'0123'
,
backup
=
True
):
"""
"""
cc_repo: (str) path to a cc sign repo i.e /aloy/web_checker/package_cc/2020_02
cc_repo: (str) path to a cc sign repo i.e /aloy/web_checker/package_cc/2020_02
...
@@ -57,7 +83,7 @@ def add_metadata(cc_repo=None,signatures='0123', backup=True):
...
@@ -57,7 +83,7 @@ def add_metadata(cc_repo=None,signatures='0123', backup=True):
print
(
"Adding metadata to"
,
fichero
)
print
(
"Adding metadata to"
,
fichero
)
dico
=
dict
(
cctype
=
signature
,
dataset_code
=
data_code
,
molset
=
molset
)
dico
=
dict
(
cctype
=
signature
,
dataset_code
=
data_code
,
molset
=
molset
)
with
h5py
.
File
(
fichero
,
'
a
'
)
as
f
:
with
h5py
.
File
(
fichero
,
'
r+
'
)
as
f
:
for
k
,
v
in
dico
.
items
():
for
k
,
v
in
dico
.
items
():
if
k
not
in
f
.
attrs
:
if
k
not
in
f
.
attrs
:
f
.
attrs
.
create
(
name
=
k
,
data
=
v
)
f
.
attrs
.
create
(
name
=
k
,
data
=
v
)
...
@@ -66,7 +92,7 @@ def add_metadata(cc_repo=None,signatures='0123', backup=True):
...
@@ -66,7 +92,7 @@ def add_metadata(cc_repo=None,signatures='0123', backup=True):
else
:
else
:
print
(
fichero
,
"doesn't exist, skipping"
)
print
(
fichero
,
"doesn't exist, skipping"
)
print
(
"
\n
____"
)
print
(
"
\n
____"
)
def
export_sign
(
target_dir
,
cc_repo
=
None
,
signatures
=
'2'
,
molsets
=
(
'full'
),
copy_backup
=
False
,
add_metadata
=
True
):
def
export_sign
(
target_dir
,
cc_repo
=
None
,
signatures
=
'2'
,
molsets
=
(
'full'
),
copy_backup
=
False
,
add_metadata
=
True
):
...
...
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