Skip to content

Commit

Permalink
Merge pull request #962 from JuliaAI/diagnostics
Browse files Browse the repository at this point in the history
Fix some error message diagnostics
  • Loading branch information
ablaom authored Mar 15, 2024
2 parents b23bbd6 + 542d81f commit 44ca101
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MLJBase"
uuid = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
authors = ["Anthony D. Blaom <[email protected]>"]
version = "1.1.2"
version = "1.1.3"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand Down
20 changes: 13 additions & 7 deletions src/composition/learning_networks/nodes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,19 @@ function _apply(y_plus, input...; kwargs...)
try
(y.operation)(mach..., raw_args...)
catch exception
@error "Failed "*
"to apply the operation `$(y.operation)` to the machine "*
"$(y.machine), which receives it's data arguments from one or more "*
"nodes in a learning network. Possibly, one of these nodes "*
"is delivering data that is incompatible with the machine's model.\n"*
diagnostics(y, input...; kwargs...)
throw(exception)
diagnostics = MLJBase.diagnostics(y, input...; kwargs...) # defined in sources.jl
if !isempty(mach)
@error "Failed "*
"to apply the operation `$(y.operation)` to the machine "*
"$(y.machine), which receives it's data arguments from one or more "*
"nodes in a learning network. Possibly, one of these nodes "*
"is delivering data that is incompatible "*
"with the machine's model.\n"*diagnostics
else
@error "Failed "*
"to apply the operation `$(y.operation)`."*diagnostics
end
rethrow(exception)
end
end

Expand Down
25 changes: 16 additions & 9 deletions src/sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,21 @@ function diagnostics(X::AbstractNode, input...; kwargs...)
_sources = sources(X)
scitypes = scitype.(raw_args)
mach = X.machine
model = mach.model
_input = input_scitype(model)
_target = target_scitype(model)
_output = output_scitype(model)

table0 = if !isnothing(mach)
model = mach.model
_input = input_scitype(model)
_target = target_scitype(model)
_output = output_scitype(model)
"""
Model ($model):
input_scitype = $_input
target_scitype =$_target
output_scitype =$_output
"""
else
""
end

table1 = "Incoming data:\n"*
"arg of $(X.operation)\tscitype\n"*
Expand All @@ -97,11 +108,7 @@ function diagnostics(X::AbstractNode, input...; kwargs...)

table2 = diagnostic_table_sources(X)
return """
Model ($model):
input_scitype = $_input
target_scitype =$_target
output_scitype =$_output
$table0
$table1
$table2"""
end
Expand Down

0 comments on commit 44ca101

Please sign in to comment.