Rake tasks in the AI plugin not working

I apologize in advance if this is the wrong place for this question about the AI plugin rake tasks.

I can run rake tasks (without bundle exec) in the Discourse app container no problem, but the AI tasks don’t work. Without bundle exec, the AI embedding backfill fails due to a missing ruby-progressbar. With bundle exec it fails due to not having a database connection.

Any pointers on how to fix this?

I got it working by going into the container and doing:

bundle install --with migrations

The problem is that the rake task rake ai:embeddings:backfill does this:

  Parallel.each(topics.all, in_processes: args[:concurrency].to_i, progress: "Topics") do |t|
    ActiveRecord::Base.connection_pool.with_connection do
      vector_rep.generate_representation_from(t)
    end
  end

which needs to have ruby-progressbar loaded, but it is ignored because its in the Gemfile migrations group.

2 Likes

@Roman_Rizzi / @Falco should we stop using progress bar here?

2 Likes

FWIW, my experience of the progress bar was so positive that I’d happily do that bundle install again if I ever need to repeat the backfill. The progress bar provided a highly accurate estimate (in my case, 49 minutes for six years of discussion). I really didn’t know what to expect… it was a mental/emotional relief to see that the long process (that I had never done before) was working.

3 Likes