Skip to content

Commit

Permalink
feat(dispatch): require configuration of academic use for commercial …
Browse files Browse the repository at this point in the history
…solvers
  • Loading branch information
jonrkarr authored and bilalshaikh42 committed Sep 28, 2021
1 parent a696fbc commit 6c5307c
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 1 deletion.
2 changes: 2 additions & 0 deletions apps/api/src/simulation-run/simulation-run.controller.ts
Expand Up @@ -179,6 +179,7 @@ export class SimulationRunController {
memory: run.memory,
maxTime: run.maxTime,
envVars: run.envVars,
academicUse: run.academicUse,
isPublic: run.public,
};
const sim = await this.dispatchQueue.add(message);
Expand Down Expand Up @@ -223,6 +224,7 @@ export class SimulationRunController {
run.memory,
run.maxTime,
run.envVars,
run.academicUse,
run.submitted,
run.updated,
run.public,
Expand Down
4 changes: 4 additions & 0 deletions apps/api/src/simulation-run/simulation-run.model.ts
Expand Up @@ -150,6 +150,9 @@ export class SimulationRunModel extends Document {
})
envVars!: EnvironmentVariable[];

@Prop({ type: Boolean, required: false, default: false })
academicUse!: boolean;

@Prop()
submitted!: Date;

