Error building <sageplot> images in codespaces

49 views
Skip to first unread message

ljmi...@hawaii.edu

unread,
Mar 1, 2023, 6:36:03 PM3/1/23
to PreTeXt support
I have an older fork of ADS that I have modified and am now in the process of updating it to the newest PreTeXt.

My problem is that the sageplot svg images are not generating. It has only made two svg files out of the several in the text. It seems like the .sage files are getting made but something happens when converting to svg.

I've tried compiling them in CoCalc and they're fine. I've looked at the newest ADS source and they look identical to what I've got.

 This is the error I get when I generate assets:

comprehensive messages, warnings, and errors:

successful application of /home/vscode/.ptx/xsl/extract-sageplot.xsl

converting graph-10-2-1.sage to graph-10-2-1.svg

converting minsets-2.sage to minsets-2.svg

error: [Errno 2] No such file or directory: 'minsets-2.svg'

I have several sageplots commented out but if I uncomment them, the very first one
that fails in ADS is sageplot-venn-complement1

Oscar Levin

unread,
Mar 1, 2023, 10:21:54 PM3/1/23
to pretext...@googlegroups.com
It is possible that codespaces is installing an outdated version of sage.  Could you try something like sage --version in the terminal and report your version?  I'll see if this is something we broke when switching to the quicker version of the codespaces setup.

--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-support/f7697a7c-d4d6-40e5-9c4c-8f9a8c52eba5n%40googlegroups.com.

ljmi...@hawaii.edu

unread,
Mar 2, 2023, 5:20:37 PM3/2/23
to PreTeXt support
Here's the result from my codespaces:
$ sage --version
SageMath version 9.2, Release Date: 2020-10-24

Steven Clontz

unread,
Mar 2, 2023, 6:19:52 PM3/2/23
to PreTeXt support
I can confirm that I had issues with latex-image when I did a demo on Monday. I'll try it again with a fresh project tomorrow (as well as SageMath).

Steven Clontz

unread,
Mar 3, 2023, 5:38:05 PM3/3/23
to PreTeXt support
We just created a sample book with just a latex-image and sageplot, and it works with our full Codespace build. https://github.com/StevenClontz/special-octo-spork

Since this is a Codespaces issue, if you share a link to your repo we can try it ourselves directly.

Steven Clontz

unread,
Mar 3, 2023, 9:39:43 PM3/3/23
to PreTeXt support
Well. Maybe strike that. 

Oscar, we're using two different images depending on if we're using a "full" or "lite" build.


I think the pretext-full image works, but not the other one.

Steven Clontz

unread,
Mar 5, 2023, 1:59:11 PM3/5/23
to PreTeXt support

ljmi...@hawaii.edu

unread,
Mar 5, 2023, 4:38:50 PM3/5/23
to PreTeXt support
Sorry for the slow reply, but if you still want to look at my repo here it is: https://github.com/ICSatKCC/DM4CS

Steven Clontz

unread,
Mar 8, 2023, 4:07:23 PM3/8/23
to PreTeXt support
I created a codespace for your project using the "default" settings, plus running the script on GenerateAssetsHelp.md to install sagemath, LaTeX, etc.

Result:

