Skip to content
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

remove references to external programs in favor of packages #2172

Merged
merged 12 commits into from
Feb 7, 2024

Conversation

pstaabp
Copy link
Member

@pstaabp pstaabp commented Aug 11, 2023

This removes the use of the programs mv, cp, rm, mkdir, tar, gzip (some were no longer used). Instead, use functions in perl modules.

This should be tested on a few different platforms. Especially

  1. Hardcopy generation
  2. Course Archiving
  3. Course Unarchiving
  4. Add new course

@pstaabp pstaabp force-pushed the remove-ext-programs branch 2 times, most recently from 6a56ba8 to d2cd200 Compare August 20, 2023 20:52
@pstaabp pstaabp marked this pull request as ready for review August 20, 2023 20:52
@pstaabp
Copy link
Member Author

pstaabp commented Aug 20, 2023

This is ready for review. Switched to Archive::Zip::SimpleZip like #2163 and improved the creation of tar balls to not use chdir.

Definitely needs some testing in the area listed above.

@Alex-Jordan
Copy link
Contributor

Is it relevant that I see a direct use of mkdir in lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm?

@pstaabp
Copy link
Member Author

pstaabp commented Aug 28, 2023

Is it relevant that I see a direct use of mkdir in lib/WeBWorK/ContentGenerator/Instructor/FileManager.pm?

That's the perl mkdir. https://perldoc.perl.org/functions/mkdir

@drgrice1
Copy link
Member

This pull request has merge conflicts that need to be resolved.

@pstaabp pstaabp force-pushed the remove-ext-programs branch from 64c5a3d to 46242bc Compare October 16, 2023 20:06
Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't testing things yet, but I see some things that need to be fixed in the code.

bin/check_modules.pl Show resolved Hide resolved
conf/site.conf.dist Show resolved Hide resolved
lib/HardcopyRenderedProblem.pm Outdated Show resolved Hide resolved
lib/WeBWorK/ContentGenerator/Hardcopy.pm Outdated Show resolved Hide resolved
lib/WeBWorK/ContentGenerator/Hardcopy.pm Outdated Show resolved Hide resolved
lib/WeBWorK/ContentGenerator/Hardcopy.pm Outdated Show resolved Hide resolved
lib/WeBWorK/ContentGenerator/Hardcopy.pm Outdated Show resolved Hide resolved
lib/WeBWorK/Utils/CourseManagement.pm Outdated Show resolved Hide resolved
lib/WeBWorK/Utils/CourseManagement.pm Outdated Show resolved Hide resolved
lib/WeBWorK/Utils/CourseManagement.pm Outdated Show resolved Hide resolved
@pstaabp pstaabp force-pushed the remove-ext-programs branch from 46242bc to 69a09ff Compare October 24, 2023 10:49
@pstaabp
Copy link
Member Author

pstaabp commented Oct 31, 2023

@drgrice1 Just made updates.

@pstaabp pstaabp force-pushed the remove-ext-programs branch from ef111d4 to fb3f690 Compare October 31, 2023 16:24
Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still some things that aren't right.

Also, I don't really think it is worth introducing the Archive::Extract module when the Archive::Tar module covers this and is a core module.

bin/download-OPL-metadata-release.pl Outdated Show resolved Hide resolved
lib/HardcopyRenderedProblem.pm Outdated Show resolved Hide resolved
lib/HardcopyRenderedProblem.pm Outdated Show resolved Hide resolved
lib/WeBWorK/ContentGenerator/Hardcopy.pm Outdated Show resolved Hide resolved
lib/WeBWorK/Utils/CourseManagement.pm Outdated Show resolved Hide resolved
lib/WeBWorK/Utils/CourseManagement.pm Show resolved Hide resolved
@pstaabp pstaabp force-pushed the remove-ext-programs branch 3 times, most recently from 2166fe6 to 6f15637 Compare November 10, 2023 18:41
@pstaabp
Copy link
Member Author

pstaabp commented Nov 10, 2023

@drgrice1 Fixed these. I've noticed in HardCopy and HardcopyRenderedProblem.pm there are a bunch of file IO that could benefit from using Mojo::File. I've left these as is for now.

@drgrice1
Copy link
Member

@pstaabp: Have you tested your latest changes?

@pstaabp pstaabp force-pushed the remove-ext-programs branch from 6f15637 to 7f3cf8f Compare November 20, 2023 20:03
@pstaabp
Copy link
Member Author

pstaabp commented Nov 20, 2023

I had tested the course admin features and didn't test the hardcopy creation. Fixed the error.

@pstaabp pstaabp force-pushed the remove-ext-programs branch 2 times, most recently from 87748e4 to abc058e Compare November 20, 2023 20:04
@pstaabp pstaabp force-pushed the remove-ext-programs branch from abc058e to 51abfd5 Compare December 3, 2023 14:59
@pstaabp
Copy link
Member Author

pstaabp commented Dec 4, 2023

