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

Support toolboxes in startup.m files #39

Open
agahkarakuzu opened this issue Jan 14, 2021 · 6 comments
Open

Support toolboxes in startup.m files #39

agahkarakuzu opened this issue Jan 14, 2021 · 6 comments

Comments

@agahkarakuzu
Copy link

agahkarakuzu commented Jan 14, 2021

I wanted to give Azure extension a try, but looks like some essential toolboxes are missing:

image

I thought only transformation products were excluded on Microsoft Hosted Agents. Is this also the case with all the toolboxes, or do I need an extra configuration step for, let say, optimization and image processing toolboxes.

Thanks!

Update:

I run ver and saw that all the toolboxes are available! The problem is then:

result = license('test','Optimization_Toolbox');

which I assume has to do with the license is issued. Unless there is not another option, I will set an environment variable to bypass these checks on Azure.

@agahkarakuzu
Copy link
Author

When I kept playing with the pipeline a bit more, I noticed that there is an unexpected behaviour:

In startup.m

L1 if isempty(getenv('ISAZURE')) || ~str2double(getenv('ISAZURE')) 
L2        ISAZURE=false; 
L3    else
L4        ISAZURE=true; 
L5 end
L6 disp(['Azure env is' getenv('ISAZURE')]);
L7 if ~ISAZURE
L8      if ~license('test', 'Optimization_Toolbox'), error('Optimization Toolbox is not installed on your system: most qMR models won''t fit. Please consider installing <a href="matlab:matlab.internal.language.introspective.showAddon(''OP'');">Optimization Toolbox</a> if you want to use qMRLab in MATLAB.'); end
L9      if ~license('test', 'Image_Toolbox'), warning('Image Toolbox is not installed: ROI Analysis tool not available in the GUI. Consider installing <a href="matlab:matlab.internal.language.introspective.showAddon(''IP'');">Image Processing Toolbox</a>'); end
L10 end

with the following Azure task:

jobs:
- job: Ubuntu_MATLAB
  pool:
    vmImage: 'Ubuntu-16.04'
  steps:
    - checkout: self
      fetchDepth: 1
    - task: InstallMATLAB@0
    - task: RunMATLABCommand@0
      displayName: Run qMRLab
      inputs:
        command: |
          setenv('ISAZURE','1');
          act = pwd;
          ls;
          startup;
          qMRLabVer;
          disp('Test Done');
          exit;

produces the following log:
image

Normally it should not have stepped into the logical statement at L7, given that I pass setenv('ISAZURE','1'); in the config. In addition, Azure env is was shown without the value of the set env variable, which is displayed properly later on.

The tasks from qMRLabVer on proceeds properly and can use toolboxes. Is there something wrong in the yaml task that tampers with the execution order?

@agahkarakuzu
Copy link
Author

Looks like I was not catching up with the latest MATLAB releases, and did not notice that shadowing from startup.m would be causing this issue. I changed the script name from startup to something else and the problem disappeared.

Sorry for the monologic issue :)

@mcafaro
Copy link
Member

mcafaro commented Jan 14, 2021

Hi @agahkarakuzu. Thanks for opening this issue!

Yes, you are right: Optimization Toolbox should be available and license('test','Optimization_Toolbox') should return 1.

However there is a funny way MATLAB is licensed for the CI services where the toolbox licenses are not be available until after startup.m executes. We are thinking about solutions for the use-case where you want to access or utilize toolboxes in startup.m, but in the current state toolbox licenses are not available until after startup.

@agahkarakuzu
Copy link
Author

Thank you @mcafaro! On another note re license management, Azure's Microsoft Hosted agents are generous enough to provide two virtual cores, which would be useful to run small tests for parallelized operations. However when I attempt `parpool(2):

Workers whose licenses are not managed online cannot use clusters whose MATLAB Parallel Server licenses are managed online. If possible, specify another cluster that uses
        the network license manager.

Is this something you may consider resolving in future releases?

@mcafaro
Copy link
Member

mcafaro commented Jan 19, 2021

Is this something you may consider resolving in future releases?

Certainly. Especially if more users request it, so it's great to hear your feedback.

@acampbel
Copy link
Member

Thank you @mcafaro! On another note re license management, Azure's Microsoft Hosted agents are generous enough to provide two virtual cores, which would be useful to run small tests for parallelized operations. However when I attempt `parpool(2):

Workers whose licenses are not managed online cannot use clusters whose MATLAB Parallel Server licenses are managed online. If possible, specify another cluster that uses
        the network license manager.

Is this something you may consider resolving in future releases?

Note this should work now with R2023a. Please let us know if you can get this particular aspect of your question working.

@acampbel acampbel changed the title Toolbox support Support toolboxes in startup.m files May 4, 2024
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

3 participants