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
jflow
Commits
bc5edc7d
Commit
bc5edc7d
authored
Mar 12, 2013
by
Jerome Mariette
Browse files
handle errors when not adding a loaded component
parent
59a9f93b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/jflow/workflow.py
View file @
bc5edc7d
...
...
@@ -111,28 +111,32 @@ class Workflow(threading.Thread):
def
add_component
(
self
,
component_name
,
args
=
[],
kwargs
=
{},
component_prefix
=
"default"
):
# first build and check if this component is OK
my_pckge
=
__import__
(
self
.
comp_pckg
[
component_name
],
globals
(),
locals
(),
[
component_name
],
-
1
)
# build the object and define required field
cmpt_object
=
getattr
(
my_pckge
,
component_name
)()
cmpt_object
.
output_directory
=
self
.
get_component_output_directory
(
component_name
,
component_prefix
)
cmpt_object
.
prefix
=
component_prefix
if
kwargs
:
cmpt_object
.
define_parameters
(
**
kwargs
)
else
:
cmpt_object
.
define_parameters
(
*
args
)
# if already init, add the component to the list and check if weaver should be executed
if
self
.
component_nameids_is_init
:
# add the component
self
.
components
.
append
(
cmpt_object
)
# if this one require a dynamic pipeline, execute the first part
if
cmpt_object
.
is_dynamic
:
self
.
_execute_weaver
()
else
:
if
self
.
_component_is_duplicated
(
cmpt_object
):
raise
ValueError
(
"Component "
+
cmpt_object
.
__class__
.
__name__
+
" with prefix "
+
cmpt_object
.
prefix
+
" already exist in this pipeline!"
)
self
.
component_nameids
[
cmpt_object
.
get_nameid
()]
=
None
if
self
.
comp_pckg
.
has_key
(
component_name
):
my_pckge
=
__import__
(
self
.
comp_pckg
[
component_name
],
globals
(),
locals
(),
[
component_name
],
-
1
)
# build the object and define required field
cmpt_object
=
getattr
(
my_pckge
,
component_name
)()
cmpt_object
.
output_directory
=
self
.
get_component_output_directory
(
component_name
,
component_prefix
)
cmpt_object
.
prefix
=
component_prefix
if
kwargs
:
cmpt_object
.
define_parameters
(
**
kwargs
)
else
:
cmpt_object
.
define_parameters
(
*
args
)
# if already init, add the component to the list and check if weaver should be executed
if
self
.
component_nameids_is_init
:
# add the component
self
.
components
.
append
(
cmpt_object
)
# if this one require a dynamic pipeline, execute the first part
if
cmpt_object
.
is_dynamic
:
self
.
_execute_weaver
()
else
:
if
self
.
_component_is_duplicated
(
cmpt_object
):
raise
ValueError
(
"Component "
+
cmpt_object
.
__class__
.
__name__
+
" with prefix "
+
cmpt_object
.
prefix
+
" already exist in this pipeline!"
)
self
.
component_nameids
[
cmpt_object
.
get_nameid
()]
=
None
return
cmpt_object
return
cmpt_object
else
:
sys
.
exit
(
component_name
+
" component cannot be loaded, available components are: "
+
", "
.
join
(
self
.
comp_pckg
.
keys
()))
def
pre_process
(
self
):
pass
...
...
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