-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load in models into context in Decapodes Creation Mode (#25)
* Checkpoint some compose work * Add full func * Load in models * Handle decapodes compile message again * Cleanup the code a bit * Write to intermediate file * Write and unwrap graphviz * Updates to kernel to better handle subrequests * Remove SVG and unused context * Fix weird conflicts --------- Co-authored-by: Matthew Printz <[email protected]>
- Loading branch information
1 parent
b6b3425
commit 7ff0beb
Showing
9 changed files
with
56 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
using SyntacticModels, Decapodes, Catlab | ||
import JSON3, DisplayAs | ||
|
||
{{ var_name|default("_expr") }} = Decapodes.parse_decapode(quote | ||
{{ target }} = @decapode begin | ||
{{ declaration }} | ||
end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
using SyntacticModels, Decapodes, Catlab | ||
import JSON3, DisplayAs | ||
|
||
function expr_to_svg(expr) | ||
io = IOBuffer() | ||
Catlab.Graphics.Graphviz.run_graphviz(io, to_graphviz(Decapodes.SummationDecapode(expr)), format="svg") | ||
String(take!(io)) | ||
function expr_to_svg(model) | ||
_path = "/tmp/decapode.json" | ||
open(_path, "w") do f | ||
io = IOBuffer() | ||
Catlab.Graphics.Graphviz.run_graphviz(io, to_graphviz(model), format="svg") | ||
end | ||
open(_path, "r") do f | ||
return String(take!(f)) | ||
end | ||
end | ||
|
||
_response = Dict( | ||
"application/json" => {{ var_name|default("_expr") }}, | ||
"image/svg" => expr_to_svg({{ var_name|default("_expr") }}) | ||
"application/json" => generate_json_acset({{ target }}), | ||
# "image/svg" => expr_to_svg({{ target }}) # TODO: Reinclude when graphviz bug is fixed | ||
) | ||
|
||
|
||
|
||
_response |> DisplayAs.unlimited ∘ JSON3.write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.