```
Now running `pretext generate -t web` ...
PreTeXt project found in `/workspaces/DM4CS`.

Generating all assets in default formats for the target "web".

Note: No webwork elements found.

Note: No latex-image elements found.

Note: No asymptote elements found.

Now generating sageplot images



converting Sage diagrams from /workspaces/DM4CS/source/main.ptx to HTML graphics for placement in /workspaces/DM4CS/generated-assets/sageplot

extracting Sage diagrams from /workspaces/DM4CS/source/main.ptx
XSL conversion of /workspaces/DM4CS/source/main.ptx by /home/codespace/.ptx/xsl/extract-sageplot.xsl

comprehensive messages, warnings, and errors:

    * PTX:ERROR: the @xml:id value "biblio-wilson-2013" should be unique, but is authored 2 times.

    *            Results will be unpredictable, and likely incorrect.  Information on the locations follows:

    *              located within: "biblio-wilson-2013" (xml:id), "Four Colors Suffice -
                How the Map Problem Was Solved" (title)

    *              located within: "biblio-wilson-2013" (xml:id), "Four Colors Suffice - How the Map Problem Was Solved" (title)

successful application of /home/codespace/.ptx/xsl/extract-sageplot.xsl

converting Sage diagrams from /workspaces/DM4CS/source/main.ptx to SVG graphics for placement in /workspaces/DM4CS/generated-assets/sageplot

extracting Sage diagrams from /workspaces/DM4CS/source/main.ptx

XSL conversion of /workspaces/DM4CS/source/main.ptx by /home/codespace/.ptx/xsl/extract-sageplot.xsl

comprehensive messages, warnings, and errors:

    * PTX:ERROR: the @xml:id value "biblio-wilson-2013" should be unique, but is authored 2 times.
    *            Results will be unpredictable, and likely incorrect.  Information on the locations follows:
    *              located within: "biblio-wilson-2013" (xml:id), "Four Colors Suffice -
                How the Map Problem Was Solved" (title)
    *              located within: "biblio-wilson-2013" (xml:id), "Four Colors Suffice - How the Map Problem Was Solved" (title)

successful application of /home/codespace/.ptx/xsl/extract-sageplot.xsl

converting sageplot-venn-symmetric.sage to sageplot-venn-symmetric.svg

error: [Errno 2] No such file or directory: 'sageplot-venn-symmetric.svg'

##################
error: Failed to generate some sageplot elements.  Check your source and partial output to diagnose the issue.
warning: Continuing...

Note: No interactive elements found.

Note: No video@youtube elements found.

Note: No program elements using codelens found.

Note: No elements needing QR codes found

While running pretext, the following errors occured:


[31merror: [0m[Errno 2] No such file or directory: 'sageplot-venn-symmetric.svg'
[31merror: [0mFailed to generate some sageplot elements.  Check your source and partial output to diagnose the issue.

Exception ignored in atexit callback: <function exit_command at 0x7f48b266b5b0>
Traceback (most recent call last):
  File "/usr/local/python/3.10.4/lib/python3.10/site-packages/pretext/utils.py", line 480, in exit_command

    sys.exit(1)
SystemExit: 1

...PreTeXt command finished.
```



As for the double xref warning, I fixed that error locally and still got the sageplot error (which I figured was unrelated but wanted to do my due dilegence).

Oscar and I just chatted and think this is completely on our end, so we may have a new PreTeXt version out later today that should fix things. I'll update when that's done.

ljmi...@hawaii.edu

unread,
Mar 8, 2023, 6:40:04 PM3/8/23
to PreTeXt support
That is exactly what was going on when I tried to build the assets. I had a suspicion that it was the sage plots that had less than signs &lt; in them, but I'm not positive.

Thank you!

Steven Clontz

unread,
Mar 8, 2023, 7:35:19 PM3/8/23
to PreTeXt support
&lt; is correct; it replaces < because < starts a tag in XML.

Steven Clontz

unread,
Mar 8, 2023, 8:03:42 PM3/8/23
to pretext...@googlegroups.com
Okay, first things first. I recommend accepting this Pull Request:


