thbar / kiba

Data processing & ETL framework for Ruby
https://www.kiba-etl.org
Other
1.75k stars 87 forks source link

sample installation #32

Closed attahkhan016 closed 7 years ago

attahkhan016 commented 7 years ago

Hello , When i try to follow similarly to the tutorial i have landed on a error . can you look into it and let me know now where i have gone wrong ?

attahkhan016 commented 7 years ago

my movies.etl :

 require_relative 'common'

  api_key = IO.read('.themoviedb')
  source CSVSource, filename: 'movies.csv'      

  limit ENV['LIMIT']

  show_me!

 transform MovieDBlookup,
 api_key: api_key,
 title_field: 'title'

show_me!

common.rb


require 'csv'
 require 'awesome_print'

 class CSVSource 
    def initialize(filename:)   
    @filename = filename
        end

  def each
    csv = CSV.open(@filename, headers: true)
    csv.each do |row|
    yield(row.to_hash)

    end 

csv.close

    end
        end 

  require 'themoviedb'

class MovieDBlookup
 def initialize(api_key:, title_field:)
 @title_field = title_field
 Tmdb::Api.key(api_key)
    end

 def process(row)
 movie = Tmdb::Movie.find(row[@title_field]).first
 row[:vote_average] = movie.vote_average
 row[:vote_count] = movie.vote_count
 row
    end 
    end

def show_me!    
    transform do |row|
    ap row
    row
    end 
    end

def limit(x)
x = Integer(x || -1)
return if x == -1
   transform do |row|
   @counter ||= 0 
   @counter += 1
   abort("stopping....")if @counter >= x
   row
    end 
    end 

this is the error i am facing :

test01$ bundle exec kiba movies.etl
{
    "title: Blade Runner" => "title: Minority Report"
}
/home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/themoviedb-1.0.1/lib/themoviedb/api.rb:37:in `set_response': Tmdb::InvalidApiKeyError (Tmdb::InvalidApiKeyError)
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/themoviedb-1.0.1/lib/themoviedb/search.rb:75:in `fetch_response'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/themoviedb-1.0.1/lib/themoviedb/search.rb:60:in `fetch'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/themoviedb-1.0.1/lib/themoviedb/resource.rb:41:in `search'
    from /home/bitlasoft/test01/common.rb:30:in `process'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/kiba-0.6.1/lib/kiba/runner.rb:35:in `block (3 levels) in process_rows'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/kiba-0.6.1/lib/kiba/runner.rb:34:in `each'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/kiba-0.6.1/lib/kiba/runner.rb:34:in `block (2 levels) in process_rows'
    from /home/bitlasoft/test01/common.rb:12:in `block in each'
    from /home/bitlasoft/.rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/csv.rb:1739:in `each'
    from /home/bitlasoft/test01/common.rb:11:in `each'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/kiba-0.6.1/lib/kiba/runner.rb:33:in `block in process_rows'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/kiba-0.6.1/lib/kiba/runner.rb:32:in `each'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/kiba-0.6.1/lib/kiba/runner.rb:32:in `process_rows'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/kiba-0.6.1/lib/kiba/runner.rb:13:in `run'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/kiba-0.6.1/lib/kiba/cli.rb:13:in `run'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/gems/kiba-0.6.1/bin/kiba:5:in `<top (required)>'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/bin/kiba:23:in `load'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/bin/kiba:23:in `<main>'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
    from /home/bitlasoft/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'
bitlasoft@Bitlasoft-TS-22:~/test01$ 
thbar commented 7 years ago

Hello! The answer is in the output you provided : Tmdb::InvalidApiKeyError. This I believe means that the API key you are providing is incorrect, or contains a typo etc.

Since this is unrelated to Kiba itself, I'll close that issue.

For upcoming questions, please follow the recommendation at the top of the README here and ask it on StackOverflow. Thanks!

attahkhan016 commented 7 years ago

But when i give the command $ bundle exec kiba movies.etl i am getting the error ... so do we have to configure anything related api keys and databases ?

thbar commented 7 years ago

Follow-up is here.