tjchambers

tjchambers

I am trying to bridge Elixir and Python, and am getting a failure in testing.

   ** (RuntimeError) unknown worker: agr.__main__.AgrWorker
     code: Oban.Testing.with_testing_mode(:inline, fn ->
     stacktrace:
       (oban 2.21.1) lib/oban/queue/executor.ex:109: Oban.Queue.Executor.resolve_worker/1
       (oban 2.21.1) lib/oban/queue/executor.ex:74: Oban.Queue.Executor.call/1
       (oban 2.21.1) lib/oban/engines/inline.ex:104: Oban.Engines.Inline.execute_job/2
       (oban 2.21.1) lib/oban/engines/inline.ex:37: Oban.Engines.Inline.insert_job/3
       (oban 2.21.1) lib/oban/engine.ex:216: anonymous fn/4 in Oban.Engine.insert_job/3
       (oban 2.21.1) lib/oban/engine.ex:404: anonymous fn/3 in Oban.Engine.with_span/4

As far as I can tell using code I have deduced my Python worker is “_main_.AgrWorker" however no matter what I put in as a worker name, I get an error in finding the worker on the elixir side when I run my tests. I am running my test inline for a worker (an Elixir module). This elixir module enqueues a job which is for a Python class “AgrWorker”. It “seems” like what is happening is that because the test is “inline” on th Elixir side, the subsequent enqueue expects any subsequent Oban Job to also be in Elixir - i.e. it is looking for the Elixir worker to run.

I am not sure how or why it would be able to know about all of the Python Workers available.

Can anyone help me with why this makes any sense?

Showing Posts 1 to 2

kokolegorille

kokolegorille

If You don’t mind I have switched the OP section from Question to Oban.

sorentwo

sorentwo

Oban Core Team

That’s correct. The inline engine runs jobs immediately, as they are inserted, and it never touches the database. In that case the job is referencing a Python class that’s not available as an Elixir module, and there’s no worker module to load and run.

It wouldn’t. In fact, Oban in Elixir isn’t aware that Oban in Python exists at all. They speak the same “language” via the database schema and pubsub (Bridging Elixir and Python with Oban · Oban Pro), but they can’t interchangeably execute code.

You’ll need to use manual mode to test enqueuing Python jobs, and ensure they’re inserted into a queue that isn’t ran by your Elixir app. Something like this:

# config/test.exs
config :my_app, Oban,
  queues: [
    default: 10, # runs in elixir
  ],
  testing: :manual,
  ...

# some_test.exs

args
|> Oban.Job.new(queue: :bridge, worker: "_main_.AgrWorker")
|> Oban.insert!()

# Assert that it's enqueued, don't run it
assert_enqueued queue: :bridge, worker: "_main_.AgrWorker"

The jobs won’t execute during tests, but you can be sure they’re in the bridge queue.

Note that Ecto tests run in a sandbox, essentially a transaction, and whatever is inserted during a test is invisible to all other processes or connections. The only way to test end-to-end is without the sandbox enabled an with manual cleanup steps, which may be worth it eventually, but it’s not where I’d start.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews