Why does the main statement in a mrjob Python program accept only one line of code?

StackOverflow https://stackoverflow.com/questions/18972422

  •  29-06-2022
  •  | 
  •  

Pergunta

I want to know how long a mrjob program runs. However, I get an unindent does not match any outer indentation level error if I put in time.time() before and after MRWord.run(), and I couldn't find any documentation about this. What am I missing?

from mrjob.job import MRJob

class MRWord(MRJob):

  def mapper(self, _, line):
    x = line.split()
    yield x[0], 1

  def reducer(self, word, counts):
    yield word, sum(counts)

if __name__ == '__main__':

  t0 = time.time() 

  MRWord.run()

  print time.time() - t0
Foi útil?

Solução

check the indent before t0 = time.time(), did you mixed space and tab?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top