dwavesystems / dwave-optimization

Enables the formulation of nonlinear models for industrial optimization problems.
https://docs.ocean.dwavesys.com/en/stable/docs_optimization/index.html#index-optimization
Apache License 2.0
7 stars 17 forks source link

Model.to_networkx() example uses local path to figure #64

Closed JoelPasvolsky closed 2 months ago

JoelPasvolsky commented 2 months ago

The /_images/to_networkx_example.svg path here works for local builds but not for the SDK build, where it is translated to dwave-ocean-sdk/docs/_build/html/docs_optimization/reference/generated/_images/to_networkx_example.svg and not found.

I've tried a few alternatives but so far haven't a good solution. Depending on when there's a new SDK release we might need to remove this or move it to the intro.

arcondello commented 2 months ago

symbolic link to the image in the SDK's _images/ maybe? Another option would be "hosting" the image somewhere (even just in this issue) and linking it from the docs. Both ugly for sure.

JoelPasvolsky commented 2 months ago

Yes, I was looking at symbolic links and considering putting the image in the SDK with the normal path so it would only build there (and give an error for local builds)

arcondello commented 2 months ago

Ah, we can also reference it with a URL like https://github.com/dwavesystems/dwave-optimization/blob/main/docs/_images/to_networkx_example.svg. Obviously makes updating a pain but :shrug:

randomir commented 2 months ago

I would avoid "hotlinking" to github. Symlink seems the way to go.

JoelPasvolsky commented 2 months ago

Perhaps there's a different syntax but directly using the URL creates a link that you have to open to see the image image

randomir commented 2 months ago

You'd need to link to the raw image: https://raw.githubusercontent.com/dwavesystems/dwave-optimization/main/docs/_images/to_networkx_example.svg, but that's frowned upon.

JoelPasvolsky commented 2 months ago

Looks like it's actually enough to have the image itself under sdk _images for the absolute path (which is currently used in dwave-optimization) to work. I should have tried that first.

I suggest adding that image as part of this PR and making a PR in dwave-optimization to replace the current image with an image that gives the new location so in the future the right one is updated

arcondello commented 2 months ago

replace the current image with an image that gives the new location so in the future the right one is updated

I don't understand what you mean by this

JoelPasvolsky commented 2 months ago

Local build of dwave-optimization: image

SDK build: image

arcondello commented 2 months ago

I would prefer to keep the image locally and use a symbolic link in the SDK rather than have the local doc builds not work.

Also, keeping the image in this git history is preferable so we can make updates over time without needing to also change the SDK.

JoelPasvolsky commented 2 months ago

Okay, for some reason the first time I built that it failed with an error WARNING: cannot copy static file FileExistsError(17, 'File exists') but after cleaning old generated files a second build works nicely.

This commit closes this issue.