script with compiler.b​uild.produ​ctionServe​rArchive returns success in MATLAB, Production Server Compiler App Test Client, but return failed using deployed archive in MPS

36 次查看(过去 30 天)
function [ret_createCTFFunctionbyMPSLib] = createCTFFunctionByMPSLib(mFile)
% % to create a ctf service that takes a mfile and convert to a ctf
% if exist(mFile, 'file') ~= 2
if ~exist('mFile', 'var') || isempty('mFile')
mFile = '.\data\mymagic.m';
end
if ~exist(mFile, 'file')
fprintf('Source %s does not exist\n', mFile);
ret_createCTFFunctionbyMPSLib = 'Source '+mFile+'does not exist\n';
return;
end
% Define the name of the output CTF
% archiveName = 'GeneratedCTF'; % Changed to GeneratedCTF
% Define the path to the function to be included
% functionFiles = 'mymagic.m'; % Add all required function files here
appFile = which('mymagic.m');
% Create options for the production server archive
% options = compiler.build.ProductionServerArchiveOptions;
% Set options (if needed)
% options.AdditionalFiles = {'C:\A2AM ProdSrvFunctionSignatures.json'}; % Include additional files as needed
% options.OutputDir = '.\output_liboption'; % Specify output directory
% options.UseCodeGeneration = true; % Enable code generation if required
% Create the production server archive
try
% Build the archive
compiler.build.productionServerArchive(appFile);
disp('CTF created successfully.');
ret_createCTFFunctionbyMPSLib = 'success'; % Set ret val to success
catch ME
disp('Error creating CTF:');
disp(ME.message);
ret_createCTFFunctionbyMPSLib = 'Failed'; % Set ret val to failed
end
end
  2 个评论
Biyan Li
Biyan Li 2024-10-17
On the user guide, it mentioned that we can use compiler.build.productionServerArchive to create ctf prgrammatically. However, I found out I would get the following warning if I start put options to this class. And here is the warning: "C:\Program Files\MATLAB\R2024a\toolbox\compiler_sdk\cli\build\+compiler\+build\ProductionServerArchiveOptions.m", "mps.internal.validateFunctionSignatures" are excluded from packaging for the MATLAB Runtime environment according to the MATLAB Compiler license.
Are the guide conflicts with what are allowed?

请先登录,再进行评论。

采纳的回答

Sivsankar
Sivsankar 2024-11-5,8:33
I believe that you are getting the warning:
"mps.internal.validateFunctionSignatures" are excluded from packaging for the MATLAB Runtime environment
according to the MATLAB Compiler license
is most probably because, the 'validateFunctionSignaturesJSON' does not support validating in MATLAB Production Server. You can learn more about this warning from the following MATLAB documentation:
While I deployed the script to MPS using deployed archive, I was getting the following warning:
"compiler.build.productionServerArchive" are excluded from packaging for the MATLAB Runtime environment
according to the MATLAB Compiler license. Either remove the file or function from your code, or use the
MATLAB function "isdeployed" to ensure the function is not invoked in the deployed component.
This basically means that ‘productionServerArchive’ function is not supported by MATLAB compiler. To resolve this, any function that is not supported by MATLAB Compiler should be used within "isdeployed" function. This ensures that the non-supported functions are only called when not running in deployed mode. You can reframe your script as follows:
if ~isdeployed
<function that is not supported by MATLAB compiler>
end
Leverage the following MATLAB documentations to understand more about the "isdeployed" function:
You can also refer the following MATLAB documentation to understand what all functions are not supported by MATLAB compiler:
Hope this helps!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Installation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by