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
genotoul-bioinfo
jflow
Commits
d605f15b
Commit
d605f15b
authored
Dec 03, 2015
by
Céline Noirot
Browse files
Add trace execution
parent
c334bce3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/jflow/component.py
View file @
d605f15b
...
...
@@ -37,15 +37,15 @@ from weaver.function import PythonFunction
class
Component
(
object
):
TRACE
=
"trace.cmd"
def
__init__
(
self
):
self
.
prefix
=
"default"
self
.
params_order
=
[]
self
.
output_directory
=
None
self
.
config_reader
=
JFlowConfigReader
()
self
.
version
=
self
.
get_version
()
if
isinstance
(
self
.
version
,
bytes
):
self
.
version
=
self
.
version
.
decode
()
self
.
batch_options
=
self
.
config_reader
.
get_component_batch_options
(
self
.
__class__
.
__name__
)
def
is_dynamic
(
self
):
...
...
@@ -543,6 +543,8 @@ class Component(object):
else
:
py_function
(
inputs
=
new_inputs
,
outputs
=
new_outputs
,
arguments
=
arguments
,
includes
=
includes
+
includes_in
)
self
.
write_trace
(
function
.
__name__
,
inputs
,
outputs
,
arguments
,
cmd_format
,
map
,
"PythonFunction"
)
def
add_shell_execution
(
self
,
source
,
inputs
=
[],
outputs
=
[],
arguments
=
[],
includes
=
[],
cmd_format
=
None
,
map
=
False
,
shell
=
None
,
collect
=
False
,
local
=
False
):
shell_function
=
ShellFunction
(
source
,
shell
=
shell
,
cmd_format
=
cmd_format
)
...
...
@@ -562,3 +564,33 @@ class Component(object):
else
:
shell_function
(
inputs
=
inputs
,
outputs
=
outputs
,
arguments
=
arguments
,
includes
=
includes
)
self
.
write_trace
(
source
,
inputs
,
outputs
,
arguments
,
cmd_format
,
map
,
"Shell"
)
def
write_trace
(
self
,
name
,
inputs
,
outputs
,
arguments
,
cmd_format
,
map
,
type
):
trace_fh
=
open
(
os
.
path
.
join
(
self
.
output_directory
,
Component
.
TRACE
),
"a"
)
trace_fh
.
write
(
"###
\n
###Execution trace of "
+
type
+
": "
+
name
+
"
\n
"
)
if
map
:
trace_fh
.
write
(
"MODE MAP
\n
"
)
if
cmd_format
!=
""
and
type
==
"Shell"
:
trace_fh
.
write
(
"COMMAND: "
+
str
(
cmd_format
)
+
"
\n
"
)
self
.
write_element
(
trace_fh
,
"ARGCUMENTS"
,
arguments
)
self
.
write_element
(
trace_fh
,
"INPUTS"
,
inputs
)
self
.
write_element
(
trace_fh
,
"OUTPUTS"
,
outputs
)
trace_fh
.
close
()
def
write_element
(
self
,
fh
,
title
,
element
):
to_write
=
''
if
isinstance
(
element
,
list
):
if
len
(
element
)
>
0
:
if
isinstance
(
element
[
0
],
list
):
for
i
in
range
(
len
(
element
))
:
to_write
+=
"List"
+
str
(
i
+
1
)
+
":
\n
"
to_write
+=
"
\n
"
.
join
(
element
[
i
])
+
"
\n
"
else
:
to_write
+=
"
\n
"
.
join
(
element
)
+
"
\n
"
else
:
to_write
+=
element
+
"
\n
"
if
to_write
!=
""
:
fh
.
write
(
title
+
" :
\n
"
)
fh
.
write
(
to_write
)
\ No newline at end of file
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