-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
- Loading branch information
Showing
12 changed files
with
393 additions
and
99 deletions.
There are no files selected for viewing
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
Copyright 2023 Lawrence Livermore National Security, LLC | ||
(c.f. AUTHORS, NOTICE.LLNS, COPYING) | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
package application | ||
|
||
import ( | ||
"fmt" | ||
|
||
api "github.com/converged-computing/metrics-operator/api/v1alpha1" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
|
||
"github.com/converged-computing/metrics-operator/pkg/metadata" | ||
metrics "github.com/converged-computing/metrics-operator/pkg/metrics" | ||
"github.com/converged-computing/metrics-operator/pkg/specs" | ||
) | ||
|
||
type Laghos struct { | ||
metrics.LauncherWorker | ||
|
||
// Custom Options | ||
command string | ||
prefix string | ||
} | ||
|
||
// I think this is a simulation? | ||
func (m Laghos) Family() string { | ||
return metrics.SolverFamily | ||
} | ||
|
||
func (m Laghos) Url() string { | ||
return "https://github.com/CEED/Laghos" | ||
} | ||
|
||
// Set custom options / attributes for the metric | ||
func (m *Laghos) SetOptions(metric *api.Metric) { | ||
m.ResourceSpec = &metric.Resources | ||
m.AttributeSpec = &metric.Attributes | ||
|
||
// Set user defined values or fall back to defaults | ||
m.prefix = "/bin/bash" | ||
m.command = "mpirun -np 4 --hostfile ./hostlist.txt ./laghos" | ||
m.Workdir = "/workflow/laghos" | ||
|
||
// This could be improved :) | ||
command, ok := metric.Options["command"] | ||
if ok { | ||
m.command = command.StrVal | ||
} | ||
workdir, ok := metric.Options["workdir"] | ||
if ok { | ||
m.Workdir = workdir.StrVal | ||
} | ||
prefix, ok := metric.Options["prefix"] | ||
if ok { | ||
m.prefix = prefix.StrVal | ||
} | ||
} | ||
|
||
// Exported options and list options | ||
func (m Laghos) Options() map[string]intstr.IntOrString { | ||
return map[string]intstr.IntOrString{ | ||
"command": intstr.FromString(m.command), | ||
"prefix": intstr.FromString(m.prefix), | ||
"workdir": intstr.FromString(m.Workdir), | ||
} | ||
} | ||
|
||
func (m Laghos) PrepareContainers( | ||
spec *api.MetricSet, | ||
metric *metrics.Metric, | ||
) []*specs.ContainerSpec { | ||
|
||
// Metadata to add to beginning of run | ||
meta := metrics.Metadata(spec, metric) | ||
hosts := m.GetHostlist(spec) | ||
prefix := m.GetCommonPrefix(meta, m.command, hosts) | ||
|
||
preBlock := ` | ||
echo "%s" | ||
` | ||
|
||
postBlock := ` | ||
echo "%s" | ||
%s | ||
` | ||
command := fmt.Sprintf("%s ./problem.sh", m.prefix) | ||
interactive := metadata.Interactive(spec.Spec.Logging.Interactive) | ||
preBlock = prefix + fmt.Sprintf(preBlock, metadata.Separator) | ||
postBlock = fmt.Sprintf(postBlock, metadata.CollectionEnd, interactive) | ||
|
||
// Entrypoint for the launcher | ||
launcherEntrypoint := specs.EntrypointScript{ | ||
Name: specs.DeriveScriptKey(m.LauncherScript), | ||
Path: m.LauncherScript, | ||
Pre: preBlock, | ||
Command: command, | ||
Post: postBlock, | ||
} | ||
|
||
// Entrypoint for the worker | ||
workerEntrypoint := specs.EntrypointScript{ | ||
Name: specs.DeriveScriptKey(m.WorkerScript), | ||
Path: m.WorkerScript, | ||
Pre: prefix, | ||
Command: "sleep infinity", | ||
} | ||
|
||
// Container spec for the launcher | ||
launcherContainer := m.GetLauncherContainerSpec(launcherEntrypoint) | ||
workerContainer := m.GetWorkerContainerSpec(workerEntrypoint) | ||
|
||
// Return the script templates for each of launcher and worker | ||
return []*specs.ContainerSpec{&launcherContainer, &workerContainer} | ||
} | ||
|
||
func init() { | ||
launcher := metrics.LauncherWorker{ | ||
Identifier: "app-laghos", | ||
Summary: "LAGrangian High-Order Solver", | ||
Container: "ghcr.io/converged-computing/metric-laghos:latest", | ||
} | ||
|
||
Laghos := Laghos{LauncherWorker: launcher} | ||
metrics.Register(&Laghos) | ||
} |
Oops, something went wrong.