Modify singularity support per patch from Greg Kurtzer
Этот коммит содержится в:
родитель
007ca2ae08
Коммит
f7257a8310
@ -31,12 +31,9 @@
|
||||
|
||||
static int setup_app(char **personality,
|
||||
orte_app_context_t *context);
|
||||
static int setup_fork(orte_job_t *jdata,
|
||||
orte_app_context_t *context);
|
||||
|
||||
orte_schizo_base_module_t orte_schizo_singularity_module = {
|
||||
.setup_app = setup_app,
|
||||
.setup_fork = setup_fork
|
||||
.setup_app = setup_app
|
||||
};
|
||||
|
||||
static int setup_app(char **personality,
|
||||
@ -45,7 +42,7 @@ static int setup_app(char **personality,
|
||||
int i;
|
||||
char *newenv, *pth;
|
||||
bool takeus = false;
|
||||
char *p, *t2;
|
||||
char *t2;
|
||||
|
||||
/* see if we are included */
|
||||
for (i=0; NULL != personality[i]; i++) {
|
||||
@ -94,79 +91,9 @@ static int setup_app(char **personality,
|
||||
}
|
||||
}
|
||||
|
||||
/* ensure that we use "singularity run" to execute this app */
|
||||
if (0 != strcmp(app->app, "singularity")) {
|
||||
opal_output_verbose(1, orte_schizo_base_framework.framework_output,
|
||||
"%s schizo:singularity: adding singularity cmd %s",
|
||||
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), pth);
|
||||
/* change the app to the "singularity" command */
|
||||
free(app->app);
|
||||
app->app = pth;
|
||||
} else {
|
||||
free(pth);
|
||||
}
|
||||
|
||||
/* if the app contains .sapp, then we need to strip that
|
||||
* extension so singularity doesn't bark at us */
|
||||
if (NULL != (p = strstr(app->argv[0], ".sapp"))) {
|
||||
t2 = opal_basename(app->argv[0]);
|
||||
p = strstr(t2, ".sapp");
|
||||
*p = '\0'; // strip the extension
|
||||
free(app->argv[0]);
|
||||
app->argv[0] = t2;
|
||||
}
|
||||
opal_argv_prepend_nosize(&app->argv, "run");
|
||||
opal_argv_prepend_nosize(&app->argv, "singularity");
|
||||
|
||||
/* export an envar to permit shared memory operations */
|
||||
opal_setenv("SINGULARITY_NO_NAMESPACE_PID", "1", true, &app->env);
|
||||
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
||||
static int setup_fork(orte_job_t *jdata,
|
||||
orte_app_context_t *app)
|
||||
{
|
||||
int i;
|
||||
bool takeus = false;
|
||||
char *p;
|
||||
char dir[MAXPATHLEN];
|
||||
|
||||
/* see if we are included */
|
||||
for (i=0; NULL != jdata->personality[i]; i++) {
|
||||
if (0 == strcmp(jdata->personality[i], "singularity")) {
|
||||
takeus = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!takeus) {
|
||||
/* even if they didn't specify, check to see if
|
||||
* this involves a singularity container */
|
||||
if (0 != strcmp(app->argv[0],"singularity") &&
|
||||
0 != strcmp(app->argv[0],"sapprun") &&
|
||||
NULL == strstr(app->argv[0], ".sapp")) {
|
||||
/* guess not! */
|
||||
return ORTE_ERR_TAKE_NEXT_OPTION;
|
||||
}
|
||||
}
|
||||
|
||||
/* save our current directory */
|
||||
getcwd(dir, sizeof(dir));
|
||||
|
||||
/* change to the working directory for this context */
|
||||
chdir(app->cwd);
|
||||
|
||||
/* ensure the app is installed */
|
||||
opal_output_verbose(1, orte_schizo_base_framework.framework_output,
|
||||
"%s schizo:singularity: installing app %s",
|
||||
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), app->argv[2]);
|
||||
(void)asprintf(&p, "%s install %s.sapp &> /dev/null", app->app, app->argv[2]);
|
||||
system(p);
|
||||
free(p);
|
||||
|
||||
/* return to the original directory */
|
||||
chdir(dir);
|
||||
|
||||
return ORTE_SUCCESS;
|
||||
}
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user