-
Notifications
You must be signed in to change notification settings - Fork 5
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
Graphviz issue 233 #251
base: main
Are you sure you want to change the base?
Graphviz issue 233 #251
Conversation
Awesome @chbe-helix and @FraserP117! Thanks! We will start testing after IWAI! |
Amazing work, also will have more time after IWAI |
I reviewed some of the code. There seems to be something wrong with the extension loading; I cannot access the structures from the extension when I load GPPL. I'll push a commit refactoring the code a bit, but let's discuss @bvdmitri and @FraserP117 how we can elegantly solve this. We should be able to come up with smth now that we're all in Oxford anyway. Dummy visualizations I was able to cook up look 1000 times nicer than what the current viz looks like though! Thanks guys! Also on a side note, do you mind renaming the file/module to Once again, thanks for the work guys! |
No problem at all, let’s work on this some time while we’re all here.
Yes, rename it to whatever you want, I’m easy and I think I speak for Chris
and Kobus here also.
Thanks!
…On Mon, 9 Sep 2024 at 11:47 AM, Wouter Nuijten ***@***.***> wrote:
I reviewed some of the code. There seems to be something wrong with the
extension loading; I cannot access the structures from the extension when I
load GPPL. I'll push a commit refactoring the code a bit, but let's discuss
@bvdmitri <https://github.com/bvdmitri> and @FraserP117
<https://github.com/FraserP117> how we can elegantly solve this. We
should be able to come up with smth now that we're all in Oxford anyway.
Dummy visualizations I was able to cook up look 1000 times nicer than what
the current viz looks like though! Thanks guys!
Also on a side note, do you mind renaming the file/module to
GraphPPLGraphVizExt? This way, should Julia ever change their extension
functionality and expose them, it's clear that this is an extension and to
what package it belongs.
Once again, thanks for the work guys!
—
Reply to this email directly, view it on GitHub
<#251 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKMKRHMYYRQXJ7L753FMV2TZVV4DDAVCNFSM6AAAAABNXWRDFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZXG43TMNZVGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
ext/GraphvizVisualization.jl
Outdated
|
||
These types afford a trade-off between a relatively fast and a relatively 'principled' iteration strategy (respectfully). | ||
""" | ||
abstract type TraversalStrategy end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type should be available when we load GraphPPL and GraphViz, I don't really see a quick fix for this but I'm sure we can find something out
ext/GraphvizVisualization.jl
Outdated
""" | ||
abstract type TraversalStrategy end | ||
struct SimpleIteration <: TraversalStrategy end | ||
struct BFSTraversal <: TraversalStrategy end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW I really like this strategy type dispatch so I really want to keep this, great work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it too, but since we cannot access them from the extension maybe just use Symbol
s instead, e.g. :simple_iteration
and :bfs_traversal
(which can be converted to their corresponding structures if necessary and yes it will be type-unstable but this is not performance critical code and the type-instability will be negligible )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. something similar to
convert_symbol_strategy_to_struct(::Val{:simple_iteration}) = SimpleIteration()
convert_symbol_strategy_to_struct(::Val{:bfs_traversal}) = BFSTraversal()
function plot(; strategy = :simple_iteration)
strategy_struct = convert_symbol_strategy_to_struct(Val(strategy))
...
end
I'm think Plots use similar design too
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #251 +/- ##
=======================================
Coverage 90.61% 90.61%
=======================================
Files 15 15
Lines 2121 2121
=======================================
Hits 1922 1922
Misses 199 199 ☔ View full report in Codecov by Sentry. |
Sure! I'll make the update now |
…L.jl into graphviz_issue_233
Yes, because it is not possible by design of the extensions. Newly defined structures are local to the extensions and cannot be accessed from outside (without nasty hacks that can be broken in the next versions of Julia). Extensions can only add methods to the existing names using existing names but cannot define new names for the outside world.
maybe something like |
Interesting. Thanks @bvdmitri and @wouterwln. @chbe-helix, Kobus and I will be meeting this week to discuss/address this. Apologies for the delay on my part. I think @bvdmitri's suggestion of a "Symbol" substitution is probably best for now. I do like the type dispatching and I'd like to have it in the long run. On that, it seems - from your comments - that these types would have to be defined in base GraphPPL.jl (outside of the extension). Is that correct? I will do some investigating now. |
… exclusive to the extension.
…olic' into graphviz_issue_233
Greetings @bvdmitri and all, I'd just like to ask a few clarifications and to indicate our direction. Thanks again @bvdmitri, for your comments regarding suggested improvements. The first of these was "Do not use Regarding node naming, yes we will be revising the way we do this to make sure they don't get too big and unwieldy. We'll ultimately have a way to modulate their "verbosity". I will have a look at default layouts now and perhaps just implement Once these issues have been addressed - and if there are no more issues to address - we think that this will conclude Phase 1 and we will begin implementing Phase 2 (an as, yet under-specified phase). We have several plans but we think FFG notation might be the go for Phase 2, in addition to more verbosity modulation options like node naming and plate notation. Thanks! |
Ah, thats completely normal @FraserP117 that you aren't familiar with Julia extension system. The problem with Instead of writing include("../ext/GraphPPLGraphVizExt.jl") # Include your module
using .GraphPPLGraphVizExt: generate_dot, show_gv, dot_string_to_pdf, SimpleIteration, BFSTraversal
# ...
gppl_model = RxInfer.getmodel(rxi_model)
# ...
gen_dot_result = generate_dot(model_graph = gppl_model; kwargs...) The using GraphViz
gen_dot_result = GraphViz.load(RxInfer.getmodel(rxi_model)) # also looks much nicer and less code In order to achieve this you should implement a new method in the import GraphViz: load
function GraphViz.load(gppl_model::GraphPPL.Model; kwargs...)
# here is the code that uses `generate_dot` internally without need to expose it outside
return generate_dot(model_graph = gppl_model; kwargs...)
end This is the correct way of implementing extensions in Julia. Let me know if you have any further issues with this, but it should certainly work. |
Thank you @bvdmitri. That makes a lot more sense to me now and I see what you mean. I have made a new branch "graphviz_issue_233_node_naming", intended to settle the initial convention for node naming. At the moment, it only hosts my attempt to overload I appear to be missing something - again, my ignorance with Julia is letting me down here - Julia is not recognising my overloaded version of Many thanks, talk soon. Fraser |
GraphViz Beta Update Pull Request.
Update includes all code developed to visualize the core factor graph data structure of GraphPPL. This PR resolved issue 233.
We need feedback on the version number and implementation before this is merged. During this time we will run a few additional tests to assure compatibility with GraphPPL v4.3.3.