-
-
Notifications
You must be signed in to change notification settings - Fork 77
Update the Rserve interface. #1213
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
base: develop
Are you sure you want to change the base?
Conversation
The instructions on the wiki (https://webwork.maa.org/wiki/R_in_WeBWorK#Transferring_files_from_the_R_server) will need to be updated to match. |
Note that the instructions on the wiki will still work as is. Although it would be good to add examples of using the new method. There are examples in the POD that are quite complete. |
I don't think there are any Rserve sample problems at this point. |
4f237a4
to
a62c8d7
Compare
I removed the |
34bade4
to
4f0470c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and it works as described.
In case anyone is up for extensive testing of this, here are two set definition files. The first contains all OPL problems that use the |
When I tested, I just tested the two sample problems in the wiki. I looked closely at the file names (for the image and csv). |
Yeah, that is really enough. The problems in the OPL and Contrib don't do anything different really. But if you want to test extensively, then you can try the set definitions I just posted. |
b7f1491
to
0240cc0
Compare
The primary change in this pull request is how the `rserve_get_file` method in the `RserveClient.pl` macro works. Previously it accepted a second optional local filename parameter. That parameter is no longer honored. If it is given it is ignored. I don't think that there are any problems in the OPL or Contrib that pass that argument, but even if they do it will still work. The filename just won't be the chosen one. The filename should not be a problem author choice. Furthermore, previously the method fell back to using the Rserve remote filename. That is also no longer used. Instead, the `getUniqueName` method is used that creates a filename that is dependent on the problem seed, psvn, problem UUID, etc. That means that the filename will not change each time that the problem is loaded. Unfortunately, the file is still downloaded every time the problem is loaded and overwrites the existing file (with the same contents), and that can't really be fixed without a major revision of the Rserve setup. Note that all changes in this pull request are backwards compatible, and all existing problems will continue to function correctly. However, the courses html temporary directory will no longer be filled with files that are only used once before another copy of the file is created by another name the next time the problem is rendered (due to a preview, answer submission, etc.). In addition there are two new methods added that are more convenient than the previous methods for generating R images or csv files. Those are the `rserve_data_url` and `rserve_plot` methods. These handle the details of creating these things in a much nicer way. See the added POD and examples in the POD for the usage and comparison to the old approaches. The macro code and POD are also rather heavily clean up. The `Rserve.pm` module is also cleaned up. The `_inherits` method is removed from the `Rserve.pm` module, because contrary to the comments the `inherits` method of the `$rserve` object does work in the safe compartment, and so the `_inherits` method is not needed. There are a couple of other related changes. First, the `htmlLink` method now has a new calling convention for adding additional attributes to the generated `a` tag. Previously these were added by passing a single string argument. For example, `htmlLink($url, 'dataset', 'download="dataset.csv"')`. That will still work, but passing the attributes in that way should be considered deprecated. Instead the attributes should be passed as additional attribute/value pairs after the url and link text. For example, `htmlLink($url, 'dataset', download => 'dataset.csv')`. Of course, this is useful for Rserve csv files to specify the filename that will be offered when the user clicks to download a csv file. Particularly since the default will now be something like `ed721060-00b2-37fb-87c4-e3eb36c7ced2___5643740d-c34f-37c8-afc5-c2369fec26e1.csv`. Previously it would have been something like `file1231asdfasdf.csv`. The new alias is worse, but that wasn't good either.
The primary change in this pull request is how the
rserve_get_file
method in theRserveClient.pl
macro works. Previously it accepted a second optional local filename parameter. That parameter is no longer honored. If it is given it is ignored. I don't think that there are any problems in the OPL or Contrib that pass that argument, but even if they do it will still work. The filename just won't be the chosen one. The filename should not be a problem author choice. Furthermore, previously the method fell back to using the Rserve remote filename. That is also no longer used. Instead, thegetUniqueName
method is used that creates a filename that is dependent on the problem seed, psvn, problem UUID, etc. That means that the filename will not change each time that the problem is loaded. Unfortunately, the file is still downloaded every time the problem is loaded and overwrites the existing file (with the same contents), and that can't really be fixed without a major revision of the Rserve setup.Note that all changes in this pull request are backwards compatible, and all existing problems will continue to function correctly. However, the courses html temporary directory will no longer be filled with files that are only used once before another copy of the file is created by another name the next time the problem is rendered (due to a preview, answer submission, etc.).
In addition there are two new methods added that are more convenient than the previous methods for generating R images or csv files. Those are the
rserve_data_url
andrserve_plot
methods. These handle the details of creating these things in a much nicer way. See the added POD and examples in the POD for the usage and comparison to the old approaches.The macro code and POD are also rather heavily clean up. The
Rserve.pm
module is also cleaned up. The_inherits
method is removed from theRserve.pm
module, because contrary to the comments theinherits
method of the$rserve
object does work in the safe compartment, and so the_inherits
method is not needed.There is one other related change. The
htmlLink
method now has a new calling convention for adding additional attributes to the generateda
tag. Previously these were added by passing a single string argument. For example,htmlLink($url, 'dataset', 'download="dataset.csv"')
. That will still work, but passing the attributes in that way should be considered deprecated. Instead the attributes should be passed as additional attribute/value pairs after the url and link text. For example,htmlLink($url, 'dataset', download => 'dataset.csv')
. Of course, this is useful for Rserve csv files to specify the filename that will be offered when the user clicks to download a csv file. Particularly since the default will now be something likeed721060-00b2-37fb-87c4-e3eb36c7ced2___5643740d-c34f-37c8-afc5-c2369fec26e1.csv
. Previously it would have been something likefile1231asdfasdf.csv
. The new alias is worse, but that wasn't good either.