ensembl-hive-python3  2.8.1
DigitFactory.py
Go to the documentation of this file.
1 
2 # See the NOTICE file distributed with this work for additional information
3 # regarding copyright ownership.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 import eHive
18 
19 import time
20 
22  """Factory that creates 1 job per digit found in the decimal representation of 'b_multiplier'"""
23 
24  def param_defaults(self):
25  return {
26  'take_time' : 0
27  }
28 
29 
30  def fetch_input(self):
31  b_multiplier = self.param_required('b_multiplier')
32  sub_tasks = [ { 'digit': _ } for _ in set(str(b_multiplier)).difference('01') ]
33  self.param('sub_tasks', sub_tasks)
34 
35 
36  def run(self):
37  time.sleep( self.param('take_time') )
38 
39 
40  def write_output(self):
41  sub_tasks = self.param('sub_tasks')
42  self.dataflow(sub_tasks, 2)
43  self.warning('{0} multiplication jobs have been created'.format(len(sub_tasks)))
44 
45 
eHive.process.BaseRunnable
This is the counterpart of GuestProcess.
Definition: process.py:60
eHive.examples.LongMult.DigitFactory.DigitFactory.param_defaults
def param_defaults(self)
Returns the defaults parameters for this runnable.
Definition: DigitFactory.py:24
eHive.process.BaseRunnable.dataflow
def dataflow(self, output_ids, branch_name_or_code=1)
Dataflows the output_id(s) on a given branch (default 1).
Definition: process.py:229
eHive.examples.LongMult.DigitFactory.DigitFactory
Factory that creates 1 job per digit found in the decimal representation of 'b_multiplie".
Definition: DigitFactory.py:22
eHive.process.BaseRunnable.param_required
def param_required(self, param_name)
Returns the value of the parameter "param_name" or raises an exception if anything wrong happens or t...
Definition: process.py:253
eHive.process.BaseRunnable.warning
def warning(self, message, is_error=False)
Store a message in the log_message table with is_error indicating whether the warning is actually an ...
Definition: process.py:225
eHive.examples.LongMult.DigitFactory.DigitFactory.fetch_input
def fetch_input(self)
Definition: DigitFactory.py:30
eHive.process.BaseRunnable.param
def param(self, param_name, *args)
When called as a setter: sets the value of the parameter "param_name".
Definition: process.py:266
eHive.examples.LongMult.DigitFactory.DigitFactory.write_output
def write_output(self)
Definition: DigitFactory.py:40
eHive.examples.LongMult.DigitFactory.DigitFactory.run
def run(self)
Definition: DigitFactory.py:36