Expand Down Expand Up @@ -178,6 +181,7 @@ export type SimulationRunModelType = Pick<
| 'memory'
| 'maxTime'
| 'envVars'
| 'academicUse'
| 'refreshCount'
| 'submitted'
| 'updated'
Expand Down
2 changes: 2 additions & 0 deletions apps/dispatch-service/src/app/services/hpc/hpc.service.ts
Expand Up @@ -32,6 +32,7 @@ export class HpcService {
memory: number,
maxTime: number,
envVars: EnvironmentVariable[],
academicUse: boolean,
fileName: string,
): Promise<{
stdout: string;
Expand All @@ -49,6 +50,7 @@ export class HpcService {
memory,
maxTime,
envVars,
academicUse,
fileName,
endpoint,
id,
Expand Down
Expand Up @@ -13,6 +13,7 @@ export class SbatchService {
memory: number,
maxTime: number,
envVars: EnvironmentVariable[],
academicUse: boolean,
omexName: string,
apiDomain: string,
simId: string,
Expand Down Expand Up @@ -41,7 +42,10 @@ export class SbatchService {
apiDomain = 'https://run.api.biosimulations.dev/';
}

const singularityRunEnvVars = this.configService.get('singularity.envVars');
let singularityRunEnvVars = this.configService.get('singularity.envVarAll');
if (academicUse) {
singularityRunEnvVars = singularityRunEnvVars.concat(this.configService.get('singularity.envVarAcademic'));
}

const allEnvVars = envVars.concat(singularityRunEnvVars);

Expand Down
Expand Up @@ -36,6 +36,7 @@ export class DispatchProcessor {
data.memory,
data.maxTime,
data.envVars,
data.academicUse,
data.fileName,
);

Expand Down
Expand Up @@ -355,6 +355,39 @@
</div>
</div>

<div class="form-section">
<div class="form-section-head">
<div class="mat-form-field-prefix">
<biosimulations-icon icon="simulator"></biosimulations-icon>
</div>
<div class="form-section-head-title-subtitle">
<div class="form-section-title">Commercial solvers</div>
<div class="form-section-subtitle">
Optional: To execute the simulation with a commercial solver, confirm the purpose of the simulation is academic research or education.
</div>
</div>
</div>

<div class="form-section-body">
<div class="form-field-group">
<mat-checkbox
formControlName="academicUse"
[disableRipple]="true"
color="primary"
>
The purpose of this simulation is academic research or education.
</mat-checkbox>
<mat-hint>
<p>Some simulation tools, such as COBRApy and RBApy, can optionally execute simulations using commercial solvers such as Gurobi <a href="https://www.gurobi.com/products/gurobi-optimizer/" target="_blank"><biosimulations-icon icon="link"></biosimulations-icon></a>. These commercial solvers are often more accurate and more performant. However, these commercial solvers are not required to execute any of the available simulation tools. All of the available simulation tools can be run with freely available solvers.</p>

<p>Optionally, users can use these commercial solvers for academic research and education. To use these commercial solvers, check the box above to confirm that you are using runBioSimulations for academic research or education.</p>

<p>Non-academic users can execute simulations with commercial solvers by (a) running simulations through runBioSimulations' API and providing license keys through environment variables or (b) using the Docker images, command-line programs, or Python APIs for simulation tools on their own machines with their own license key environment variables or license files.</p>
</mat-hint>
</div>
</div>
</div>

<div class="form-section">
<div class="form-section-head">
<div class="mat-form-field-prefix">
Expand Down
Expand Up @@ -148,6 +148,7 @@ export class DispatchComponent implements OnInit, OnDestroy {
],
simulator: ['', [Validators.required]],
simulatorVersion: ['', [Validators.required]],
academicUse: [false],
cpus: [
1,
[
Expand Down Expand Up @@ -732,6 +733,7 @@ export class DispatchComponent implements OnInit, OnDestroy {
const memory: number = this.formGroup.value.memory; // in GB
const maxTime: number = this.formGroup.value.maxTime; // in min
const envVars: EnvironmentVariable[] = [];
const academicUse: boolean = this.formGroup.value.academicUse;
const name: string = this.formGroup.value.name;
const email: string | null = this.formGroup.value.email || null;

Expand All @@ -747,6 +749,7 @@ export class DispatchComponent implements OnInit, OnDestroy {
memory,
maxTime,
envVars,
academicUse,
name,
email,
);
Expand All @@ -760,6 +763,7 @@ export class DispatchComponent implements OnInit, OnDestroy {
memory,
maxTime,
envVars,
academicUse,
name,
email,
);
Expand All @@ -774,6 +778,7 @@ export class DispatchComponent implements OnInit, OnDestroy {
memory,
maxTime,
envVars,
academicUse,
email,
),
);
Expand All @@ -789,6 +794,7 @@ export class DispatchComponent implements OnInit, OnDestroy {
memory: number, // in GB
maxTime: number, // min min
envVars: EnvironmentVariable[],
academicUse: boolean,
email: string | null,
): void {
const simulationId = data['id'];
Expand All @@ -803,6 +809,7 @@ export class DispatchComponent implements OnInit, OnDestroy {
memory: memory,
maxTime: maxTime,
envVars: envVars,
academicUse: academicUse,
submittedLocally: true,
status: SimulationRunStatus.QUEUED,
runtime: undefined,
Expand Down
Expand Up @@ -16,6 +16,7 @@ export interface FormattedSimulation {
memory: number; // GB
maxTime: number; // min
envVars: EnvironmentVariable[];
academicUse: boolean;
status: SimulationRunStatus;
statusRunning: boolean;
statusSucceeded: boolean;
Expand Down
Expand Up @@ -91,6 +91,7 @@ export class ViewService {
memory: simulation.memory || 8,
maxTime: simulation.maxTime || 20,
envVars: simulation.envVars || [],
academicUse: simulation.academicUse || false,
status: simulation.status,
statusRunning: statusRunning,
statusSucceeded: statusSucceeded,
Expand Down
2 changes: 2 additions & 0 deletions apps/dispatch/src/app/datamodel.ts
Expand Up @@ -14,6 +14,7 @@ export interface UnknownSimulation {
memory?: null; // GB
maxTime?: null; // min
envVars?: null;
academicUse?: null;
status?: null;
runtime?: null;
submitted?: null;
Expand All @@ -33,6 +34,7 @@ export interface Simulation {
memory: number; // GB
maxTime: number; // min
envVars: EnvironmentVariable[];
academicUse: boolean;
status: SimulationRunStatus;
runtime?: number;
submitted: Date;
Expand Down
4 changes: 4 additions & 0 deletions apps/dispatch/src/app/services/dispatch/dispatch.service.ts
Expand Up @@ -93,6 +93,7 @@ export class DispatchService {
memory: number, // in GB
maxTime: number, // in minutes
envVars: EnvironmentVariable[],
academicUse: boolean,
name: string,
email: string | null,
): Observable<SimulationRun> {
Expand All @@ -106,6 +107,7 @@ export class DispatchService {
memory,
maxTime,
envVars,
academicUse,
public: false,
};
return this.http.post<SimulationRun>(this.endpoint, body, {
Expand All @@ -121,6 +123,7 @@ export class DispatchService {
memory: number, // in GB
maxTime: number, // in minutes
envVars: EnvironmentVariable[],
academicUse: boolean,
name: string,
email: string | null,
): Observable<SimulationRun> {
Expand All @@ -135,6 +138,7 @@ export class DispatchService {
memory,
maxTime,
envVars,
academicUse,
public: false,
};
formData.append('file', fileToUpload, fileToUpload.name);
Expand Down
Expand Up @@ -247,6 +247,7 @@ export class SimulationService {
memory: dispatchSimulation.memory,
maxTime: dispatchSimulation.maxTime,
envVars: dispatchSimulation.envVars,
academicUse: dispatchSimulation.academicUse,
updated: new Date(dispatchSimulation.updated),
resultsSize: dispatchSimulation.resultsSize,
projectSize: dispatchSimulation.projectSize,
Expand Down
11 changes: 11 additions & 0 deletions libs/dispatch/api-models/src/lib/simulationRun.ts
Expand Up @@ -83,6 +83,14 @@ export class SimulationRun {
})
envVars: EnvironmentVariable[];

@ApiPropertyOptional({
type: Boolean,
description: 'Whether use of commercial solvers is permitted because the purpose of the simulation is academic research or education',
required: false,
default: false,
})
academicUse: boolean;

@ApiPropertyOptional({
type: String,
format: 'email',
Expand Down Expand Up @@ -123,6 +131,7 @@ export class SimulationRun {
memory: number,
maxTime: number,
envVars: EnvironmentVariable[],
academicUse: boolean,
submitted: Date,
updated: Date,
isPublic?: boolean,
Expand All @@ -141,6 +150,7 @@ export class SimulationRun {
this.memory = memory || 8;
this.maxTime = maxTime || 20;
this.envVars = envVars || [];
this.academicUse = academicUse || false;
this.status = status || SimulationRunStatus.CREATED;
this.public = isPublic || false;
this.submitted = submitted;
Expand All @@ -163,6 +173,7 @@ export class UploadSimulationRun extends PickType(SimulationRun, [
'memory',
'maxTime',
'envVars',
'academicUse',
'public',
]) {}

Expand Down
3 changes: 3 additions & 0 deletions libs/messages/messages/src/lib/dispatch.ts
Expand Up @@ -49,6 +49,7 @@ export class DispatchCreatedPayload extends DispatchPayload {
memory: number;
maxTime: number;
envVars: EnvironmentVariable[];
academicUse: boolean;

constructor(
id: string,
Expand All @@ -59,6 +60,7 @@ export class DispatchCreatedPayload extends DispatchPayload {
memory: number,
maxTime: number,
envVars: EnvironmentVariable[],
academicUse: boolean,
) {
super(id);
this.fileName = fileName;
Expand All @@ -68,6 +70,7 @@ export class DispatchCreatedPayload extends DispatchPayload {
this.memory = memory;
this.maxTime = maxTime;
this.envVars = envVars;
this.academicUse = academicUse;
}
}

Expand Down
1 change: 1 addition & 0 deletions libs/messages/messages/src/lib/queues.ts
Expand Up @@ -27,6 +27,7 @@ export class DispatchJob {
memory!: number;
maxTime!: number;
envVars!: EnvironmentVariable[];
academicUse!: boolean;
isPublic!: boolean;
}

Expand Down
1 change: 1 addition & 0 deletions tools/scripts/createSimulationRun.sh
Expand Up @@ -11,6 +11,7 @@
"memory": 8,
"maxTime": 20,
"envVars": [],
"academicUse": true,
"email": "info@biosimulations.org",
"public": false,
"url": "https://github.com/biosimulators/Biosimulators_test_suite/raw/dev/examples/sbml-core/Ciliberto-J-Cell-Biol-2003-morphogenesis-checkpoint-continuous.omex"
Expand Down
2 changes: 2 additions & 0 deletions tools/submit-example-simulation-runs
Expand Up @@ -141,6 +141,7 @@ def main(runbiosimulations_api='dev', biosimulators_api='org',
"memory": 8,
"maxTime": 20,
"envVars": [],
"academicUse": True,
"email": None,
"public": True,
"url": url,
Expand Down Expand Up @@ -177,6 +178,7 @@ def main(runbiosimulations_api='dev', biosimulators_api='org',
"memory": 8,
"maxTime": 20,
"envVars": [],
"academicUse": True,
"submittedLocally": False,
"status": "CREATED",
"submitted": simulation_run['submitted'],
Expand Down

0 comments on commit 6c5307c

Please sign in to comment.