2

I am writing a multi-step mrjob. The first step does some pre-processing and ends with the following reducer:

def some_reducer(self, key, values):
    values = (int (value) for value in values)
    if key == 'iwantthiskey':
        //I want to pass sum(values) as a parameter to the next step

I've tried going through the documentation and experimented with adding passthrough options or adding values to self.jobconf(), but I couldn't figure it out. Any help would be appreciated.

Martin Boyanov
  • 416
  • 3
  • 13

1 Answers1

0

Sonic provided an excellent solution by making a global variable. Basically, once you get the wanted value, store it in the global variable for later use.

my_parameter = None

def some_reducer(self, key, values):
  global my_parameter
  values = (int (value) for value in values)
  if key == 'iwantthiskey':
      my_parameter = sum(values)

def next_funtion_or_job(self, input, parameter=my_parameter):
  #Your method goes here.

````

Community
  • 1
  • 1
xjlin0
  • 341
  • 5
  • 10