Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
pipelet
Pipelet
Commits
f28cc575
Commit
f28cc575
authored
Feb 11, 2011
by
Maude Le Jeune
Browse files
add get_input facility to environment
parent
015bdb2f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
5 deletions
+36
-5
TODO.org
TODO.org
+1
-1
pipelet/environment.py
pipelet/environment.py
+27
-0
test/multiplex/a.py
test/multiplex/a.py
+3
-2
test/multiplex/b.py
test/multiplex/b.py
+3
-2
test/multiplex/c.py
test/multiplex/c.py
+2
-0
No files found.
TODO.org
View file @
f28cc575
...
...
@@ -36,7 +36,7 @@ I see at least before three projects to complete before making the first release
result. I think this is not an issue (Maude)
- [ ] Its calling signature should be rethought
- The name should be changed in glob_parents and glob_seg
- [
] Are we satisfied with seg_input, is this convenient, should we
- [
X
] Are we satisfied with seg_input, is this convenient, should we
provide extra function to ease the retrieval of inputs.
- [ ] Are we satisfied with the lst_par, lst_tag, load_param syntax (may become save(name1,name2 ...) and expose(name1,name2...))
- [ ] logged_subprocess is the function I use in every segment,
...
...
pipelet/environment.py
View file @
f28cc575
...
...
@@ -151,6 +151,33 @@ class Environment(EnvironmentBase):
self
.
logger
=
init_logger
(
self
.
_get_data_fn
(
""
),
self
.
_get_log_file
(),
level
=
[])
def
get_input
(
self
,
seg
=
None
):
""" Get segment input.
Parameters
----------
seg: string segment name
Returns
-------
python object or None
"""
if
isinstance
(
self
.
seg_input
,
dict
):
if
seg
is
not
None
:
if
self
.
seg_input
.
has_key
(
seg
):
return
self
.
seg_input
[
seg
]
else
:
self
.
logger
.
info
(
"No input from parent named %s"
,
seg
)
else
:
if
len
(
self
.
seg_input
.
values
())
>
0
:
return
self
.
seg_input
.
values
()[
0
]
else
:
self
.
logger
.
info
(
"Empty input list"
)
elif
isinstance
(
self
.
seg_input
,
list
)
and
len
(
self
.
seg_input
)
==
0
:
self
.
logger
.
info
(
"Empty input list"
)
else
:
return
self
.
seg_input
return
None
def
get_data_fn
(
self
,
x
):
""" Complete the filename with the path to the working
...
...
test/multiplex/a.py
View file @
f28cc575
print
seg_input
import
os
os
.
system
(
"touch %s"
%
get_data_fn
(
"file%d.dat"
%
seg_input
.
values
()[
0
]))
seg_output
=
[
seg_input
.
values
()[
0
]]
inp
=
get_input
()
os
.
system
(
"touch %s"
%
get_data_fn
(
"file%d.dat"
%
inp
))
seg_output
=
[
inp
]
test/multiplex/b.py
View file @
f28cc575
#seg_output = ['aa', 'bb']
import
os
print
seg_input
os
.
system
(
"touch %s"
%
get_data_fn
(
"bbbb%d.dat"
%
seg_input
.
values
()[
0
]))
#seg_output = [(seg_input.values()[0], "pp")]
inp
=
get_input
()
os
.
system
(
"touch %s"
%
get_data_fn
(
"bbbb%d.dat"
%
inp
))
seg_output
=
[(
inp
,
"pp"
)]
test/multiplex/c.py
View file @
f28cc575
#multiplex cross_prod group_by "0"
print
seg_input
import
os
f
=
glob_seg
(
"a"
,
"file*.dat"
)
for
file
in
f
:
...
...
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