-
Notifications
You must be signed in to change notification settings - Fork 206
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
initial progress toward local pg processing #2014
base: master
Are you sure you want to change the base?
Conversation
Looks like there is a typo in the usage instructions: I'm running this now against APEX. Update pending in 30 minutes or so. |
OK... container is up and running on the
|
|
I ran the Then I checked out your pull request and ran the Everything is from a terminal; I didn't shell into the docker container or anything like that. |
Sorry for the confusion. (omg, I think I've been talking to LLMs too much!) In order for the renderer to do its thing, it must be able to run locally on your machine -- the docker container is only accessible as a webservice, and this setup is built to avoid the overhead of making such requests. The renderer dockerfile lists the dependencies, which will need to be installed locally. If you are running Ubuntu, these packages can be installed just as they are listed in the dockerfile. Otherwise, you will need CPANMinus (recommended, but CPAN will also work) to install the packages that start with "lib" and end with "-perl". For example, installing |
OK! Took a little longer than planned to get all the packages installed and then kids came home from school. This time we got off to a good start -- first 6 problems built without a hitch. Then we ran into the first one using WeBWorK's TikZ support. This problem also has a table, and I'm seeing the warnings you mentioned (these are related to table alignment and styling that I think is supported in PreTeXt but not WeBWorK). Complaints about "bottom", "midrule", "align", and "valgin". But it's the image that breaks things. Error message:
Source code for the problem causing the error:
|
The warnings about tables shouldn't matter here.
…On June 27, 2023 9:52:22 PM PDT, Sean Fitzpatrick ***@***.***> wrote:
OK! Took a little longer than planned to get all the packages installed and then kids came home from school.
This time we got off to a good start -- first 6 problems built without a hitch. Then we ran into the first one using WeBWorK's TikZ support. This problem also has a table, and I'm seeing the warnings you mentioned (these are related to table alignment and styling that I think is supported in PreTeXt but not WeBWorK). Complaints about "bottom", "midrule", "align", and "valgin". But it's the image that breaks things.
Error message:
```
Traceback (most recent call last):
File "/home/sean/Documents/pretext/pretext/pretext", line 819, in <module>
main()
File "/home/sean/Documents/pretext/pretext/pretext", line 663, in main
ptx.webwork_to_xml(
File "/home/sean/Documents/pretext/pretext/pretext.py", line 1498, in webwork_to_xml
if ww_image_scheme:
^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'ww_image_scheme' where it is not associated with a value
```
Source code for the problem causing the error:
```
<exercise label="ex-limit-intro-numerical-graphical-1">
<webwork xml:id="ex-limit-intro-numerical-graphical-1">
<pg-code>
do {
$a = list_random(-1,1);
$b = non_zero_random(-5,5,1);
$c = non_zero_random(-5,5,1);
if ($envir{problemSeed} == 1){
($a,$b,$c) = (1,3,-5);
};
$f = Formula("x^2 + $b x + $c")->reduce;
$l = $f->eval(x => $a);
} until($l != 0);
@tabin = ($a - 0.1, $a - 0.01, $a - 0.001, $a + 0.001, $a + 0.01, $a + 0.1);
@tabOut = map{$f->eval(x => $_)} ***@***.***);
</pg-code>
<statement>
<p>
<m>\lim\limits_{x\to <var name="$a"/>}\left(<var name="$f"/>\right)</m>
</p>
<instruction>
If the limit does not exist, you may type <c>DNE</c>.
If you need to enter <m>\infty</m>, you may type <c>inf</c>.
</instruction>
<p>
<var name="$l" width="10"/>
</p>
</statement>
<solution>
<p>
For a numerical approximation, make a table:
</p>
<tabular>
<row bottom="medium">
<cell><m>x</m></cell>
<cell><m><var name="$f"/></m></cell>
</row>
<row>
<cell><m><var name="$tabin[0]"/></m></cell>
<cell><m><var name="$tabout[0]"/></m></cell>
</row>
<row>
<cell><m><var name="$tabin[1]"/></m></cell>
<cell><m><var name="$tabout[1]"/></m></cell>
</row>
<row>
<cell><m><var name="$tabin[2]"/></m></cell>
<cell><m><var name="$tabout[2]"/></m></cell>
</row>
<row>
<cell><m><var name="$tabin[3]"/></m></cell>
<cell><m><var name="$tabout[3]"/></m></cell>
</row>
<row>
<cell><m><var name="$tabin[4]"/></m></cell>
<cell><m><var name="$tabout[4]"/></m></cell>
</row>
<row>
<cell><m><var name="$tabin[5]"/></m></cell>
<cell><m><var name="$tabout[5]"/></m></cell>
</row>
</tabular>
<p>
For a graphical approximation:
</p>
<image>
<latex-image>
\begin{tikzpicture}
\begin{axis}[grid=both]
\addplot+[domain=-2:2] {$f};
\end{axis}
\end{tikzpicture}
</latex-image>
</image>
<p>
It appears that when <m>x</m> is close to <m><var name="$a"/></m>,
that <m><var name="$f"/></m> is close to <m><var name="$l"/></m>.
So <m>\lim_{x\to <var name="$a"/>}\left(<var name="$f"/>\right)=<var name="$l"/></m>.
</p>
</solution>
</webwork>
</exercise>
```
|
No, the table warnings aren't a concern. But the error when it hits the first TikZ image is. |
Thanks, @drdrew42 for this, and putting it out early. I'll rely a lot on having @Alex-Jordan take a good hard look. What if the |
Ultimately, I defer to how you want to implement-- I did this as proof of concept, and it was easiest to add a script parameter. Long term, my goal is to allow authors to select the renderer implementation for their activated WW problems, which makes sense in the publisher file. There is a difference, though, between the two features. Compiling the output from pretext source using this script is independent of the choice to use "webwork2" vs. "renderer" for activated problems. The pgscript option is entirely dependent on the machine that compiles the pretext, while the (not yet written) option for activated problems in production only depends on the presence of a renderer service at a specified URL. IMO, that makes pgscript less appropriate for a publisher file. Compiling a pretext book on another machine shouldn't require a change in the publisher file. PS - I have only spotty internet for another couple weeks. I'll be back on this case once I return. |
@drdrew42 Looking at this now and seeing how far I get today. A year later, there is one tiny conflict that should be easy for you to resolve on your branch with a rebase. |
I've caught up to where you left off here :) I can build representations for the sample chapter using a local renderer in 14 seconds, where it takes 33 seconds when I use the AIM WW server. Unless you object, I will start a new branch with your commits on it, clean some things up, and continue working toward rolling this out. |
Image files that the renderer produces are referenced in PG output as being at locations like:
I need to replace that @rbeezer, if I have the standalone PG renderer installed somewhere on my system, where is an appropriate place for me to tell Alternatively, @drdrew42 , can I get the renderer to just dump images directly into the And also for @drdrew42 , I have a more fundamental problem. The renderer does not seem to actually be creating image files and placing them in that Aside from these issues with images, the representations file from using the renderer is close enough (for now) to the one I get from using the AIM WW server. The differences that I see are attributable to the AIM WW server using PG 2.17, and the rendererer is using something more recent. Altern |
Yes, I think so - it sounds like another executable to me. A program of its own of to the side - not XSL, not even "called" by XSL. But I'm hoping @drdrew42 has a better idea about flexibility for specifying this location. |
It's two things. One is an executable that Drew's usage (at top of this thread) prescribes via the Maybe the executable should move to And I am hoping that somehow we can just tell the renderer a location to place image files in the first place, sidestepping the |
I'm on the road this weekend, but when I return, I will look into the possibility of what you've described. |
Create webwork-representations locally
This is still a work in progress. I am sharing it as a draft PR for visibility and feedback.
Prerequisites
Local install of Standalone PG Renderer
git submodule update
(pg dependency is updated on this branch)Place the attached ptx script into
script/
folder of the renderer. Rename it toptx
and make sure it is executable...Copy any WeBWorK macro dependencies (e.g.
WWSC.pl
) into theprivate/macros/
folder of the renderer.Usage
Run
pretext/pretext -c webwork --pgscript /absolute-path/to-renderer/script/ptx <other config + project files>
Status
Line 1100 of
pretext.py
requires an internet connection in order tosanitize_url
, I did bad things™️ in order to support fully offline use. This still needs to be resolved.Next Steps
Update publisher file to support problem rendering by the standalone renderer instead of webwork2