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

MATLAB Path Management #127

Open
jared321 opened this issue Feb 27, 2024 · 4 comments
Open

MATLAB Path Management #127

jared321 opened this issue Feb 27, 2024 · 4 comments
Assignees

Comments

@jared321
Copy link
Collaborator

For a project that is using MATLAB POUNDERS presently, my callpounders.m sets the current working directory (CWD) to the location in which needed configuration files are stored and where I want results to be written. This is completely unrelated to where IBCDFO is installed.

However, this doesn't presently work because of the relative path in

if ~exist('hfun', 'var')
% Use least-squares hfun by default
addpath('../general_h_funs/');

which I believe looks for general_h_funs with respect to the CWD.

@jmlarson1 @mmenickelly @wildsm Can we assume that if someone is calling a specific pounders.m, then they should be using the general_h_funs in the same clone? If so, then how about using

[here_path, ~, ~] = fileparts(mfilename('fullpath'));
addpath(fullfile(here_path, 'general_h_funs'));
@jared321 jared321 self-assigned this Feb 27, 2024
@jared321
Copy link
Collaborator Author

jared321 commented Mar 1, 2024

It looks like users (or perhaps the person who writes something like callpounders) are expected to add the location of the correct minq to MATLAB's path. Based on your response to the above and the above technique for adding to the path, couldn't POUNDERS automatically add the correct minq to the path based on the final value of spsolver?

@jared321
Copy link
Collaborator Author

Some potentially useful info regarding addpath:

In light of this, is it acceptable for a tool like POUNDERS to blindly add general_h_funs or minq5 to the path automatically without seeing if they are already in the path or restoring the PATH upon termination? Is there a reasonable use case where someone might manipulate the PATH so that an alternate version of external dependencies are found?

jared321 added a commit that referenced this issue Apr 25, 2024
pounders.m and its tests often add folders to the MATLAB path but do so using
relative paths, which can influence from where you can call the code.  The
changes here adopt a different path strategy using paths relative to the file
that is adding to the path.  This is related to Issue #127.  A second goal is
to make it so that users don't have to add too many paths.

Confirmed that the full test suite can be run as detailed in its inline
documentation.  This includes creating an HTML coverage report.  Confirmed that
changes to the path made by tests are not present upon termination.  Ran each
single test individually with a clean MATLAB environment to confirm that they
run through with and only with the documented path requirements.  Confirmed
that they leave the path as found upon entry.
@jared321
Copy link
Collaborator Author

It looks like manifold_sampling_primal uses POUNDERS's checkinputss function, which necessitates adding pounders/m to the path.

Naively, I would believe that if I want to use one method, I shouldn't add another method to the MATLAB path unless there is an obvious dependence such as between POUNDERS and MINQ.

@jmlarson1 @mmenickelly
Would a better solution be to add a folder such as common/m to IBCDFO and locate checkinputss there? Copy or symlink checkinputss into manifold_sampling/m?

@jared321
Copy link
Collaborator Author

jared321 commented Apr 29, 2024

As part of working Issue #145, I have come across

  • a MATLAB feature called Projects, which appear to be analogous to virtual environments. In particular, you can install setup/teardown scripts that can setup/teardown the environment including the path.
  • a MATLAB feature called Toolboxes which community developers can setup. They appear to be analogous to Python packages.

These might ease path management and overcome some of the aforementioned technical difficulties.

Consensus is that for now we assume that MATLAB users are happy to work from a clone of the repo with the need for them to alter the path. In particular, there is no need to offer the MATLAB code as a potentially simpler, cleaner toolbox through FileExchange. The possibility of methods such as pounders.m silently altering their path at the global level as a side effect is not particularly troubling for a such a workflow.

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

No branches or pull requests

1 participant