mcoll
mcoll
AEAsh Elixir
Created by mcoll on 5/21/2025 in #support
AshOban job failures
I have a job that runs using AshOban, which I find a very nice way of doing things tbh, as most things you've done so far! However it seems to me that the only way to handle failures is to give it an action to run. For example setting the state to failed, however I'd like to be able to see the failure in Oban apart from setting the Resource as failed. I have scoured the documentation but I don't see a way of having the Oban job fail on failure. Am I missing something? Was there a specific reason this is like this?
28 replies
AEAsh Elixir
Created by mcoll on 5/19/2025 in #support
Ash.Type.Tuple Enumerable not implemented
I have an attribute of type :tuple defined like this:
attribute :model, :tuple do
constraints [
fields: [
alpha: [type: :float, description: "The alpha parameter for the beta model"],
beta: [type: :float, description: "The beta parameter for the beta model"],
t: [type: :float, description: "The half life of the fact in days"],
]
]
allow_nil? false
default fn -> Katarineko.Srs.default_model(1, nil, nil) end
end
attribute :model, :tuple do
constraints [
fields: [
alpha: [type: :float, description: "The alpha parameter for the beta model"],
beta: [type: :float, description: "The beta parameter for the beta model"],
t: [type: :float, description: "The half life of the fact in days"],
]
]
allow_nil? false
default fn -> Katarineko.Srs.default_model(1, nil, nil) end
end
When I create an instance of this model
fact = Katarineko.Learning.create_fact
fact = Katarineko.Learning.create_fact
I get this error
{:error,
%Ash.Error.Unknown{
bread_crumbs: ["Error returned from: Katarineko.Learning.Fact.create"],
changeset: "#Changeset<>",
errors: [
%Ash.Error.Unknown.UnknownError{
error: "** (Protocol.UndefinedError) protocol Enumerable not implemented for type Tuple\n\nGot value:\n\n {3.0, 3.0, 1.0}\n",
field: nil,
value: nil,
splode: Ash.Error,
bread_crumbs: ["Error returned from: Katarineko.Learning.Fact.create"],
vars: [],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :unknown
}
]
}}
{:error,
%Ash.Error.Unknown{
bread_crumbs: ["Error returned from: Katarineko.Learning.Fact.create"],
changeset: "#Changeset<>",
errors: [
%Ash.Error.Unknown.UnknownError{
error: "** (Protocol.UndefinedError) protocol Enumerable not implemented for type Tuple\n\nGot value:\n\n {3.0, 3.0, 1.0}\n",
field: nil,
value: nil,
splode: Ash.Error,
bread_crumbs: ["Error returned from: Katarineko.Learning.Fact.create"],
vars: [],
path: [],
stacktrace: #Splode.Stacktrace<>,
class: :unknown
}
]
}}
Is this expected? Am I doing something wrong?
107 replies
AEAsh Elixir
Created by mcoll on 5/16/2025 in #support
Complex Custom Actions
How do you usually model complex operations over a model? I have a model that needs to do some processing over their inputs, it handles everything related to subtitles, and after creation it goes over several stages of analysis of the context and such and I'm struggling to fit it inside of the Ash framework. I was thinking to model it in two ways: * Have an Oban job that contains that logic and operates over a :update or :analyzed action. * The problem in this case is that I cannot use AshOban to handle the scheduling, I'd need to do it manually * Implement a manual action using Ash.Resource.ManualUpdate, but in that case I'm a bit unsure how to handle everything, what are the best practices around ManualUpdate and what am I giving up in exchange. I still have a bit of trouble reasoning about that. * In that case do I need to deal with ecto directly? Or should I use other more generic actions as part of the manual action? Do you have an example of a ManualUpdate I could take a look at?
23 replies