Asymptote generation

16 views
Skip to first unread message

Mark Fitch

unread,
Apr 11, 2023, 1:53:38 PM4/11/23
to pretext...@googlegroups.com
The error below occurs on account of a rather longer bit of Asymptote
code (also below). I am wondering if there is a timeout on account of it
being so long. Note the code works just fine (tested at
http://asymptote.ualberta.ca/ and generated locally). For the moment I
am generating that one html/pdf file manually, but it would be nice to
not have to do that every time I need to compile the entire document.
The resulting image is at:
http://www.math.uaa.alaska.edu/~afmaf/classes/math253/text/section-surface-vector-integrals.html

$ pretext build -g asymptote web
PreTeXt project found in `D:\Documents\texts\calculus3`.
warning: Generating only asymptote assets.
Now generating asymptote images


converting Asymptote diagrams from
D:\Documents\texts\calculus3\source\calculus3.ptx to HTML graphics for
placement in D:/Documents/texts/calculus3/generated-assets/asymptote
with method "server"
extracting Asymptote diagrams from
D:\Documents\texts\calculus3\source\calculus3.ptx
string parameters passed to extraction stylesheet: {'publisher':
'D:/Documents/texts/calculus3/publication/publication.ptx'}
XSL conversion of D:\Documents\texts\calculus3\source\calculus3.ptx by
C:\Users\drmaf\.ptx\xsl\extract-asymptote.xsl
comprehensive messages, warnings, and errors:
successful application of C:\Users\drmaf\.ptx\xsl\extract-asymptote.xsl
converting
C:\Users\drmaf\AppData\Local\Temp\tmpxr91ktbo\image-cartesian-cylindrical.asy
to
C:\Users\drmaf\AppData\Local\Temp\tmpxr91ktbo\image-cartesian-cylindrical.html
error: HTTPConnectionPool(host='asymptote.ualberta.ca', port=10007): Max
retries exceeded with url: /?f=html (Caused by
NewConnectionError('<urllib3.connection.HTTPConnection object at
0x00000124644897F0>: Failed to establish a new connection: [WinError
10061] No connection could be made because the target machine actively
refused it'))
##################
error: Failed to generate some asymptote elements. Check your source and
partial output to diagnose the issue.
warning: Continuing...
Removing temporary directory C:\Users\drmaf\AppData\Local\Temp\tmpxr91ktbo
Traceback (most recent call last):
  File "C:\bin\Anaconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\bin\Anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\bin\Anaconda3\Scripts\pretext.exe\__main__.py", line 7, in
<module>
  File "C:\bin\Anaconda3\lib\site-packages\click\core.py", line 1128,
in __call__
    return self.main(*args, **kwargs)
  File "C:\bin\Anaconda3\lib\site-packages\click\core.py", line 1053,
in main
    rv = self.invoke(ctx)
  File "C:\bin\Anaconda3\lib\site-packages\click\core.py", line 1659,
in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\bin\Anaconda3\lib\site-packages\click\core.py", line 1395,
in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\bin\Anaconda3\lib\site-packages\click\core.py", line 754, in
invoke
    return __callback(*args, **kwargs)
  File "C:\bin\Anaconda3\lib\site-packages\pretext\cli.py", line 398,
in build
    project.generate(target.name(), asset_list=[generate])
  File "C:\bin\Anaconda3\lib\site-packages\pretext\project.py", line
447, in generate
    core.release_temporary_directories()
  File "C:\bin\Anaconda3\lib\site-packages\pretext\core\pretext.py",
line 3896, in release_temporary_directories
    shutil.rmtree(td, ignore_errors=False)
  File "C:\bin\Anaconda3\lib\shutil.py", line 748, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\bin\Anaconda3\lib\shutil.py", line 630, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "C:\bin\Anaconda3\lib\shutil.py", line 628, in _rmtree_unsafe
    os.rmdir(path)
PermissionError: [WinError 32] The process cannot access the file
because it is being used by another process:
'C:\\Users\\drmaf\\AppData\\Local\\Temp\\tmpxr91ktbo'
While running pretext, the following errors occurred:

error: HTTPConnectionPool(host='asymptote.ualberta.ca', port=10007): Max
retries exceeded with url: /?f=html (Caused by
NewConnectionError('<urllib3.connection.HTTPConnection object at
0x00000124644897F0>: Failed to establish a new connection: [WinError
10061] No connection could be made because the target machine actively
refused it'))
error: Failed to generate some asymptote elements. Check your source and
partial output to diagnose the issue.

----------------------------------------------------
----------------------------------------------------
    <figure xml:id="figure-vector-surface-integral">
        <caption>Vector field passing through various surfaces</caption>
        <image xml:id="image-vector-surface-integral">
            <description>Vectors field passing through one hemisphere,
one half hemisphere and a plane</description>
            <asymptote>
                import graph3;
                import three;
                size(10cm);
                currentprojection = orthographic(5,5,5);

                path3 myarc = Arc(c=O,normal=X, v1=-Z, v2=Z, n=10);
                surface greenHemisphere = surface(myarc,
angle1=90,angle2=270, c=O, axis=Z, n=10);
                surface blueHemisphere = surface(myarc,
angle1=90,angle2=270, c=O, axis=Z, n=10);
                draw(scale(3,3,3)*greenHemisphere,
surfacepen=material(green+opacity(0.5),
                emissivepen=0.1*white), meshpen=gray(0.4));
                draw(scale(3,3,3)*shift(2Y)*blueHemisphere,
surfacepen=material(blue+opacity(0.5),
                emissivepen=0.1*white), meshpen=gray(0.4));
draw(shift((-3.76,-3.76,4))*scale(7.52,7.52,1)*unitplane,
surfacepen=red+opacity(0.5));

                path3 gradient1(triple z){
                  return O--(z.x/10,z.y/10,z.z/10);
                }

                triple A=(-4,-4,-4);
                triple B=(4,4,4);

                picture VectorPlot3D(path3 vector(triple t), triple a,
triple b,
                                     int nx=nmesh, int ny=nx, int
nz=nx, bool truesize=false,
                                     real maxlength=truesize ? 0 :
min(abs(b.x-a.x)/nx,abs(b.y-a.y)/ny,abs(b.z-a.z)/nz),
                                     pen p=currentpen,
                                     arrowbar3 arrow=Arrow3, margin3
margin=PenMargin3,
                                     string name="", render
render=defaultrender)
                {
                  picture pic;
                  real dx=1/nx;
                  real dy=1/ny;
                  real dz=1/nz;
                  real scale;
                  if(maxlength > 0) {
                    real size(triple t) {
                      path3 g=vector(t);
                      return abs(point(g,size(g)-1)-point(g,0));
                    }
                    real max=size((0,0,0));

                    for(int i=0; i &lt;= nx; ++i) {
                      real x=interp(a.x,b.x,i*dx);
                      for(int j=0; j &lt;= ny; ++j)
                        {
                          real y=interp(a.y,b.y,j*dy);
                          for(int k=0; k &lt;= nz; ++k)
max=max(max,size((x,y,interp(a.z,b.z,k*dz))));
                        }}
                    scale=max > 0 ? maxlength/max : 1;
                  } else scale=1;
                  bool group=name != "" || render.defaultnames;
                  if(group)
                    begingroup3(pic,name == "" ? "vectorfield" :
name,render);
                  for(int i=0; i &lt;= nx; ++i) {
                    real x=interp(a.x,b.x,i*dx);
                    for(int j=0; j &lt;= ny; ++j) {
                      real y=interp(a.y,b.y,j*dy);
                      for(int k=0; k &lt;= nz; ++k)
                        {      triple z=(x,y,interp(a.z,b.z,k*dz));
                          {
                            path3 g=scale3(scale)*vector(z);
                            string name="vector";
                            if(truesize) {
                              picture opic;
draw(opic,g,p,arrow,margin,name,render);
                              add(pic,opic,z);
                            } else
draw(pic,shift(z)*g,p,arrow,margin,name,render);
                          }
                        }
                    }}
                  if(group)
                    endgroup3(pic);
                  return pic;

                }
                add(VectorPlot3D(gradient1,A,B,10,p=grey));
xaxis3(Label("x",MidPoint),Bounds(Both,Both),InTicks(Step=1));
yaxis3(Label("y",MidPoint),Bounds(Both,Both),InTicks(Step=1));
zaxis3(Label("z",MidPoint),Bounds(Both,Both),InTicks(Step=1));
            </asymptote>
        </image>
    </figure>

Dr. Mark A. Fitch
Professor of Mathematics
Chair, Associate of Arts

maf...@alaska.edu
907-786-1656
SSB 154
University of Alaska Anchorage
3211 Providence Drive, Anchorage, AK 99508

Rob Beezer

unread,
Apr 11, 2023, 2:07:07 PM4/11/23
to pretext...@googlegroups.com
Dear Mark,

There's a tread on -dev, just started recently, that appears to be the same
error/complaint. You might want to participate in that to see what sort of
resolution is enacted.

Rob

Sean Fitzpatrick

unread,
Apr 11, 2023, 3:12:54 PM4/11/23
to pretext...@googlegroups.com
I've just emailed the person who maintains the remote server to see if we should expect to regain access.
I've also asked the CLI team if they're willing to support local compilation of Asymptote figures. (The version of Asymptote that ships with TeXLive 2022 should be sufficient to build everything PreTeXt uses.)

--
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/MTAwMDA0Mi5iZWV6ZXI.1681236424%40quikprotect.

Sean Fitzpatrick

unread,
Apr 11, 2023, 5:26:13 PM4/11/23
to pretext...@googlegroups.com
Try again now.
I contacted the person who maintains the server and he tracked down what he thinks was the problem. (A Python library went missing during an OS upgrade.)

Reply all
Reply to author
Forward
0 new messages