Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Make graphviz optional #27

Merged
merged 3 commits into from
Dec 14, 2021
Merged

Conversation

ivirshup
Copy link
Contributor

@ivirshup ivirshup commented Dec 6, 2021

Makes graphviz an optional dependency.

Fixes #26.

Additions

  • Helpful error message if graphviz isn't installed and the user tries to plot

Removals

  • Dependency on graphviz

Testing

Not really sure how to test this.

Surely there is a way to mock existence or non-existence of a package? Cursory googling did not reveal one.

Todos

  • Test maybe? If we can figure out how

Checklist

I'm not sure I can do all of these things:

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows the standards laid out in the TODO link to standards
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Python

  • python 3.6
  • python 3.7

@elijahbenizzy
Copy link
Collaborator

Looks good! Let's add a minor version bump for the library? Even though this technically could be backwards incompatible I think a minor version bump is fine -- its unlikely to break existing workflows. Also I think we can do the same with networkx -- it's only used in the same function.

@ivirshup
Copy link
Contributor Author

ivirshup commented Dec 8, 2021

Did both. Might be worth a helper function!

@skrawcz
Copy link
Collaborator

skrawcz commented Dec 8, 2021

First up, thanks for the PR.
Second, @ivirshup question, what's your motivation for this? I'm curious what you're trying to avoid.

Otherwise we need to think about the impact to documentation and onboarding; we're going from a single pip install step to multiple. Hence my curiosity as to what prompted the PR :)

@ivirshup
Copy link
Contributor Author

ivirshup commented Dec 8, 2021

what's your motivation for this? I'm curious what you're trying to avoid.

I was thinking about trying this out for computing some statistics on some single cell data (relevant library). Made me wonder whether this could even be a dependency, so I looked this packages dependencies.

we're going from a single pip install step to multiple. Hence my curiosity as to what prompted the PR

Oh, I would definitely recommend having a pip install "sf-hamilton[plotting]" option or something. Would also be nice to have these for installing the dev and test requirements.

@skrawcz
Copy link
Collaborator

skrawcz commented Dec 8, 2021

what's your motivation for this? I'm curious what you're trying to avoid.

I was thinking about trying this out for computing some statistics on some single cell data (relevant library). Made me wonder whether this could even be a dependency, so I looked this packages dependencies.

Yep -- but did you install hamilton and it didn't work? or you had a dependency conflict in your environment? or?

we're going from a single pip install step to multiple. Hence my curiosity as to what prompted the PR

Oh, I would definitely recommend having a pip install "sf-hamilton[plotting]" option or something. Would also be nice to have these for installing the dev and test requirements.

Yep -- I would perhaps name it sf-hamilton[visualization] but that doesn't seem unreasonable. I guess if we go that route, it's probably worthwhile doing #12 while we're at it? 🤔

@ivirshup
Copy link
Contributor Author

ivirshup commented Dec 8, 2021

Just wondered "could this be a dependency", opened an issue to check, and had this PR solicited #26 (comment)

it's probably worthwhile doing #12 while we're at it

Yeah, I would also highly recommend that. flit + as much of the pyproject.toml PEPs as possible is quite nice and clean. I've recently done this myself for scanpy and anndata, and it's just so much less janky.

I don't think that I should be the one doing that update though – since it's about reporting author metadata and license.

I could undo the version bump for now?

@skrawcz
Copy link
Collaborator

skrawcz commented Dec 9, 2021

Just wondered "could this be a dependency", opened an issue to check, and had this PR solicited #26 (comment)

🤦 sorry I missed that. Thanks for clarifying.

Yeah, I would also highly recommend that. flit + as much of the pyproject.toml PEPs as possible is quite nice and clean.
I've recently done this myself for scanpy and anndata, and it's just so much less janky.

I don't think that I should be the one doing that update though – since it's about reporting author metadata and license.

Fair enough 😄 .

I could undo the version bump for now?

Yeah I think removing the version bump would be useful; we haven't decided on a proper release process just yet. So let us convene internally and then let you know about when we'll merge this PR.

ivirshup and others added 2 commits December 11, 2021 21:53
To ensure a delightful user experience, this commit adds
to `extras_require` for graphviz and networkx. This will mean
that users will have to do pip install sf-hamilton[visualization]
to be able to get a DAG visualized.

Rather than doing a major version bump, we're doing a minor one;
this shouldn't break any body's core use, since they shouldn't be
visualizing the DAG in production each time.

Otherwise this updates the docs with this information.

Adjusts behavior when graphivz or networkx aren't present

Rather than causing an execute to fail, we'll instead log the
error and return early.

The message to the user should look something like:

```
ERROR:hamilton.graph: graphviz is required for visualizing the function graph. Install it with:

  pip install sf-hamilton[visualization] or pip install graphviz

Traceback (most recent call last):
  File "/Users/stefankrawczyk/temp/hamilton/hamilton/graph.py", line 142, in display
    import graphviz
ModuleNotFoundError: No module named 'graphviz'
```
@skrawcz
Copy link
Collaborator

skrawcz commented Dec 12, 2021

@ivirshup I went ahead and dropped your version bump, and tweaked the logic a little. Thanks for getting this started.

Otherwise @elijahbenizzy I tested the install locally via pip install -e . and pip install -e .[visualization].

@elijahbenizzy
Copy link
Collaborator

@skrawcz looks good to me! Only Q is if we want to wait to release a minor version until we get the transformer/node lifecycle changes out. But I think it's fine to release this, then do my change and release a different minor version.

@elijahbenizzy elijahbenizzy merged commit 6a19dc4 into stitchfix:main Dec 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Have graphviz be an optional dependency?
3 participants