copyFileToStore - Copy files from local file system to FileStore

  object - MATLAB ([original](https://in.mathworks.com/help/parallel-computing/parallel.filestore.copyfiletostore.html)) ([raw](?raw))

Main Content

Copy files from local file system to FileStore object

Since R2022a

Syntax

Description

copyFileToStore([store](#mw%5F8019748d-ac79-4400-9060-d9b3dc1e8225),[fileSet](#mw%5F56969204-b3a6-4d0d-b848-15809cef5c0f),[keySet](#mw%5F8bbb0c9d-cf69-4798-b2e0-fe032df36569)) copies files from the local file system fileSet tostore using the corresponding keys keySet. If the keys already exist in store, then copyFileToStore replaces the files associated with the specified keys.

example

Examples

collapse all

Run a simulation on a parallel pool of process workers and retrieve the file storage on a client. The file storage is a FileStore object with key-file entries. Copy files to this object as specified by its corresponding keys using the copyFileToStore function.

The following simulation finds the average and standard deviation of random matrices and stores the results in the FileStore object using copyFileToStore.

function workerStatsCode(models) % Get the FileStore of the current job store = getCurrentFileStore; for i = 1:numel(models) % Compute the average and standard deviation of random matrices A = rand(models(i)); M = mean(A); S = std(A); % Save simulation results in temporary files sourceTempFile = strcat(tempname("C:\myTempFolder"),".mat"); save(sourceTempFile,"M","S"); % Copy files to FileStore object as key-file pairs key = strcat("result_",num2str(i)); copyFileToStore(store,sourceTempFile,key); end end

Start a parallel pool of process workers.

pool = parpool("Processes");

Starting parallel pool (parpool) using the 'Processes' profile ... Connected to the parallel pool (number of workers: 6).

Get the FileStore for this pool.

Run the simulation on the pool.

models = [4,8,32,20]; future = parfeval(@workerStatsCode,0,models); wait(future);

Input Arguments

collapse all

File storage shared by MATLAB clients and workers, specified as a FileStore object.

Local files, specified as a character vector, string scalar, string array, or cell array of character vectors or strings. fileSet andkeySet must have the same number of elements.

Example: ["/data/run.mat" "/tmp/run_log.txt"]

Keys to add, specified as a character vector, string scalar, string array, or cell array of character vectors or strings. fileSet andkeySet must have the same number of elements.

Example: ["myDataKey" "myLogKey"]

Version History

Introduced in R2022a