Once you do, you can destroy your Codespace and recreate it to get a clean install of PreTeXt 1.5.0 (just released). (If you do, you'll lose any uncommitted changes.)


On the other hand, there are definitely mistakes in your SageMath code as well. See for example:


At some point the Python code indentation was messed up. :-/ So you'll need to find the original code or fix things back.


I hope that helps!

You received this message because you are subscribed to a topic in the Google Groups "PreTeXt support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-support/b-8ytsnFGV0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-suppo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-support/2d12b8de-98b2-41ff-851d-285b6146ad9fn%40googlegroups.com.

ljmi...@hawaii.edu

unread,
Mar 9, 2023, 6:01:08 PM3/9/23
to PreTeXt support
Thank you! I'm slowly getting them fixed and built now.

The reason they are full of errors is that I got all excited when I realized Codespaces would fix all the xml indentation and used the "format document" tool on every file before realizing that it ruins the indentation of the SageMath Python parts.

Steven Clontz

unread,
Mar 9, 2023, 7:14:15 PM3/9/23
to pretext...@googlegroups.com
This is good incentive to adopt a practice suggested below to maintain your code outside XML via XInclude.

Steven Clontz

unread,
Mar 9, 2023, 7:15:54 PM3/9/23
to pretext...@googlegroups.com
See also discussion here: https://groups.google.com/g/pretext-support/c/43tDAXTjESU/m/0kJBlkw_AQAJ?pli=1

If you want any help starting that process, let me know!

ljmi...@hawaii.edu

unread,
Mar 9, 2023, 10:06:59 PM3/9/23
to PreTeXt support
Oh, that would be most excellent! I tried it but can't figure out the syntax

I've tried:
<sageplot>
<input><xi:include parse="text" href="./sage_venn-intersection.txt" /></input>
</sageplot>
And the same without <input> tags but no luck.

Rob Beezer

unread,
Mar 9, 2023, 10:17:50 PM3/9/23
to pretext...@googlegroups.com
On 3/9/23 19:06, ljmi...@hawaii.edu wrote:
> Oh, that would be most excellent!

Or some immediate help from a closer time zone?

> I tried it but can't figure out the syntax

Looks right/close to me.

* An underscore *and* a hyphen in your filename. Is that right?

* I think the @href is relative to the location of the file with the
"xi:include". Is the file in the right place? Experiment putting it different
places?

* The file with the "xi:include" needs to define the namespace alias "xi",
typically at the top of the file. You should get a good error message if that
is not right.

Rob

>
> I've tried:
> <sageplot>
> <input><xi:includeparse="text"href="./sage_venn-intersection.txt"/></input>
> </sageplot>
> And the same without <input> tags but no luck.
> On Thursday, March 9, 2023 at 2:15:54 PM UTC-10 steven...@gmail.com wrote:
>
> See also discussion here:
> https://groups.google.com/g/pretext-support/c/43tDAXTjESU/m/0kJBlkw_AQAJ?pli=1 <https://groups.google.com/g/pretext-support/c/43tDAXTjESU/m/0kJBlkw_AQAJ?pli=1>
> https://clontz.org <https://clontz.org> - steven...@gmail.com
> https://github.com/PreTeXtBook/pretext-codespace/issues/4 <https://github.com/PreTeXtBook/pretext-codespace/issues/4>
>
> On Friday, March 3, 2023 at 8:39:43 PM UTC-6
> Steven Clontz wrote:
>
> Well. Maybe strike that.
>
> Oscar, we're using two different images
> depending on if we're using a "full" or
> "lite" build.
>
> https://github.com/StevenClontz/special-octo-spork/blob/main/.devcontainer/pretext-full/devcontainer.json#L3 <https://github.com/StevenClontz/special-octo-spork/blob/main/.devcontainer/pretext-full/devcontainer.json#L3>
> https://github.com/StevenClontz/special-octo-spork/blob/main/.devcontainer/devcontainer.json#L6 <https://github.com/StevenClontz/special-octo-spork/blob/main/.devcontainer/devcontainer.json#L6>
>
> I think the pretext-full image works,
> but not the other one.
>
> On Friday, March 3, 2023 at 4:38:05 PM
> UTC-6 Steven Clontz wrote:
>
> We just created a sample book with
> just a latex-image and sageplot, and
> it works with our full Codespace
> build.
> https://github.com/StevenClontz/special-octo-spork <https://github.com/StevenClontz/special-octo-spork>
> https://groups.google.com/d/msgid/pretext-support/f7697a7c-d4d6-40e5-9c4c-8f9a8c52eba5n%40googlegroups.com <https://groups.google.com/d/msgid/pretext-support/f7697a7c-d4d6-40e5-9c4c-8f9a8c52eba5n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
>
> You received this message because you are subscribed to a
> topic in the Google Groups "PreTeXt support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pretext-support/b-8ytsnFGV0/unsubscribe <https://groups.google.com/d/topic/pretext-support/b-8ytsnFGV0/unsubscribe>.
> To unsubscribe from this group and all its topics, send an
> email to pretext-suppo...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-support/2d12b8de-98b2-41ff-851d-285b6146ad9fn%40googlegroups.com <https://groups.google.com/d/msgid/pretext-support/2d12b8de-98b2-41ff-851d-285b6146ad9fn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to a topic in
> the Google Groups "PreTeXt support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pretext-support/b-8ytsnFGV0/unsubscribe <https://groups.google.com/d/topic/pretext-support/b-8ytsnFGV0/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to
> pretext-suppo...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-support/b73ca819-c1e9-4c87-b06f-da7cd6994d0an%40googlegroups.com <https://groups.google.com/d/msgid/pretext-support/b73ca819-c1e9-4c87-b06f-da7cd6994d0an%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com
> <mailto:pretext-suppo...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-support/2c9272e5-f12c-4788-b0eb-2e1ca23eff3bn%40googlegroups.com <https://groups.google.com/d/msgid/pretext-support/2c9272e5-f12c-4788-b0eb-2e1ca23eff3bn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Steven Clontz

unread,
Mar 10, 2023, 1:57:55 PM3/10/23
to PreTeXt support
Now I think the trouble is the code itself.


Because it's outside XML, your <s and >s cannot be XML escaped as &lt; or &gt;.

ljmi...@hawaii.edu

unread,
Mar 10, 2023, 3:24:04 PM3/10/23
to PreTeXt support
I think I am running into another issue with my Codespaces. I have fixed up all of the SageMath in the XML and can generate assets error-free. If I try to switch to any of the Sage in separate files using xi:include it doesn't work (even with < and > fixed and code checked in SageMathCell site)

While running pretext, the following errors occurred:

[31merror: [0m[Errno 2] No such file or directory: 'sageplot-venn-intersection.svg'
[31merror: [0mFailed to generate some sageplot elements. Check your source and partial output to diagnose the issue.

Exception ignored in atexit callback: <function exit_command at 0x7f191edf4b80>
Traceback (most recent call last):
File "/home/vscode/.local/lib/python3.11/site-packages/pretext/utils.py", line 481, in exit_command

sys.exit(1)

SystemExit: 1

This is the XML where the problem happens (with working but commented out Sage code):
<sageplot>
<input><xi:include parse="text" href="./sage_venn-intersection.py" /></input>
<!-- m=2
scale = 1.7
sx=3
sy=2
centers = [(cos(n*2*pi/m), sin(n*2*pi/m)) for n in range(m)]
clr = ['blue', 'blue', 'green']
G = Graphics()
r=lambda x,y:(x-centers[0][0])^2+(y-centers[0][1])^2 &lt; scale^2 and \
(x-centers[1][0])^2+(y-centers[1][1])^2 &lt; scale^2
G+=region_plot(r,(-sx,sx),(-sy,sy),plot_points=200,incol='lightblue',axes=False)
for i in range(m):
G += circle(centers[i], scale)
for i in range(m):
G += circle(centers[i], scale)
G+=line([[-sx,-sy],[sx,-sy],[sx,sy],[-sx,sy],[-sx,-sy]],rgbcolor=(0,0,0))
G+=text('B',centers[0],fontsize='x-large')
G+=text('A',centers[1],fontsize='x-large')
G -->
</sageplot>



Contents of sage_venn-intersection.py
//don't hate my file naming! LOL!!

m=2
scale = 1.7
sx=3
sy=2
centers = [(cos(n*2*pi/m), sin(n*2*pi/m)) for n in range(m)]
clr = ['blue', 'blue', 'green']
G = Graphics()
r=lambda x,y:(x-centers[0][0])^2+(y-centers[0][1])^2 < scale^2 and \
(x-centers[1][0])^2+(y-centers[1][1])^2 < scale^2
G+=region_plot(r,(-sx,sx),(-sy,sy),plot_points=200,incol='lightblue',axes=False)
for i in range(m):
G += circle(centers[i], scale)
for i in range(m):
G += circle(centers[i], scale)
G+=line([[-sx,-sy],[sx,-sy],[sx,sy],[-sx,sy],[-sx,-sy]],rgbcolor=(0,0,0))
G+=text('B',centers[0],fontsize='x-large')
G+=text('A',centers[1],fontsize='x-large')
G

ljmi...@hawaii.edu

unread,
Mar 10, 2023, 3:37:36 PM3/10/23
to PreTeXt support
I believe the location of the files at ./ is correct as I have all subsections of the entire book included from that location and they work fine.

Steven Clontz

unread,
Mar 10, 2023, 4:03:47 PM3/10/23
to PreTeXt support
It's super unclear from the error message, but `<input>` should be deleted. Just write

<sageplot><xi:include parse="text" href="./sage_venn-intersection.py" /></sageplot>

Lisa Miller

unread,
Mar 10, 2023, 4:15:52 PM3/10/23
to pretext...@googlegroups.com
YAY! It works!
/*************************************************
* Lisa J. Miller
* Assistant Professor in ICS, Math & Sciences Dept.
* Kapi'olani Community College.
* Email:  ljmi...@hawaii.edu
* Office: Koki'o 109C
* Office Phone: 808-734-9388
* STEM Program site: https://kccstem.com/
***************************************************/


Reply all
Reply to author
Forward
0 new messages