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

feat: add $meta$show_graph() #64

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

Conversation

etiennebacher
Copy link
Contributor

I think we talked before about whether we should include the options to print / save the graph using external packages. I don't remember the decision, but no problem to add / remove functionalities here.

@eitsupi
Copy link
Owner

eitsupi commented Jan 11, 2025

I think we talked before about whether we should include the options to print / save the graph using external packages. I don't remember the decision

Maybe pola-rs/r-polars#928 (comment)?

Related upstream issue: pola-rs/polars#20631

@etiennebacher
Copy link
Contributor Author

In the r-polars issue we decided to go with $to_dot() so that we don't have these extra Suggests, but this function is not exported in py-polars.

At the same time, if we keep $show_graph() then it's weird to not print a graph but only the dot syntax. In the end I think adding those 3 optional deps only matters for CI time.

@eitsupi
Copy link
Owner

eitsupi commented Jan 11, 2025

My concern is not the dependency but the API.
In other words, I don't want complex combinations of arguments to result in completely different types of output.

In my opinion, we should separate functions rather than controlling the type of output with arguments.
IIUC, this is known as the Unix philosophy.

Comment on lines +122 to +129

fn meta_tree_format(&self) -> Result<Sexp> {
self.compute_tree_format(false)
}

fn meta_show_graph(&self) -> Result<Sexp> {
self.compute_tree_format(true)
}
Copy link
Owner

@eitsupi eitsupi Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to add these functions; just call <expr>$compute_tree_format(<bool>) from the R side.

Comment on lines +203 to +205
#' Note that Graphviz must be installed to render the visualization (if not
#' already present, you can download it here:
#' `<https://graphviz.org/download>`_).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this explanation is incorrect; Graphviz is not required.

@etiennebacher
Copy link
Contributor Author

etiennebacher commented Jan 11, 2025

In my opinion, we should separate functions rather than controlling the type of output with arguments.

I'd agree if we were building our own API but here we're following an existing one that faces the same challenges. I think we could instead talk about this upstream, especially with the mermaid PR that adds an additional layer of complexity to the function in Python. Having .to_dot(), .to_mermaid() and .show_graph() without the raw_output args would make more sense IMO.

(I can add a comment on the mermaid PR if you agree with this suggestion)

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.

2 participants