Skip to content

Commit f7257a8

Browse files
author
Ralph Castain
committed
Modify singularity support per patch from Greg Kurtzer
1 parent 007ca2a commit f7257a8

File tree

1 file changed

+2
-75
lines changed

1 file changed

+2
-75
lines changed

orte/mca/schizo/singularity/schizo_singularity.c

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@
3131

3232
static int setup_app(char **personality,
3333
orte_app_context_t *context);
34-
static int setup_fork(orte_job_t *jdata,
35-
orte_app_context_t *context);
3634

3735
orte_schizo_base_module_t orte_schizo_singularity_module = {
38-
.setup_app = setup_app,
39-
.setup_fork = setup_fork
36+
.setup_app = setup_app
4037
};
4138

4239
static int setup_app(char **personality,
@@ -45,7 +42,7 @@ static int setup_app(char **personality,
4542
int i;
4643
char *newenv, *pth;
4744
bool takeus = false;
48-
char *p, *t2;
45+
char *t2;
4946

5047
/* see if we are included */
5148
for (i=0; NULL != personality[i]; i++) {
@@ -94,79 +91,9 @@ static int setup_app(char **personality,
9491
}
9592
}
9693

97-
/* ensure that we use "singularity run" to execute this app */
98-
if (0 != strcmp(app->app, "singularity")) {
99-
opal_output_verbose(1, orte_schizo_base_framework.framework_output,
100-
"%s schizo:singularity: adding singularity cmd %s",
101-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), pth);
102-
/* change the app to the "singularity" command */
103-
free(app->app);
104-
app->app = pth;
105-
} else {
106-
free(pth);
107-
}
108-
109-
/* if the app contains .sapp, then we need to strip that
110-
* extension so singularity doesn't bark at us */
111-
if (NULL != (p = strstr(app->argv[0], ".sapp"))) {
112-
t2 = opal_basename(app->argv[0]);
113-
p = strstr(t2, ".sapp");
114-
*p = '\0'; // strip the extension
115-
free(app->argv[0]);
116-
app->argv[0] = t2;
117-
}
118-
opal_argv_prepend_nosize(&app->argv, "run");
119-
opal_argv_prepend_nosize(&app->argv, "singularity");
120-
12194
/* export an envar to permit shared memory operations */
12295
opal_setenv("SINGULARITY_NO_NAMESPACE_PID", "1", true, &app->env);
12396

12497
return ORTE_SUCCESS;
12598
}
12699

127-
static int setup_fork(orte_job_t *jdata,
128-
orte_app_context_t *app)
129-
{
130-
int i;
131-
bool takeus = false;
132-
char *p;
133-
char dir[MAXPATHLEN];
134-
135-
/* see if we are included */
136-
for (i=0; NULL != jdata->personality[i]; i++) {
137-
if (0 == strcmp(jdata->personality[i], "singularity")) {
138-
takeus = true;
139-
break;
140-
}
141-
}
142-
if (!takeus) {
143-
/* even if they didn't specify, check to see if
144-
* this involves a singularity container */
145-
if (0 != strcmp(app->argv[0],"singularity") &&
146-
0 != strcmp(app->argv[0],"sapprun") &&
147-
NULL == strstr(app->argv[0], ".sapp")) {
148-
/* guess not! */
149-
return ORTE_ERR_TAKE_NEXT_OPTION;
150-
}
151-
}
152-
153-
/* save our current directory */
154-
getcwd(dir, sizeof(dir));
155-
156-
/* change to the working directory for this context */
157-
chdir(app->cwd);
158-
159-
/* ensure the app is installed */
160-
opal_output_verbose(1, orte_schizo_base_framework.framework_output,
161-
"%s schizo:singularity: installing app %s",
162-
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), app->argv[2]);
163-
(void)asprintf(&p, "%s install %s.sapp &> /dev/null", app->app, app->argv[2]);
164-
system(p);
165-
free(p);
166-
167-
/* return to the original directory */
168-
chdir(dir);
169-
170-
return ORTE_SUCCESS;
171-
}
172-

0 commit comments

Comments
 (0)