Skip to content

Commit ddfd0aa

Browse files
authored
Merge pull request #3 from mathworks/getRemoteConnection
Ensure cached connection is valid
2 parents 44f074e + d576806 commit ddfd0aa

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Parallel Computing Toolbox plugin for MATLAB Parallel Server with Grid Engine
22

3-
[![View Parallel Computing Toolbox Plugin for Grid Engine on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://mathworks.com/matlabcentral/fileexchange/127389-parallel-computing-toolbox-plugin-for-grid-engine)
3+
[![View Parallel Computing Toolbox Plugin for Grid Engine on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/127389-parallel-computing-toolbox-plugin-for-grid-engine)
44

55
Parallel Computing Toolbox™ provides the `Generic` cluster type for submitting MATLAB® jobs to a cluster running a third-party scheduler.
66
The `Generic` cluster type uses a set of plugin scripts to define how your machine communicates with your scheduler.
@@ -10,10 +10,10 @@ This repository contains MATLAB code files and shell scripts that you can use to
1010

1111
## Products Required
1212

13-
- [MATLAB](https://mathworks.com/products/matlab.html) and [Parallel Computing Toolbox](https://mathworks.com/products/parallel-computing.html), R2017a or newer, installed on your computer.
14-
Refer to the documentation for [how to install MATLAB and toolboxes](https://mathworks.com/help/install/index.html) on your computer.
15-
- [MATLAB Parallel Server™](https://mathworks.com/products/matlab-parallel-server.html) installed on the cluster.
16-
Refer to the documentation for [how to install MATLAB Parallel Server](https://mathworks.com/help/matlab-parallel-server/integrate-matlab-with-third-party-schedulers.html) on your cluster.
13+
- [MATLAB](https://www.mathworks.com/products/matlab.html) and [Parallel Computing Toolbox](https://www.mathworks.com/products/parallel-computing.html), R2017a or newer, installed on your computer.
14+
Refer to the documentation for [how to install MATLAB and toolboxes](https://www.mathworks.com/help/install/index.html) on your computer.
15+
- [MATLAB Parallel Server™](https://www.mathworks.com/products/matlab-parallel-server.html) installed on the cluster.
16+
Refer to the documentation for [how to install MATLAB Parallel Server](https://www.mathworks.com/help/matlab-parallel-server/integrate-matlab-with-third-party-schedulers.html) on your cluster.
1717
The cluster administrator normally does this step.
1818
- Grid Engine running on the cluster.
1919

@@ -74,7 +74,7 @@ The cluster configuration file is a plain text file with the extension `.conf` c
7474
The MATLAB client will use the cluster configuration file to create a cluster profile for the user who discovers the cluster.
7575
Therefore, users will not need to follow the instructions in the sections below.
7676
You can find an example of a cluster configuration file in [discover/example.conf](discover/example.conf).
77-
For full details on how to make a cluster running a third-party scheduler discoverable, see the documentation for [Configure for Third-Party Scheduler Cluster Discovery](https://mathworks.com/help/matlab-parallel-server/configure-for-cluster-discovery.html).
77+
For full details on how to make a cluster running a third-party scheduler discoverable, see the documentation for [Configure for Third-Party Scheduler Cluster Discovery](https://www.mathworks.com/help/matlab-parallel-server/configure-for-cluster-discovery.html).
7878

7979
### Create a Cluster Profile in MATLAB
8080

@@ -91,7 +91,7 @@ c = parallel.cluster.Generic;
9191
### Configure Cluster Properties
9292

9393
This table lists the properties that you must specify to configure the `Generic` cluster profile.
94-
For a full list of cluster properties, see the documentation for [`parallel.Cluster`](https://mathworks.com/help/parallel-computing/parallel.cluster.html).
94+
For a full list of cluster properties, see the documentation for [`parallel.Cluster`](https://www.mathworks.com/help/parallel-computing/parallel.cluster.html).
9595

9696
**Property** | **Description**
9797
------------------------|----------------
@@ -131,7 +131,7 @@ struct('windows', 'M:\jobstorage', 'unix', '/organization/matlabjobs/jobstorage'
131131
```
132132

133133
You can use `AdditionalProperties` to modify the behaviour of the `Generic` cluster without editing the plugin scripts.
134-
For a full list of the `AdditionalProperties` supported by the plugin scripts in this repository, see [Customize Behavior of Sample Plugin Scripts](https://mathworks.com/help/matlab-parallel-server/customize-behavior-of-sample-plugin-scripts.html).
134+
For a full list of the `AdditionalProperties` supported by the plugin scripts in this repository, see [Customize Behavior of Sample Plugin Scripts](https://www.mathworks.com/help/matlab-parallel-server/customize-behavior-of-sample-plugin-scripts.html).
135135
By modifying the plugins, you can add support for your own custom `AdditionalProperties`.
136136

137137
#### Connect to a Remote Cluster
@@ -196,7 +196,7 @@ c = parcluster("myGridEngineCluster")
196196
### Submit Work for Batch Processing
197197

198198
The `batch` command runs a MATLAB script or function on a worker on the cluster.
199-
For more information about batch processing, see the documentation for [`batch`](https://mathworks.com/help/parallel-computing/batch.html).
199+
For more information about batch processing, see the documentation for [`batch`](https://www.mathworks.com/help/parallel-computing/batch.html).
200200

201201
```matlab
202202
% Create a job and submit it to the cluster.
@@ -228,7 +228,7 @@ A parallel pool (parpool) is a group of MATLAB workers on which you can interact
228228
When you run the `parpool` command, MATLAB submits a special job to the cluster to start the workers.
229229
Once the workers start, your MATLAB session connects to them.
230230
Depending on the network configuration at your organization, including whether it is permissible to connect to a program running on a compute node, parpools may not be functional.
231-
For more information about parpools, see the documentation for [`parpool`](https://mathworks.com/help/parallel-computing/parpool.html).
231+
For more information about parpools, see the documentation for [`parpool`](https://www.mathworks.com/help/parallel-computing/parpool.html).
232232

233233
```matlab
234234
% Open a parallel pool on the cluster. This command returns a

communicatingSubmitFcn.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function communicatingSubmitFcn(cluster, job, environmentProperties)
103103
if cluster.HasSharedFilesystem
104104
jobDirectoryOnCluster = cluster.getJobFolderOnCluster(job);
105105
else
106-
jobDirectoryOnCluster = remoteConnection.getRemoteJobLocation(job.ID, cluster.OperatingSystem);
106+
jobDirectoryOnCluster = remoteConnection.getRemoteJobLocation(job.ID, clusterOS);
107107
end
108108

109109
% Specify the job wrapper script to use.
@@ -174,13 +174,13 @@ function communicatingSubmitFcn(cluster, job, environmentProperties)
174174
remoteConnection.startMirrorForJob(job);
175175
end
176176

177-
if strcmpi(cluster.OperatingSystem, 'unix')
177+
if strcmpi(clusterOS, 'unix')
178178
% Add execute permissions to shell scripts
179179
runSchedulerCommand(cluster, sprintf( ...
180-
'chmod u+x %s%s*.sh', jobDirectoryOnCluster, fileSeparator));
180+
'chmod u+x "%s%s"*.sh', jobDirectoryOnCluster, fileSeparator));
181181
% Convert line endings to Unix
182182
runSchedulerCommand(cluster, sprintf( ...
183-
'dos2unix --allow-chown %s%s*.sh', jobDirectoryOnCluster, fileSeparator));
183+
'dos2unix --allow-chown "%s%s"*.sh', jobDirectoryOnCluster, fileSeparator));
184184
end
185185

186186
% Now ask the cluster to run the submission command

discover/example.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# For more information, including the required format for this file, see
1111
# the online documentation for making a cluster running a third-party
1212
# scheduler discoverable:
13-
# https://mathworks.com/help/matlab-parallel-server/configure-for-cluster-discovery.html
13+
# https://www.mathworks.com/help/matlab-parallel-server/configure-for-cluster-discovery.html
1414

1515
# Copyright 2023 The MathWorks, Inc.
1616

getCommonSubmitArgs.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
% Memory required per CPU
2121
commonSubmitArgs = iAppendArgument(commonSubmitArgs, ap, ...
22-
'MemPerCPU', 'char', '-l pmem=%s');
22+
'MemPerCPU', 'char', '-l s_vmem=%s');
2323

2424
% Project
2525
commonSubmitArgs = iAppendArgument(commonSubmitArgs, ap, ...

getRemoteConnection.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
remoteConnection = cluster.UserData.RemoteConnection;
4444

4545
% And check it is of the type that we expect
46-
if isempty(remoteConnection)
46+
if isempty(remoteConnection) || (isa(remoteConnection, "handle") && ~isvalid(remoteConnection))
4747
needToCreateNewConnection = true;
4848
else
4949
clusterAccessClassname = 'parallel.cluster.RemoteClusterAccess';

independentSubmitFcn.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function independentSubmitFcn(cluster, job, environmentProperties)
107107
if cluster.HasSharedFilesystem
108108
jobDirectoryOnCluster = cluster.getJobFolderOnCluster(job);
109109
else
110-
jobDirectoryOnCluster = remoteConnection.getRemoteJobLocation(job.ID, cluster.OperatingSystem);
110+
jobDirectoryOnCluster = remoteConnection.getRemoteJobLocation(job.ID, clusterOS);
111111
end
112112

113113
% Name of the wrapper script to launch the MATLAB worker
@@ -218,13 +218,13 @@ function independentSubmitFcn(cluster, job, environmentProperties)
218218
remoteConnection.startMirrorForJob(job);
219219
end
220220

221-
if strcmpi(cluster.OperatingSystem, 'unix')
221+
if strcmpi(clusterOS, 'unix')
222222
% Add execute permissions to shell scripts
223223
runSchedulerCommand(cluster, sprintf( ...
224-
'chmod u+x %s%s*.sh', jobDirectoryOnCluster, fileSeparator));
224+
'chmod u+x "%s%s"*.sh', jobDirectoryOnCluster, fileSeparator));
225225
% Convert line endings to Unix
226226
runSchedulerCommand(cluster, sprintf( ...
227-
'dos2unix --allow-chown %s%s*.sh', jobDirectoryOnCluster, fileSeparator));
227+
'dos2unix --allow-chown "%s%s"*.sh', jobDirectoryOnCluster, fileSeparator));
228228
end
229229

230230
for ii=1:numel(commandsToRun)

0 commit comments

Comments
 (0)