@drgrice1 and others, when you get a chance, this is ready to be looked at and tested gain.

Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, just revert to using Archive::Zip in HardcopyRenderedProblem.pm and Hardcopy.pm. Here are the justifications for this request:

  • Archive::Zip is already NOT using a reference to an external program, and so this change does not fit into this pull request as titled.
  • Archive::Zip is still needed because Archive::Zip::SimpleZip can not do archive extraction.
  • Archive::Zip has a nicer API than Archive::Zip::SimpleZip. Look at how much more code it took to implement the same thing in HardcopyRenderedProblem.pm and Hardcopy.pm with Archive::Zip::SimpleZip than with Archive::Zip.
  • Quite frankly we wouldn't be using Archive::Zip::SimpleZip at all if it weren't for the bug in Archive::Zip with adding symbolic links to zip archives. The zip files created in these two modules don't have symbolic links, so that is irrelevant here.

In fact, please revert all changes to HardcopyRenderedProblem.pm in this pull request. Other than switching from Archive::Zip to Archive::Zip::SimpleZip, you change several cases where the Mojo::File::path method was called into Mojo::File->new calls. You do realize that the path call is just a shorthand for Mojo::File->new don't you? The definition of the path method in Mojo::File is sub path { __PACKAGE__->new(@_) }. The path method could also be imported and used in the CourseManagement.pm file. Do NOT do this in Hardcopy.pm (or any module that derives from ContentGenerator.pm), because that module has another path method that will conflict if the path method is imported from Mojo::File.

conf/site.conf.dist Outdated Show resolved Hide resolved
@pstaabp pstaabp force-pushed the remove-ext-programs branch from 51abfd5 to 62ddf67 Compare January 4, 2024 15:57
@pstaabp
Copy link
Member Author

pstaabp commented Jan 4, 2024

reverted to Archive::Zip in Hardcopy.pm and HardcopyRenderedProblem.pm.

@pstaabp pstaabp force-pushed the remove-ext-programs branch from 62ddf67 to a0ccbc6 Compare January 4, 2024 17:05
@drgrice1
Copy link
Member

drgrice1 commented Jan 9, 2024

In fact, please revert all changes to HardcopyRenderedProblem.pm in this pull request. Other than switching from Archive::Zip to Archive::Zip::SimpleZip, you change several cases where the Mojo::File::path method was called into Mojo::File->new calls. You do realize that the path call is just a shorthand for Mojo::File->new don't you? The definition of the path method in Mojo::File is sub path { __PACKAGE__->new(@_) }. The path method could also be imported and used in the CourseManagement.pm file. Do NOT do this in Hardcopy.pm (or any module that derives from ContentGenerator.pm), because that module has another path method that will conflict if the path method is imported from Mojo::File.

This has still not been addressed.

@pstaabp pstaabp force-pushed the remove-ext-programs branch from a0ccbc6 to e851dda Compare January 10, 2024 19:01
Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor issues to be fixed, and then this is ready to go.

lib/HardcopyRenderedProblem.pm Outdated Show resolved Hide resolved
lib/WeBWorK/Utils/CourseManagement.pm Outdated Show resolved Hide resolved
lib/WeBWorK/Utils/CourseManagement.pm Outdated Show resolved Hide resolved
lib/WeBWorK/ContentGenerator/Hardcopy.pm Outdated Show resolved Hide resolved
@pstaabp pstaabp force-pushed the remove-ext-programs branch from 87c3428 to 130ba37 Compare January 25, 2024 11:07
Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that you added the usage of the module File::Copy::Recursive, but did not add it to the check_modules.pl script. Make sure to add that.

@pstaabp
Copy link
Member Author

pstaabp commented Feb 6, 2024

Good catch. Updated.

@drgrice1 drgrice1 merged commit 41fac6d into openwebwork:develop Feb 7, 2024
1 check passed
mkdir $courseDir
or warn
"Failed to create $courseDirName directory '$courseDir': $!. You will have to create this directory manually.\n";
eval { Mojo::File($courseDir)->make_path };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an error? Should be Mojo::File->new?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so and if someone confirms how I should fix it, I can fix it in #2290.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that should be eval { Mojo::File->new($courseDir)->make_path };. Good catch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, less of a catch though than just debugging when testing #2290.

drgrice1 added a commit to drgrice1/webwork2 that referenced this pull request Feb 22, 2024
The dependence on File::Copy::Recursive module was added in openwebwork#2172, but
not added to the docker build.

Start using node 20 in the docker build.  The node 16 install script
from nodesource is deprecated, and they have imposed a 60 second install
delay when you use it.

Fix the ownership on the courses directory and admin course directory
when the docker entrypoint runs.  Fixing the ownership on the courses
directory will not cause any slow down to the execution of that script.
It is not a recursive ownership change, just a single directory
ownership change which is super fast.
drgrice1 added a commit to drgrice1/webwork2 that referenced this pull request Feb 22, 2024
The dependence on File::Copy::Recursive module was added in openwebwork#2172, but
not added to the docker build.

Start using node 20 in the docker build.  The node 16 install script
from nodesource is deprecated, and they have imposed a 60 second install
delay when you use it.

Fix the ownership on the courses directory and admin course directory
when the docker entrypoint runs.  Fixing the ownership on the courses
directory and admin course directory will not cause any slow down to the
execution of that script.  It is not a recursive ownership change, just
two directories for which ownership is changed which is super fast.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants