-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1124 from NASA-AMMOS/1071-scheduling-can-use-exte…
…rnal-profiles Scheduling can use external profiles
- Loading branch information
Showing
36 changed files
with
1,052 additions
and
370 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
constraints/src/main/java/gov/nasa/jpl/aerie/constraints/tree/SpansWrapperExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package gov.nasa.jpl.aerie.constraints.tree; | ||
import gov.nasa.jpl.aerie.constraints.model.EvaluationEnvironment; | ||
import gov.nasa.jpl.aerie.constraints.model.SimulationResults; | ||
import gov.nasa.jpl.aerie.constraints.time.Interval; | ||
import gov.nasa.jpl.aerie.constraints.time.Spans; | ||
|
||
import java.util.Set; | ||
|
||
public record SpansWrapperExpression(Spans spans) implements Expression<Spans> { | ||
@Override | ||
public Spans evaluate( | ||
final SimulationResults results, | ||
final Interval bounds, | ||
final EvaluationEnvironment environment) | ||
{ | ||
return spans; | ||
} | ||
|
||
@Override | ||
public String prettyPrint(final String prefix) { | ||
return String.format( | ||
"\n%s(spans-wrapper-of %s)", | ||
prefix, | ||
this.spans | ||
); } | ||
|
||
@Override | ||
public void extractResources(final Set<String> names) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
e2e-tests/src/tests/scheduler-external-datasets.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
|
||
import {expect, test} from "@playwright/test"; | ||
import req, {awaitScheduling, awaitSimulation} from "../utilities/requests.js"; | ||
import time from "../utilities/time.js"; | ||
|
||
/* | ||
This test uploads an external dataset and checks that it is possible to use an external resource in a scheduling goal | ||
*/ | ||
test.describe.serial('Scheduling with external dataset', () => { | ||
const rd = Math.random() * 100; | ||
const plan_start_timestamp = "2021-001T00:00:00.000"; | ||
const plan_end_timestamp = "2021-001T12:00:00.000"; | ||
|
||
test('Main', async ({request}) => { | ||
//upload bananation jar | ||
const jar_id = await req.uploadJarFile(request); | ||
|
||
const model: MissionModelInsertInput = { | ||
jar_id, | ||
mission: 'aerie_e2e_tests' + rd, | ||
name: 'Banananation (e2e tests)' + rd, | ||
version: '0.0.0' + rd, | ||
}; | ||
const mission_model_id = await req.createMissionModel(request, model); | ||
//delay for generation | ||
await delay(2000); | ||
const plan_input: CreatePlanInput = { | ||
model_id: mission_model_id, | ||
name: 'test_plan' + rd, | ||
start_time: plan_start_timestamp, | ||
duration: time.getIntervalFromDoyRange(plan_start_timestamp, plan_end_timestamp) | ||
}; | ||
const plan_id = await req.createPlan(request, plan_input); | ||
|
||
const profile_set = { | ||
'/my_boolean': { | ||
type: 'discrete', | ||
schema: { | ||
type: 'boolean', | ||
}, | ||
segments: [ | ||
{ duration: 3600000000, dynamics: false }, | ||
{ duration: 3600000000, dynamics: true }, | ||
{ duration: 3600000000, dynamics: false }, | ||
], | ||
}, | ||
}; | ||
|
||
const externalDatasetInput: ExternalDatasetInsertInput = { | ||
plan_id, | ||
dataset_start: plan_start_timestamp, | ||
profile_set, | ||
}; | ||
|
||
await req.insertExternalDataset(request, externalDatasetInput); | ||
|
||
await awaitSimulation(request, plan_id); | ||
|
||
const schedulingGoal1: SchedulingGoalInsertInput = | ||
{ | ||
description: "Test goal", | ||
model_id: mission_model_id, | ||
name: "ForEachGrowPeel" + rd, | ||
definition: `export default function myGoal() { | ||
return Goal.CoexistenceGoal({ | ||
forEach: Discrete.Resource("/my_boolean").equal(true).assignGaps(false), | ||
activityTemplate: ActivityTemplates.BiteBanana({ | ||
biteSize: 1, | ||
}), | ||
startsAt:TimingConstraint.singleton(WindowProperty.END) | ||
}) | ||
}` | ||
}; | ||
|
||
const first_goal_id = await req.insertSchedulingGoal(request, schedulingGoal1); | ||
|
||
let plan_revision = await req.getPlanRevision(request, plan_id); | ||
|
||
const schedulingSpecification: SchedulingSpecInsertInput = { | ||
// @ts-ignore | ||
horizon_end: plan_end_timestamp, | ||
horizon_start: plan_start_timestamp, | ||
plan_id: plan_id, | ||
plan_revision: plan_revision, | ||
simulation_arguments: {}, | ||
analysis_only: false | ||
} | ||
const scheduling_specification_id = await req.insertSchedulingSpecification(request, schedulingSpecification); | ||
|
||
const priority = 0; | ||
const specGoal: SchedulingSpecGoalInsertInput = { | ||
goal_id: first_goal_id, | ||
priority: priority, | ||
specification_id: scheduling_specification_id, | ||
}; | ||
await req.createSchedulingSpecGoal(request, specGoal); | ||
|
||
await awaitScheduling(request, scheduling_specification_id); | ||
const plan = await req.getPlan(request, plan_id) | ||
expect(plan.activity_directives.length).toEqual(1); | ||
expect(plan.activity_directives[0].startTime == "2021-001T02:00:00.000") | ||
await req.deletePlan(request, plan_id); | ||
await req.deleteMissionModel(request, mission_model_id) | ||
}); | ||
}); | ||
|
||
function delay(ms: number) { | ||
return new Promise( resolve => setTimeout(resolve, ms) ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.