Bases: pipelet.environment.EnvironmentBase
Default segment’s facilities.
The default environment contains some basic utilities related to filenames, parameters and subprocesses. It can be extended to complete the default environment with new utilities.
Complete the filename with the path to the working directory.
>>> get_data_fn ("test.png")
./test/first_test/first_S3CRKVY/data/test.png
Return the input coming from segment seg.
If no segment specified, take the first. This utility replaces the seg_input variable which type could vary as described below.
>>> get_input(seg='third')
the_brave
Obtain a temporary filename
Note : has to be part of the segment execution environment The temporary file is added to the intern list for future removal.
>>> get_tmp_fn()
./test/first_test/third_QA7CX5A/fourth_LGJSKVQ/735200
Globbing limited to the fatherhood. For unlimited globbing see glob_seg.
>>> glob_parent ('test*.txt')
['./test/first_test/first_S3CRKVY/second_WDSDP3Q/data/7_Robin/test.txt']
Return the list of filename matching y in the working directory of segment x.
Usage of glob_seg should be limited: + potentially breaks the dependancy scheme + may hurt performances as all task directories of the segment x will be searched
>>> glob_seg ('second', 'test*.txt')
['./test/first_test/first_S3CRKVY/second_WDSDP3Q/data/8_Arthur/test.txt', './test/first_test/first_S3CRKVY/second_WDSDP3Q/data/7_Robin/test.txt']
Execute hook code.
Search for an extra segment code file, and update dictionnary with the result of its execution.
Update the global dictionnary with parameters of a segment.
>>> load_param('second', globals(), ["fn"])
>>> print fn
test.txt
Update a namespace by unpickling requested object from the file.
>>> load_products(get_data_fn("test.pkl", seg="second"), globals(),['i'])
>>> print i
0
Execute a subprocess and log its output.
Create files process_name.log and process_name.err. If shell is set to True, the command is run via a shell. If except_on_failure set to True, raise an exception when command execution return non zero
>>> (o,e)=logged_subprocess (["echo", "$TMP"])
>>> open(o).readlines()
['$BASH']