Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some error message diagnostics #962

Merged
merged 3 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 "*

Check warning on line 162 in src/composition/learning_networks/nodes.jl

View check run for this annotation

Codecov / codecov/patch

src/composition/learning_networks/nodes.jl#L162

Added line #L162 was not covered by tests
"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
Loading