Source code for fastr.examples.source_sink

#!/usr/bin/env python

# Copyright 2011-2016 Biomedical Imaging Group Rotterdam, Departments of
# Medical Informatics and Radiology, Erasmus MC, Rotterdam, The Netherlands
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


IS_TEST = True

[docs]def create_network(): # Import the faster environment and set it up import fastr # Create a new network network = fastr.Network(id_='source_sink') # Create a source node in the network source = network.create_source(fastr.typelist['Int'], id_='source') # Create a sink to save the data sink = network.create_sink(fastr.typelist['Int'], id_='sink') # Link the addint node to the sink sink.input = source.output return network
[docs]def source_data(network): return { 'source': { 'sample_a': (1, 2, 3, 4), 'sample_b': (5, 6, 7, 8), 'sample_c': (9, 10, 11, 12), } }
[docs]def sink_data(network): return {'sink': 'vfs://tmp/results/{}/result_{{sample_id}}_{{cardinality}}{{ext}}'.format(network.id)}
[docs]def main(): network = create_network() # Execute network.draw_network() network.execute(source_data(network), sink_data(network))
if __name__ == '__main__': main()