Unrecognized function or variable when using `str2func` in Docker container

5 次查看(过去 30 天)
Hello. Inside a Docker container, I am attempting to run .m matlab files that are remotely pulled from a git repository so that a remote code can be changed continously without needed redeployment of a containerized instance of Matlab Production Server. Since addpath is not supported by the Matlab runtime, I created the following function to the run the pulled fnuctions that cannot be added the the path:
function [varargout] = evaluate_function_out_of_path(function_name, function_file_path, options)
arguments
function_name string
function_file_path string
options.function_inputs cell = {}
end
function_handle = str2func(function_name);
current_directory = cd;
cd(function_file_path);
[varargout{1:nargout}] = function_handle(options.function_inputs{:});
cd(current_directory);
end
While I am able to run evaluate_function_out_of_path locally without issue on pulled code not added to the search path, I am receving the following error when ran on a deployed Docker container:
Unrecognized function or variable 'my_function'
The code that I am pulling is not compiled. What I am worried about is that the pulled source code must be compiled first before it can be used during runtime. Is this assumption right? Oddly enough, I am able to run built in functions with str2func inside the container without any kind of compilation such as:
str2func("@() disp('hello world')")
Let me know if you need clarification; I'll edit the question accordingly. Thanks in advance!
  8 个评论
Chandler
Chandler 2024-4-11
After fiddling with the Matlab container, I couldn't think of a way to serve an http server to run matlab remotely. While creating and deploying something like a node express server to serve http requests or even port forward the container, building a maltab microservice is the cleanest way so far. Is there no way to run ephemeral matlab code in Matlab Production Server?
Nicole Bonfatti
Nicole Bonfatti 2024-4-12
Hi Chandler,
I'm the product manager for MATLAB Production Server and I'd be interested in hearing more about your use case for uncompiled code behind MATLAB Production Server, but I also wanted to address something I noticed in your OP:
You shouldn't need to redeploy your MATLAB Production Server container when you make changes to your deployed code. Provided you've packaged an updated deployable archive (CTF file) you should be able to map a volume into the container and replace the existing deployable archive in that volume without redeploying (or even restarting) the container itself.
Cheers,
Nicole

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 C Shared Library Integration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by