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

Graphviz issue 233 #251

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Graphviz issue 233 #251

wants to merge 15 commits into from

Conversation

chbe-helix
Copy link

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.

@albertpod
Copy link
Member

Awesome @chbe-helix and @FraserP117! Thanks! We will start testing after IWAI!

@bvdmitri
Copy link
Member

bvdmitri commented Sep 6, 2024

Amazing work, also will have more time after IWAI

@wouterwln
Copy link
Member

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 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!

@FraserP117
Copy link

FraserP117 commented Sep 9, 2024 via email


These types afford a trade-off between a relatively fast and a relatively 'principled' iteration strategy (respectfully).
"""
abstract type TraversalStrategy end
Copy link
Member

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

"""
abstract type TraversalStrategy end
struct SimpleIteration <: TraversalStrategy end
struct BFSTraversal <: TraversalStrategy end
Copy link
Member

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

Copy link
Member

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 Symbols 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 )

Copy link
Member

@bvdmitri bvdmitri Sep 18, 2024

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

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.61%. Comparing base (c97718a) to head (e49dcb5).

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.
📢 Have feedback on the report? Share it here.

@chbe-helix
Copy link
Author

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 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!

Sure! I'll make the update now

@bvdmitri
Copy link
Member

There seems to be something wrong with the extension loading; I cannot access the structures from the extension when I load GPPL.

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.

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

maybe something like plot(..., strategy = :simple) and plot(..., strategy = :bfs). Symbol can be converted to TraversalStrategy and const-propagation should make it type-stable and even if its not its shouldn't be a big issue since this code is not performance critical and most of the time will be spent in the plotting anyway.

@FraserP117
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants