Skip to content

Commit

Permalink
Merge branch 'master' into 6914-sbatch-id-phase-1
Browse files Browse the repository at this point in the history
  • Loading branch information
robnagler authored Nov 13, 2024
2 parents 6e85033 + 860fbf5 commit fd58ef4
Show file tree
Hide file tree
Showing 36 changed files with 3,372 additions and 2,049 deletions.
3 changes: 3 additions & 0 deletions sirepo/api_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def check_api_call(qcall, func):
a.REQUIRE_COOKIE_SENTINEL,
a.REQUIRE_USER,
a.REQUIRE_ADM,
a.REQUIRE_PREMIUM,
):
if not qcall.cookie.has_sentinel():
raise sirepo.util.SRException("missingCookies", None)
Expand All @@ -42,6 +43,8 @@ def check_api_call(qcall, func):
qcall.auth.require_email_user()
elif expect == a.REQUIRE_ADM:
qcall.auth.require_adm()
elif expect == a.REQUIRE_PREMIUM:
qcall.auth.require_premium()
elif expect == a.ALLOW_VISITOR:
pass
elif expect == a.INTERNAL_TEST:
Expand Down
2 changes: 2 additions & 0 deletions sirepo/api_perm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class APIPerm(aenum.Flag):
REQUIRE_USER = aenum.auto()
#: only usable on internal test systems
INTERNAL_TEST = aenum.auto()
#: a user with a a premium subscription is required
REQUIRE_PREMIUM = aenum.auto()


#: A user can access APIs decorated with these permissions even if they don't have the role
Expand Down
4 changes: 4 additions & 0 deletions sirepo/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ def require_email_user(self):
if m != METHOD_EMAIL:
raise sirepo.util.Forbidden(f"method={m} is not email for uid={i}")

def require_premium(self):
if not self.is_premium_user():
raise sirepo.util.Forbidden(f"not premium user")

def require_user(self):
"""Asserts whether user is logged in
Expand Down
4 changes: 2 additions & 2 deletions sirepo/job_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async def api_runStatus(self):
# runStatus receives models when an animation status if first queried
return await self._request_api(_request_content=self._request_content(PKDict()))

@sirepo.quest.Spec("require_user")
@sirepo.quest.Spec("require_premium")
async def api_sbatchLogin(self):
r = self._request_content(
PKDict(computeJobHash="unused", jobRunMode=sirepo.job.SBATCH),
Expand All @@ -221,7 +221,7 @@ async def api_sbatchLogin(self):
r.pkdel("data")
return await self._request_api(_request_content=r)

@sirepo.quest.Spec("require_user")
@sirepo.quest.Spec("require_premium")
async def api_sbatchLoginStatus(self):
return await self._request_api(
_request_content=self._request_content(
Expand Down
4 changes: 0 additions & 4 deletions sirepo/package_data/static/css/openmc.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

.sr-range-slider {
background: var(--sr-action) !important;
}

.model-tallyReport-axis .sr-enum-button {
min-width: 4em;
}
4 changes: 4 additions & 0 deletions sirepo/package_data/static/css/sirepo.css
Original file line number Diff line number Diff line change
Expand Up @@ -1056,3 +1056,7 @@ img.sr-disabled-image {
.sr-hide-scrollbars {
overflow: hidden;
}

.sr-range-slider {
background: var(--sr-action) !important;
}
69 changes: 69 additions & 0 deletions sirepo/package_data/static/en/plans.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" href="/static/img/favicon.ico">
<link rel="icon" type="image/png" href="/static/img/favicon.png">
<link rel="apple-touch-icon" href="/static/img/favicon.png">
<title>RadiaSoft</title>
<link href="/static/css/ext/bootstrap-3.3.7.min.css" rel="stylesheet">
<link href="/en/css/landing.css" rel="stylesheet">
<script src="/static/js/ext/jquery-2.2.4.min.js"></script>
<script src="/static/js/ext/bootstrap-3.3.7.min.js"></script>
</head>
<body class="landing">
<div class="header-strip"></div>
<div class="max-width-container">
<header>
<nav class="navbar navbar-static-top main-nav">
<a class="home-link" href="/">
<img src="/en/img/sirepo-by-radiasoft-logo.png" class="logo" alt="Sirepo" />
</a>
</nav>
</header>

<main>
<section class="content-block intro">
<div class="row">
<div class="col-lg-8 center-block intro-content">
<h2>Sirepo Plans</h2>
<p>
You are running a private instance of sirepo.
<br/>
<a href="https://www.apache.org/licenses/LICENSE-2.0"> license </a>
</p>
</div>
<section style="background: white;" >
<br/>
<h3 style="margin: 1em;">Sirepo Plans</h3>
<p>You should only see this page if you are developing Sirepo.</p>
</section>
</div>
</section>
</main>

<footer>
<div class="row">
<div class="col-lg-12 center-block footer-content">
<img class="footer-sirepo" src="/en/img/sirepo-logo-white.png" alt="Sirepo" />

<nav class="footer-nav">
<ul>
<li><a href="https://radiasoft.net">RadiaSoft Home</a></li>
</ul>
</nav>

<div class="footer-radiasoft">
<img src="/en/img/radiasoft-logo-white.png" alt="RadiaSoft" />
<p>
&copy;2022 RadiaSoft
</p>
</div>
</div>
</div>
</footer>
</div>
</body>
</html>
123 changes: 63 additions & 60 deletions sirepo/package_data/static/html/openmc-visualization.html
Original file line number Diff line number Diff line change
@@ -1,71 +1,74 @@
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-xxl-4">
<div data-basic-editor-panel="" data-view-name="settings"></div>
</div>
<div class="col-md-6 col-xxl-4">
<div data-simple-panel="simulationStatus">
<div data-sim-status-panel="visualization.simState" data-start-function="visualization.startSimulation()"></div>
<div class="row">
<div class="col-md-offset-2 col-md-8" data-ng-show="visualization.eigenvalue.length">
<table class="table">
<caption style="text-align: center; font-weight: bold;">Eigenvalues</caption>
<thead>
<th>Batch</th>
<th>k</th>
<th>&lt;k&gt;</th>
<th>σ</th>
</thead>
<tbody>
<tr data-ng-repeat="e in visualization.eigenvalue.slice(-visualization.eigenvalueHistory()) track by $index">
<td>{{ e.batch }}</td>
<td>{{ e.val[0] }}</td>
<td>{{ e.val[1] || 'N/A' }}</td>
<td>{{ e.val[2] || 'N/A' }}</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-offset-2 col-md-8" data-ng-show="visualization.results.length">
<table class="table">
<caption style="text-align: center; font-weight: bold;">Results</caption>
<thead>
<th>Quantity</th>
<th>Value</th>
<th>σ</th>
</thead>
<tbody>
<tr data-ng-repeat="r in visualization.results track by $index">
<td>{{ r[0] }}</td>
<td>{{ r[1] }}</td>
<td>{{ r[2] }}</td>
</tr>
</tbody>
</table>
</div>
<div class="col-sm-12" data-ng-if="visualization.hasWeightWindowsFile">
<div class="col-sm-12"><a data-ng-attr-href="{{ visualization.weightWindowsFileURL() }}">
<span class="glyphicon glyphicon-cloud-download"></span> Computed Weight Windows</a>
<buttontype="button" class="btn btn-sm btn-default" data-ng-click="visualization.applyWeightWindows()">Apply Weight Windows</button>
<div class="col-sm-12 col-xxl-4">
<div class="row">
<div class="col-sm-6 col-xxl-12">
<div data-basic-editor-panel="" data-view-name="settings"></div>
</div>
<div class="col-sm-6 col-xxl-12">
<div data-simple-panel="simulationStatus">
<div data-sim-status-panel="visualization.simState" data-start-function="visualization.startSimulation()"></div>
<div class="row">
<div class="col-md-offset-2 col-md-8" data-ng-show="visualization.eigenvalue.length">
<table class="table">
<caption style="text-align: center; font-weight: bold;">Eigenvalues</caption>
<thead>
<th>Batch</th>
<th>k</th>
<th>&lt;k&gt;</th>
<th>σ</th>
</thead>
<tbody>
<tr data-ng-repeat="e in visualization.eigenvalue.slice(-visualization.eigenvalueHistory()) track by $index">
<td>{{ e.batch }}</td>
<td>{{ e.val[0] }}</td>
<td>{{ e.val[1] || 'N/A' }}</td>
<td>{{ e.val[2] || 'N/A' }}</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-offset-2 col-md-8" data-ng-show="visualization.results.length">
<table class="table">
<caption style="text-align: center; font-weight: bold;">Results</caption>
<thead>
<th>Quantity</th>
<th>Value</th>
<th>σ</th>
</thead>
<tbody>
<tr data-ng-repeat="r in visualization.results track by $index">
<td>{{ r[0] }}</td>
<td>{{ r[1] }}</td>
<td>{{ r[2] }}</td>
</tr>
</tbody>
</table>
</div>
<div class="col-sm-12" data-ng-if="visualization.hasWeightWindowsFile">
<div class="col-sm-12"><a data-ng-attr-href="{{ visualization.weightWindowsFileURL() }}">
<span class="glyphicon glyphicon-cloud-download"></span> Computed Weight Windows</a>
<buttontype="button" class="btn btn-sm btn-default" data-ng-click="visualization.applyWeightWindows()">Apply Weight Windows</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
</div>
<div class="row" data-ng-if="visualization.simState.hasFrames()">
<div class="col-sm-8">
<div data-report-panel="tallyViewer" data-model-name="openmcAnimation" data-panel-title="{{visualization.tallyTitle()}}"></div>
</div>
<div class="col-sm-4">
<div data-simple-panel="tallySettings">
<div data-advanced-editor-pane="" data-view-name="'tallySettings'" data-want-buttons=""
data-field-def="basic"></div>
<div data-ng-if="visualization.simState.hasFrames()">
<div class="col-md-8 col-lg-7 col-xl-6 col-xxl-4">
<div data-report-panel="tallyViewer" data-model-name="openmcAnimation" data-panel-title="{{visualization.tallyTitle()}}"></div>
</div>
<div data-ng-if="visualization.showEnergyPlot()">
<div data-report-panel="parameter" data-model-name="energyAnimation" data-panel-title="Energy Spectrum">
<div data-advanced-editor-pane="" data-view-name="'energyAnimation'" data-field-def="basic"></div>
<div class="col-md-4 col-lg-5 col-xl-6 col-xxl-3">
<div data-simple-panel="tallySettings">
<div data-advanced-editor-pane="" data-view-name="'tallySettings'" data-want-buttons=""
data-field-def="basic"></div>
</div>
<div data-ng-if="visualization.showEnergyPlot()">
<div data-report-panel="parameter" data-model-name="energyAnimation" data-panel-title="Energy Spectrum">
<div data-advanced-editor-pane="" data-view-name="'energyAnimation'" data-field-def="basic"></div>
</div>
</div>
</div>
</div>
Expand Down
27 changes: 13 additions & 14 deletions sirepo/package_data/static/js/elegant.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,34 +155,33 @@ SIREPO.app.factory('elegantService', function(appState, commandService, requestS
}

function commandsChanged() {
let cmd = self.findFirstCommand('run_setup');
if (cmd && cmd.use_beamline) {
appState.models.simulation.visualizationBeamlineId = cmd.use_beamline;
const rscmd = self.findFirstCommand('run_setup');
if (rscmd && rscmd.use_beamline) {
appState.models.simulation.visualizationBeamlineId = rscmd.use_beamline;
appState.saveQuietly('simulation');
}

// update bunchSource, bunchFile, bunch models
cmd = self.findFirstCommand(['bunched_beam', 'sdds_beam']);
if (! cmd) {
const bcmd = self.findFirstCommand(['bunched_beam', 'sdds_beam']);
if (! bcmd) {
return;
}
appState.models.bunchSource.inputSource = cmd._type;
appState.models.bunchSource.inputSource = bcmd._type;
appState.saveQuietly('bunchSource');
cmd = self.findFirstCommand('run_setup');
const bunch = appState.models.bunch;
if (cmd) {
if (rpnService.getRpnValue(cmd.p_central_mev) !== 0) {
bunch.p_central_mev = cmd.p_central_mev;
if (rscmd) {
if (rpnService.getRpnValue(rscmd.p_central_mev) !== 0) {
bunch.p_central_mev = rscmd.p_central_mev;
}
else {
bunch.p_central_mev = rpnService.getRpnValue(cmd.p_central) * SIREPO.APP_SCHEMA.constants.ELEGANT_ME_EV;
bunch.p_central_mev = rpnService.getRpnValue(rscmd.p_central) * SIREPO.APP_SCHEMA.constants.ELEGANT_ME_EV;
}
}
if (cmd._type == 'bunched_beam') {
updateBunchFromCommand(bunch, cmd);
if (bcmd._type == 'bunched_beam') {
updateBunchFromCommand(bunch, bcmd);
}
else {
appState.models.bunchFile.sourceFile = cmd.input;
appState.models.bunchFile.sourceFile = bcmd.input;
appState.saveQuietly('bunchFile');
}
// need to update source reports.
Expand Down
Loading

0 comments on commit fd58ef4

Please sign in to comment.