mathworks / matlab-azure-devops-extension

Continuous Integration with MATLAB on Azure DevOps
https://marketplace.visualstudio.com/items?itemName=MathWorks.matlab-azure-devops-extension
Other
14 stars 5 forks source link

Support toolboxes in startup.m files #39

Open agahkarakuzu opened 3 years ago

agahkarakuzu commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 1 year ago

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.