ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
readProgress.m
Go to the documentation of this file.
1%> \brief
2%> Return a list of objects of class [pm.sampling.FileContentsProgress](@ref FileContentsProgress)
3%> containing the content(s) of the ParaMonte simulation output progress
4%> file(s) whose path(s) match the specified input ``pattern`` or the
5%> simulation specification ``sampler.spec.outputFileName``.<br>
6%>
7%> \warning
8%> This method is to be only used for post-processing of the output
9%> progress file(s) of an already finished simulation. Although possible,
10%> this method is NOT meant to be called by all processes
11%> in MPI-parallel simulations.<br>
12%>
13%> \param[in] self : The input parent object of class [pm.sampling.Sampler](@ref Sampler)
14%> which is **implicitly** passed to this dynamic method (not by the user).<br>
15%> \param[in] pattern : The input scalar MATLAB string containing the pattern matching
16%> the desired progress file(s) whose contents is to be read.<br>
17%> The specified ``pattern`` only needs to partially identify
18%> the name of the simulation to which the progress file belongs.<br>
19%> For example, specifying ``"./mydir/mysim"`` as input will
20%> lead to a search for file(s) beginning with "mysim" and
21%> ending with ``"_progress.txt"`` inside the directory ``"./mydir/"``.<br>
22%> If there are multiple files matching in the input ``pattern``,
23%> then all such files will be read and returned as elements of a list.<br>
24%> If the specified pattern is a valid existing URL, the file will be
25%> downloaded as a temporary file to the local system, its contents
26%> shall be parsed and the file will be subsequently removed.<br>
27%> If the input ``pattern`` is empty, then the method will search
28%> for any possible candidate files with the appropriate suffix
29%> in the current working directory.<br>
30%> (optional, default = ``sampler.spec.outputFileName`` or ``"./"``)
31%> \param[in] sep : The input MATLAB string containing the field separator used in the file(s).<br>
32%> (optional, default = ``sampler.spec.outputSeparator`` or automatically inferred.)
33%>
34%> \return
35%> ``progressList`` : The output MATLAB cell array of objects
36%> of class [pm.sampling.FileContentsProgress](@ref FileContentsProgress),
37%> each of which corresponds to the contents
38%> of a unique progress file.<br>
39%>
40%> \interface{readProgress}
41%> \code{.m}
42%>
43%> sampler = pm.sampling.Sampler();
44%> progressList = sampler.readProgress();
45%> progressList = sampler.readProgress([]);
46%> progressList = sampler.readProgress([], []);
47%> progressList = sampler.readProgress(pattern);
48%> progressList = sampler.readProgress([], sep);
49%> progressList = sampler.readProgress(pattern, sep);
50%>
51%> \endcode
52%>
53%> \final{readProgress}
54%>
55%> \note
56%> See the documentation of the sampler subclasses
57%> (e.g., [pm.sampling.Paradram](@ref Paradram)) for example usage in action.<br>
58%>
59%> \example{readProgress}
60%> \code{.m}
61%>
62%> sampler.readProgress("./out/test_run_");
63%>
64%> sampler.spec.outputFileName = "./out/test_run_";
65%> sampler.readProgress();
66%>
67%> sampler.readProgress("./out/test_run_", ",");
68%>
69%> sampler.spec.outputSeparator = ",";
70%> sampler.readProgress("./out/test_run_");
71%>
72%> sampler.spec.outputFileName = "./out/test_run_";
73%> sampler.spec.outputSeparator = ",";
74%> sampler.readProgress();
75%>
76%> \endcode
77%>
78%> \final{readProgress}
79%>
80%> \author
81%> \JoshuaOsborne, May 21 2024, 12:25 AM, University of Texas at Arlington<br>
82%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
83%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
84function progressList = readProgress(self, pattern, sep)
85 if nargin < 3
86 if 0 < pm.array.len(self.spec.outputSeparator)
87 sep = string(self.spec.outputSeparator);
88 else
89 sep = [];
90 end
91 end
92 if nargin < 2
93 if 0 < pm.array.len(self.spec.outputFileName)
94 pattern = string(self.spec.outputFileName);
95 else
96 pattern = [];
97 end
98 end
99 ftype = "progress";
100 pathList = self.findfile(ftype, pattern);
101 progressList = cell(length(pathList), 1);
102 for ifile = length(pathList) : -1 : 1
103 if ~self.silent
104 disp("processing file: """ + pathList(ifile) + """");
105 end
106 progressList{ifile} = pm.sampling.FileContentsProgress(pathList(ifile), self.silent, sep);
107 end
108end
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared libraries.
function list()
Return a list of MATLAB strings containing the names of OS platforms supported by the ParaMonte MATLA...
This is the base class for generating objects that contain the contents of a progress file generated ...
This is the ParaDRAM class for generating instances of serial and parallel Delayed-Rejection Adaptive...
Definition: Paradram.m:14
This is the base class for the ParaMonte sampler routines.
Definition: Sampler.m:21
function parallel()
Return a scalar MATLAB logical that is true if and only if the current installation of MATLAB contain...
function which(in vendor)
Return the a MATLAB string containing the path to the first mpiexec executable binary found in system...