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
genotoul-bioinfo
ng6
Commits
b412ffa6
Commit
b412ffa6
authored
Jun 03, 2020
by
Romain Therville
🐭
Browse files
The switchspaceid workflow has been made to update the paths to the
migrated analysis files (broken links and missing files). Issue#129
parent
f632d6aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/ng6/analysis.py
View file @
b412ffa6
...
@@ -622,7 +622,7 @@ class Analysis (Component):
...
@@ -622,7 +622,7 @@ class Analysis (Component):
file_name
=
os
.
path
.
basename
(
file
)
file_name
=
os
.
path
.
basename
(
file
)
else
:
else
:
copyfile
(
file
,
os
.
path
.
join
(
self
.
__get_work_directory
(),
file_name
))
copyfile
(
file
,
os
.
path
.
join
(
self
.
__get_work_directory
(),
file_name
))
return
'fileadmin'
+
os
.
path
.
join
(
self
.
directory
,
file
_name
)
return
self
.
get_full_filepath
(
file_name
,
'
file
admin'
)
def
_save_files
(
self
,
files
,
gzip
=
False
):
def
_save_files
(
self
,
files
,
gzip
=
False
):
"""
"""
...
@@ -722,6 +722,8 @@ class Analysis (Component):
...
@@ -722,6 +722,8 @@ class Analysis (Component):
return
t3mysql
.
select_analysis_directory
(
str
(
self
.
id
))
return
t3mysql
.
select_analysis_directory
(
str
(
self
.
id
))
def
change_space
(
self
,
space_id
):
def
change_space
(
self
,
space_id
):
import
os
from
ng6.project
import
Project
ng6conf
=
NG6ConfigReader
()
ng6conf
=
NG6ConfigReader
()
old_path
=
ng6conf
.
get_save_directory
()
+
self
.
directory
old_path
=
ng6conf
.
get_save_directory
()
+
self
.
directory
...
@@ -749,6 +751,21 @@ class Analysis (Component):
...
@@ -749,6 +751,21 @@ class Analysis (Component):
t3mysql
=
t3MySQLdb
()
t3mysql
=
t3MySQLdb
()
t3mysql
.
update_fields
(
'tx_nG6_analyze'
,
str
(
self
.
id
),
[
'directory'
,
'retention_date'
],
[
str
(
"/"
+
new_relative_path
),
new_retention
]
)
t3mysql
.
update_fields
(
'tx_nG6_analyze'
,
str
(
self
.
id
),
[
'directory'
,
'retention_date'
],
[
str
(
"/"
+
new_relative_path
),
new_retention
]
)
old_dir_name
=
self
.
__get_save_directory
()
new_dir_name
=
ng6conf
.
get_space_directory
(
space_id
)
result_files
=
t3mysql
.
get_analysis_result_files
(
str
(
self
.
id
),
'fileadmin'
)
for
result_file
in
result_files
:
filename
=
os
.
path
.
basename
(
result_file
[
'rvalue'
])
new_filepath
=
self
.
get_full_filepath
(
filename
)
print
(
"new_filepath = "
+
str
(
new_filepath
))
print
(
"result uid = "
+
str
(
result_file
[
'uid'
]))
t3mysql
.
update_fields
(
'tx_nG6_result'
,
str
(
result_file
[
'uid'
]),
[
'rvalue'
],
[
str
(
new_filepath
)]
)
return
[
retcode
,
str_cmd
]
return
[
retcode
,
str_cmd
]
def
get_full_filepath
(
self
,
file_name
,
base_filepath
=
'fileadmin'
):
return
base_filepath
+
os
.
path
.
join
(
self
.
directory
,
file_name
)
\ No newline at end of file
src/ng6/t3MySQLdb.py
View file @
b412ffa6
...
@@ -1066,4 +1066,16 @@ class t3MySQLdb(object):
...
@@ -1066,4 +1066,16 @@ class t3MySQLdb(object):
qresult
=
self
.
execute
(
sql
)
qresult
=
self
.
execute
(
sql
)
return
[
r
[
0
]
for
r
in
qresult
.
rows
]
return
[
r
[
0
]
for
r
in
qresult
.
rows
]
def
get_analysis_result_files
(
self
,
analysis_id
,
base_filepath
=
'fileadmin'
):
sql
=
"SELECT uid, rvalue FROM tx_nG6_result WHERE analyze_id='"
+
str
(
analysis_id
)
+
"' AND rvalue LIKE '"
+
str
(
base_filepath
)
+
"%'"
print
(
sql
)
qresult
=
self
.
execute
(
sql
)
results
=
[]
for
result
in
qresult
.
rows
:
results
.
append
({
'uid'
:
result
[
0
],
'rvalue'
:
result
[
1
],
})
return
results
\ No newline at end of file
workflows/switch_space_id/components/move_project.py
View file @
b412ffa6
...
@@ -35,7 +35,6 @@ def migrate_project (project_id, new_space_id, output):
...
@@ -35,7 +35,6 @@ def migrate_project (project_id, new_space_id, output):
fh
.
write
(
log_text
)
fh
.
write
(
log_text
)
fh
.
close
()
fh
.
close
()
logging
.
getLogger
(
"move_project.py"
).
debug
(
log_text
)
logging
.
getLogger
(
"move_project.py"
).
debug
(
log_text
)
print
(
"os.path.exists("
+
log_file
+
")="
+
str
(
os
.
path
.
exists
(
log_file
)))
ng6conf
=
NG6ConfigReader
()
ng6conf
=
NG6ConfigReader
()
base_path
=
ng6conf
.
get_save_directory
()
base_path
=
ng6conf
.
get_save_directory
()
...
@@ -47,6 +46,7 @@ def migrate_project (project_id, new_space_id, output):
...
@@ -47,6 +46,7 @@ def migrate_project (project_id, new_space_id, output):
log_to_output_files
(
str_log
,
output
)
log_to_output_files
(
str_log
,
output
)
runs
=
project
.
get_runs
()
runs
=
project
.
get_runs
()
#print(runs)
for
run
in
runs
:
for
run
in
runs
:
str_log
=
"
\t
- ##RUN '"
+
run
.
name
+
"' ("
+
str
(
run
.
id
)
+
") - "
+
run
.
directory
+
"
\n
"
str_log
=
"
\t
- ##RUN '"
+
run
.
name
+
"' ("
+
str
(
run
.
id
)
+
") - "
+
run
.
directory
+
"
\n
"
log_to_output_files
(
str_log
,
output
)
log_to_output_files
(
str_log
,
output
)
...
@@ -66,6 +66,8 @@ def migrate_project (project_id, new_space_id, output):
...
@@ -66,6 +66,8 @@ def migrate_project (project_id, new_space_id, output):
analyzes
=
project
.
get_analysis
()
analyzes
=
project
.
get_analysis
()
for
analysis
in
analyzes
:
for
analysis
in
analyzes
:
print
(
analysis
.
results
)
str_log
=
"
\t
- ##ANALYSE PROJECT '"
+
analysis
.
name
+
"' ("
+
str
(
analysis
.
id
)
+
") - "
+
analysis
.
directory
+
"
\n
"
str_log
=
"
\t
- ##ANALYSE PROJECT '"
+
analysis
.
name
+
"' ("
+
str
(
analysis
.
id
)
+
") - "
+
analysis
.
directory
+
"
\n
"
log_to_output_files
(
str_log
,
output
)
log_to_output_files
(
str_log
,
output
)
...
...
Romain Therville
🐭
@rtherville
mentioned in issue
#129 (closed)
·
Jun 04, 2020
mentioned in issue
#129 (closed)
mentioned in issue #129
Toggle commit list
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