AE
Ash Elixir•2y ago
WIGGLES

custom step inside of map step in a flow.

It appears that the DSL is not setup to handle nested custom steps. When trying to use a custom step inside of a parent map step, I get a undefined function custom/3 (there is no such import) error.
8 Replies
WIGGLES
WIGGLESOP•2y ago
The weird thing is I believe this worked until I updated Ash today.
defmodule Butsby.Scheduler.Invoke do
use Ash.Flow

alias Butsby.Scheduler
alias Scheduler.Job

flow do
api Scheduler
returns :run_jobs
end

steps do
read :get_jobs, Job, :invokable

map :run_jobs, result(:get_jobs) do
output :invoke_job

custom :invoke_job, &invoke_job/2 do
input %{
job: element(:run_jobs)
}
end
end
end

defp invoke_job(%{job: job} = input, context) do
flow = Ash.Flow.run!(job.flow, job.input)
{:ok, flow.result}
end
end
defmodule Butsby.Scheduler.Invoke do
use Ash.Flow

alias Butsby.Scheduler
alias Scheduler.Job

flow do
api Scheduler
returns :run_jobs
end

steps do
read :get_jobs, Job, :invokable

map :run_jobs, result(:get_jobs) do
output :invoke_job

custom :invoke_job, &invoke_job/2 do
input %{
job: element(:run_jobs)
}
end
end
end

defp invoke_job(%{job: job} = input, context) do
flow = Ash.Flow.run!(job.flow, job.input)
{:ok, flow.result}
end
end
== Compilation error in file lib/butsby/scheduler/invoke.ex ==
** (CompileError) lib/butsby/scheduler/invoke.ex:18: undefined function custom/3 (there is no such import)
(ash 2.10.2) expanding macro: Ash.Flow.Dsl.Steps.Map.map/3
== Compilation error in file lib/butsby/scheduler/invoke.ex ==
** (CompileError) lib/butsby/scheduler/invoke.ex:18: undefined function custom/3 (there is no such import)
(ash 2.10.2) expanding macro: Ash.Flow.Dsl.Steps.Map.map/3
Putting the custom step at the root will let it compile, but I think this is a bug.
ZachDaniel
ZachDaniel•2y ago
Can you try main of ash and spark as well? actually what version of ash are you on? Can you try the new release candidate?
WIGGLES
WIGGLESOP•2y ago
I'm on 2.10 is the RC on hex?
ZachDaniel
ZachDaniel•2y ago
should be
WIGGLES
WIGGLESOP•2y ago
or will I have to get it from teh github branch
ZachDaniel
ZachDaniel•2y ago
Yeah, it is 2.11.0-rc.1 So make sure to try latest version of spark and the ash release candidate maybe a version dependency is wrong somewhere there
WIGGLES
WIGGLESOP•2y ago
Yeah that did it.
ZachDaniel
ZachDaniel•2y ago
🥳 if you're okay with being on an RC (its really just an RC because of field policies, I'll probably fully release it soon)

Did you find this page helpful?