Commit d9d8eb89 authored by John Tourtellott's avatar John Tourtellott

Merge branch 'master' into release

parents 17efdfe9 5c27b52a
......@@ -3,5 +3,8 @@
*.pyo
__pycache__/
# IDE config files
.vscode/
# Exclude OS X .DS_Store files.
.DS_Store
This diff is collapsed.
......@@ -50,14 +50,14 @@
<!-- One include file with definitions per tab -->
<!-- Must load boundaryconditions before analysis, for AttributeRef -->
<Includes>
<File>templates/beamloading.sbt</File>
<File>templates/boundarycondition.sbt</File>
<File>templates/loading.sbt</File>
<File>templates/material.sbt</File>
<File>templates/monitor.sbt</File>
<File>templates/analysis.sbt</File>
<File>templates/track3p.sbt</File>
<File>templates/tem3p.sbt</File>
<File>internal/templates/beamloading.sbt</File>
<File>internal/templates/boundarycondition.sbt</File>
<File>internal/templates/loading.sbt</File>
<File>internal/templates/material.sbt</File>
<File>internal/templates/monitor.sbt</File>
<File>internal/templates/analysis.sbt</File>
<File>internal/templates/track3p.sbt</File>
<File>internal/templates/tem3p.sbt</File>
</Includes>
<!--********** Workflow Views ***********-->
......
<?xml version="1.0"?>
<SMTK_AttributeSystem Version="2">
<SMTK_AttributeResource Version="3">
<Definitions>
<AttDef Type="ExportSpec" Label="Settings" BaseType="" Version="0">
<AttDef Type="ace3p-export" BaseType="operation" Label="Export to ACE3P" Version="1">
<BriefDescription>
Write ACE3P input file for selected program.
</BriefDescription>
<DetailedDescription>
</DetailedDescription>
<ItemDefinitions>
<Component Name="model" Label="Model" LockType="DoNotLock">
<Accepts>
<Resource Name="smtk::model::Resource" Filter="model" />
</Accepts>
</Component>
<Resource Name="attributes" Label="Attributes">
<Accepts>
<Resource Name="smtk::attribute::Resource"/>
</Accepts>
</Resource>
<File Name="MeshFile" Label="Mesh File" ShouldExist="True"
FileFilters="Exodus files (*.exo *.ex2 *.gen);;NetCDf files (*.ncdf);; All files (*.*)" Version="0"/>
<String Name="Analysis" Label="ACE3P Analysis" Version="0">
<ChildrenDefinitions>
<Directory Name="OutputFolder" Label="Export Folder" Version="0">
......@@ -52,6 +69,8 @@
<Value Enum="Acdtool">acdtool</Value>
<Items>
<Item>AcdtoolTask</Item>
<Item>OutputFolder</Item>
<Item>OutputFilePrefix</Item>
</Items>
</Structure>
<Structure>
......@@ -126,9 +145,6 @@
</Structure>
</DiscreteInfo>
</String>
<File Name="PythonScript" Label="Python script" Version="0" AdvanceLevel="1" NumberOfRequiredValues="1" ShouldExist="true" FileFilters="Python files (*.py);;All files (*.*)">
<DefaultValue>ACE3P.py</DefaultValue>
</File>
<Group Name="NERSCSimulation" Label="Submit job to NERSC"
Optional="true" IsEnabledByDefault="false"
......@@ -212,18 +228,18 @@
<DefaultValue>5</DefaultValue>
<RangeInfo><Min Inclusive="true">1</Min></RangeInfo>
</Int>
<String Name="TailFile" Label="Tail Filename" Version="0" AdvanceLevel="1">
<!-- <String Name="TailFile" Label="Tail Filename" Version="0" AdvanceLevel="1">
</String>
</ItemDefinitions>
--> </ItemDefinitions>
</Group>
</ItemDefinitions>
</AttDef>
</Definitions>
<Views>
<View Type="Instanced" Title="Export Settings" TopLevel="true" FilterByCategory="false">
<View Type="Instanced" Title="Export Settings" TopLevel="true" FilterByCategory="false" FilterByAdvanceLevel="true">
<InstancedAttributes>
<Att Name="Options" Type="ExportSpec" />
</InstancedAttributes>
</View>
</Views>
</SMTK_AttributeSystem>
</SMTK_AttributeResource>
"""
Log into nersc machine and get newt session id
"""
import argparse
import getpass
import requests
nersc_url = 'https://newt.nersc.gov/newt'
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Login to obtain newt session id')
parser.add_argument('--machine', '-m', default='cori', help='cori or edison')
parser.add_argument('--user', '-u', default='johnt', help='user name')
args = parser.parse_args()
# print(args)
print('Username: {}'.format(args.user))
print('Machine: {}'.format(args.machine))
password = getpass.getpass(prompt='Password: ')
# One time password for MFA
otp = input('Enter one time password (for MFA)')
# print('ready')
credentials = {
'username': args.user,
'password': password + str(otp)
}
url = '{}/login/'.format(nersc_url)
r = requests.post(url, data=credentials)
r.raise_for_status()
js = r.json()
if js.get('auth'):
session_id = js.get('newt_sessionid')
print('newt_sessionid: {}'.format(session_id))
else:
print('NOT authenticated, response:')
print(r.text)
"""
Continually logs user's queue on nersc machine
"""
import argparse
import datetime
import time
import requests
nersc_url = 'https://newt.nersc.gov/newt'
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Login to obtain newt session id')
parser.add_argument('--machine', '-m', default='cori', help='cori or edison')
parser.add_argument('--outfile', '-o', help='output logfile')
parser.add_argument('--user', '-u', default='johnt', help='user name')
parser.add_argument('--wait_sec', '-w', default=5, help='delay between each queue request')
# Add session id either as string or file to read
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--sessionid', '-s', help='newt session id')
group.add_argument('--id_filename', '-i', help='filename containing newt session id')
args = parser.parse_args()
# print(args)
print('Username: {}'.format(args.user))
print('Machine: {}'.format(args.machine))
url = '{}/queue/{}?user={}'.format(nersc_url, args.machine, args.user)
newt_sessionid = None
if args.sessionid:
newt_sessionid
elif args.id_filename:
with open(args.id_filename) as f:
newt_sessionid = f.read().strip()
if not newt_sessionid:
raise RuntimeError('Not able to read session id file {}'.format(args.if_filename))
cookies = dict(newt_sessionid=newt_sessionid)
# Rest logfile
if args.outfile:
with open(args.outfile, 'w') as f:
pass
start_time = datetime.datetime.now()
td = None # time delta
print('Begin logging loop: use Control-C to break')
try:
while True:
if td is None:
td = datetime.timedelta()
else:
td = datetime.datetime.now() - start_time
r = requests.get(url, cookies=cookies)
r.raise_for_status()
js = r.json()
data = '{}: {}'.format(td, js)
print(data)
# Log to file
if args.outfile:
complete = False
with open(args.outfile, 'a') as f:
f.write(data)
f.write('\n')
complete = True
if not complete:
print('Unabled to write to output file {}'.format(args.outfile))
# Delay
time.sleep(args.wait_sec)
except KeyboardInterrupt:
print('done')
r = requests.post(url, data=credentials)
r.raise_for_status()
js = r.json()
if js.get('auth'):
session_id = js.get('newt_sessionid')
print('newt_sessionid: {}'.format(session_id))
else:
print('NOT authenticated, response:')
print(r.text)
......@@ -3,11 +3,11 @@
<!-- ********** Include files ***********-->
<!-- Typically one include file with definitions per tab-->
<Includes>
<File>templates/tem3p-boundarycondition.sbt</File>
<File>templates/tem3p-material.sbt</File>
<File>templates/tem3p-mesh.sbt</File>
<File>templates/tem3p-solver.sbt</File>
<File>templates/tem3p-thermal.sbt</File>
<File>internal/templates/tem3p-boundarycondition.sbt</File>
<File>internal/templates/tem3p-material.sbt</File>
<File>internal/templates/tem3p-mesh.sbt</File>
<File>internal/templates/tem3p-solver.sbt</File>
<File>internal/templates/tem3p-thermal.sbt</File>
</Includes>
<Views>
......
......@@ -13,8 +13,6 @@ side set 2 ------> Magnetic
side set 6 ------> Exterior
Conductivity --> 5.78e+07
Magnetic --> side set 1, side set 2
## Materials
Material --> New, element block 1
......
......@@ -18,6 +18,7 @@ import time
import uuid
import requests
import girder_client
from girder_client import GirderClient, HttpError
class CumulusClient():
......@@ -67,9 +68,13 @@ class CumulusClient():
#print 'user', user
user_id = user['_id']
r = self._client.listFolder(user_id, 'user', name='Private')
if len(r) != 1:
raise Exception('Wrong number of users; should be 1 got %s' % len(r))
self._private_folder_id = r[0]['_id']
# Getting mixed signals on what listFolder returns
# I *think* it is a generator
try:
self._private_folder_id = r.next()['_id']
except Exception as ex:
# But just in case
self._private_folder_id = r[0]['_id']
print 'private_folder_id', self._private_folder_id
# ---------------------------------------------------------------------
......@@ -154,7 +159,6 @@ class CumulusClient():
print 'Created job folder', folder_name
self._input_folder_id = self.get_folder(self._job_folder_id, 'input_files')
self._output_folder_id = self.get_folder(self._job_folder_id, 'output_files')
# Make sure job_name isn't null
if not job_name:
job_name = 'CumulusJob'
......@@ -346,10 +350,9 @@ class CumulusClient():
'''Returns folder_id, creating one if needed
'''
# Check if folder already exists
folder_list = self._client.listFolder(parent_id, name=name)
folder_list = list(self._client.listFolder(parent_id, name=name))
if folder_list:
folder = folder_list[0]
#print 'found folder %s: %s' % (name, str(folder))
return folder['_id']
# (else)
......
......@@ -21,13 +21,11 @@ import time
import traceback
import shutil
from girder_client import HttpError
import girder_client
print 'girder_client', girder_client.__version__
import requests
import smtk
if 'pybind11' == smtk.wrappingProtocol():
#print 'Using pybind11 bindings'
import smtk.attribute
import smtk.attribute
import cumulusclient
reload(cumulusclient) # for dev
......@@ -92,7 +90,7 @@ def submit_ace3p(scope, sim_item):
# Submit job
submit_job(scope, sim_item)
print 'Submitted %s job, id %s' % (solver, scope.cumulus.job_id())
except HttpError as err:
except girder_client.HttpError as err:
print 'ERROR', err.responseText
raise
except Exception as ex:
......@@ -222,9 +220,10 @@ def create_job(scope, solver, sim_item):
job_name = get_string(sim_item, 'JobName')
if not job_name:
raise Exception('No Job Name specified -- cannot submit to NERSC')
tail = get_string(sim_item, 'TailFile')
scope.cumulus.create_job(job_name, tail=tail)
# Next line crashes modelbuilder, because there is no TailFile item any more
# tail = get_string(sim_item, 'TailFile')
# scope.cumulus.create_job(job_name, tail=tail)
scope.cumulus.create_job(job_name)
# Add cmb-specific metadata
cmb_data = dict()
......@@ -304,9 +303,7 @@ def get_acdtool_args(scope):
Returns a string with the formatted arguments
'''
# Need the Analysis attribute item
att_list = scope.export_atts.findAttributes('ExportSpec')
export_spec_att = att_list[0]
solver_item = export_spec_att.findString('Analysis')
solver_item = scope.export_att.findString('Analysis')
task_item = solver_item.findChild('AcdtoolTask', smtk.attribute.ACTIVE_CHILDREN)
task = task_item.value(0)
......
......@@ -260,7 +260,7 @@ class Track3PWriter(basewriter.BaseWriter):
ent_ref = model_ent_item.value(i)
ent = ent_ref.entity()
prop_idlist = self.scope.model_manager.integerProperty(ent, 'pedigree id')
prop_idlist = self.scope.model_resource.integerProperty(ent, 'pedigree id')
#print 'idlist', idlist
if prop_idlist:
#scope.output.write(' %d' % idlist[0])
......
......@@ -9,16 +9,16 @@ import smtk.model
# ---------------------------------------------------------------------
def get_model_info(scope):
'''Finds/updates model-related info on input scope object:
'''DEPRECATED Finds/updates model-related info on input scope object:
* scope.model_manager
* scope.model_resource
* scope.model_ent
* scope.model_file
* scope.model_path
'''
scope.model_manager = scope.sim_atts.refModelManager()
scope.model_resource = scope.sim_atts.refModelResource()
mask = int(smtk.model.MODEL_ENTITY)
model_ents = scope.model_manager.entitiesMatchingFlags(mask, True)
model_ents = scope.model_resource.entitiesMatchingFlags(mask, True)
#print 'model_ents', model_ents
if not model_ents:
msg = 'No model - cannot export'
......@@ -33,7 +33,7 @@ def get_model_info(scope):
# Get path to native model from string properties
# that *should* be on the model
urls = scope.model_manager.stringProperty(scope.model_ent, 'url')
urls = scope.model_resource.stringProperty(scope.model_ent, 'url')
if not urls:
msg = 'Model has to string property \"url\"'
print 'ERROR: %s' % msg
......@@ -51,7 +51,7 @@ def get_model_info(scope):
scope.model_path = url
else:
# Path to native model is relative to .smtk model file
smtk_urls = scope.model_manager.stringProperty(
smtk_urls = scope.model_resource.stringProperty(
scope.model_ent, 'smtk_url')
if not smtk_urls:
msg = 'Model has no string property \"smtk_url\". Cannot get path to native model'
......@@ -104,12 +104,9 @@ def get_entity_ids(scope, model_entity_item):
if not model_entity_item.isSet(i):
continue
ent_ref = model_entity_item.value(i)
ent = ent_ref.entity()
prop_idlist = scope.model_manager.integerProperty(ent, 'pedigree id')
#print 'idlist', idlist
ent = model_entity_item.objectValue(i)
prop_idlist = scope.model_resource.integerProperty(ent.id(), 'pedigree id')
if prop_idlist:
#scope.output.write(' %d' % idlist[0])
ent_idlist.append(prop_idlist[0])
return sorted(ent_idlist)
<?xml version="1.0"?>
<cmb-resources>
<attribute id="simbuilder" role="template">
<include href="internal/AdHShallowWater.sbt" />
</attribute>
<!-- Template for Shallow Water Export Dialog -->
<attribute id="export" role="template">
<SMTK_AttributeSystem Version="2">
<Definitions>
<AttDef Type="ExportSpec" BaseType="" Version="0" Unique="true">
<AssociationsDef Name="model" Label="Model" Version="0" NumberOfRequiredValues="1">
<MembershipMask>model</MembershipMask>
</AssociationsDef>
<ItemDefinitions>
<Directory Name="OutputDirectory" Label="Output Directory" Version="1" NumberOfRequiredValues="1" />
<String Name="FileBase" Label="FileName Base" Version="1" NumberOfRequiredValues="1">
<BriefDescription>Common base name for output files (.2dm, .bc)</BriefDescription>
<DefaultValue>shallowwater</DefaultValue>
</String>
<!-- Advanced attributes -->
<String Name="AnalysisTypes" Label="Analysis Types" AdvanceLevel="99" Version="0"
Extensible="true" NumberOfRequiredValues="1"/>
<MeshEntity Name="mesh" Label="Mesh" Version="0" NumberOfRequiredValues="1" />
<File Name="PythonScript" Label="Python script" AdvanceLevel="0" Version="0" NumberOfRequiredValues="1"
ShouldExist="true" FileFilters="Python files (*.py);;All files (*.*)">
<DefaultValue>AdHShallowWater.py</DefaultValue>
</File>
<!-- Hide Extrusion executable option until new ERDC code in place -->
<File Name="ExtrusionExecutable" Label="adh_2d_3d Executable" Version="0" NumberOfRequiredValues="1"
AdvanceLevel="99" ShouldExist="true"
Optional="true" IsEnabledByDefault="false"
FileFilters="All files (*.*)">
<DefaultValue>adh_2d_3d</DefaultValue>
</File>
</ItemDefinitions>
</AttDef>
</Definitions>
<Views>
<View Type="Instanced" Title="ExportSpec" TopLevel="true"
FilterByCategory="false">
<InstancedAttributes>
<Att Name="Export Specification" Type="ExportSpec">Options</Att>
</InstancedAttributes>
</View>
</Views>
</SMTK_AttributeSystem>
</attribute>
</cmb-resources>
......@@ -2,7 +2,7 @@
<SMTK_AttributeManager Version="1">
<Includes>
<!-- Uses same definitions as surface water -->
<File>AdHSurfaceWaterDefinitions.sbt</File>
<File>internal/AdHSurfaceWaterDefinitions.sbt</File>
</Includes>
<!-- Adds extrusion meshing attribute -->
......
<?xml version="1.0"?>
<cmb-resources>
<!-- Include baseline template by reference -->
<attribute id="simbuilder" role="template">
<include href="internal/AdHSurfaceWater.sbt" />
</attribute>
<!-- Template for Export Dialog -->
<attribute id="export" role="template">
<SMTK_AttributeSystem Version="2">
<Definitions>
<AttDef Type="ExportSpec" BaseType="" Version="0" Unique="true">
<AssociationsDef Name="model" Label="Model" Version="0" NumberOfRequiredValues="1">
<MembershipMask>model</MembershipMask>
</AssociationsDef>
<ItemDefinitions>
<String Name="AnalysisTypes" Label="Analysis Types" AdvanceLevel="99" Version="0"
Extensible="true" NumberOfRequiredValues="1"/>
<MeshEntity Name="mesh" Label="Mesh" Version="0" NumberOfRequiredValues="1" />
<Directory Name="OutputDirectory" Label="Output Directory" Version="1" NumberOfRequiredValues="1" />
<String Name="FileBase" Label="FileName Base" Version="1" NumberOfRequiredValues="1">
<BriefDescription>Common base name for output files (.2dm, .bc)</BriefDescription>
<DefaultValue>surfacewater</DefaultValue>
</String>
<File Name="PythonScript" Label="Python script" AdvanceLevel="0" Version="0" NumberOfRequiredValues="1"
ShouldExist="true" FileFilters="Python files (*.py);;All files (*.*)">
<DefaultValue>AdHSurfaceWater.py</DefaultValue>
</File>
</ItemDefinitions>
</AttDef>
</Definitions>
<Attributes />
<Views>
<View Type="Instanced" Title="ExportSpec" TopLevel="true"
FilterByAdvanceLevel="false" FilterByCategory="false">
<InstancedAttributes>
<Att Name="Export Specification" Type="ExportSpec">Options</Att>
</InstancedAttributes>
</View>
</Views>
</SMTK_AttributeSystem>
</attribute>
</cmb-resources>
<?xml version="1.0"?>
<SMTK_AttributeManager Version="1">
<Includes>
<File>AdHSurfaceWaterDefinitions.sbt</File>
<File>AdHSurfaceWaterViews.sbt</File>
<File>internal/AdHSurfaceWaterDefinitions.sbt</File>
<File>internal/AdHSurfaceWaterViews.sbt</File>
</Includes>
</SMTK_AttributeManager>
<SMTK_AttributeSystem Version="2">
<Definitions>
<AttDef Type="ExportSpec" BaseType="" Version="0" Unique="true">
<AssociationsDef Name="model" Label="Model" Version="0" NumberOfRequiredValues="1">
<MembershipMask>model</MembershipMask>
</AssociationsDef>
<ItemDefinitions>
<Directory Name="OutputDirectory" Label="Output Directory" Version="1" NumberOfRequiredValues="1" />
<String Name="FileBase" Label="FileName Base" Version="1" NumberOfRequiredValues="1">
<BriefDescription>Common base name for output files (.2dm, .bc)</BriefDescription>
<DefaultValue>shallowwater</DefaultValue>
</String>
<!-- Advanced attributes -->
<String Name="AnalysisTypes" Label="Analysis Types" AdvanceLevel="99" Version="0"
Extensible="true" NumberOfRequiredValues="1"/>
<MeshEntity Name="mesh" Label="Mesh" Version="0" NumberOfRequiredValues="1" />
<File Name="PythonScript" Label="Python script" AdvanceLevel="0" Version="0" NumberOfRequiredValues="1"
ShouldExist="true" FileFilters="Python files (*.py);;All files (*.*)">
<DefaultValue>AdHShallowWater.py</DefaultValue>
</File>
<!-- Hide Extrusion executable option until new ERDC code in place -->
<File Name="ExtrusionExecutable" Label="adh_2d_3d Executable" Version="0" NumberOfRequiredValues="1"
AdvanceLevel="99" ShouldExist="true"
Optional="true" IsEnabledByDefault="false"
FileFilters="All files (*.*)">
<DefaultValue>adh_2d_3d</DefaultValue>
</File>
</ItemDefinitions>
</AttDef>
</Definitions>
<Views>
<View Type="Instanced" Title="ExportSpec" TopLevel="true"
FilterByCategory="false">
<InstancedAttributes>
<Att Name="Export Specification" Type="ExportSpec">Options</Att>
</InstancedAttributes>
</View>
</Views>
</SMTK_AttributeSystem>
<SMTK_AttributeSystem Version="2">
<Definitions>
<AttDef Type="ExportSpec" BaseType="" Version="0" Unique="true">
<AssociationsDef Name="model" Label="Model" Version="0" NumberOfRequiredValues="1">
<MembershipMask>model</MembershipMask>
</AssociationsDef>
<ItemDefinitions>
<String Name="AnalysisTypes" Label="Analysis Types" AdvanceLevel="99" Version="0"
Extensible="true" NumberOfRequiredValues="1"/>
<MeshEntity Name="mesh" Label="Mesh" Version="0" NumberOfRequiredValues="1" />
<Directory Name="OutputDirectory" Label="Output Directory" Version="1" NumberOfRequiredValues="1" />
<String Name="FileBase" Label="FileName Base" Version="1" NumberOfRequiredValues="1">
<BriefDescription>Common base name for output files (.2dm, .bc)</BriefDescription>
<DefaultValue>surfacewater</DefaultValue>
</String>
<File Name="PythonScript" Label="Python script" AdvanceLevel="0" Version="0" NumberOfRequiredValues="1"
ShouldExist="true" FileFilters="Python files (*.py);;All files (*.*)">
<DefaultValue>AdHSurfaceWater.py</DefaultValue>
</File>
</ItemDefinitions>
</AttDef>
</Definitions>
<Attributes />
<Views>
<View Type="Instanced" Title="ExportSpec" TopLevel="true"
FilterByAdvanceLevel="false" FilterByCategory="false">
<InstancedAttributes>
<Att Name="Export Specification" Type="ExportSpec">Options</Att>
</InstancedAttributes>
</View>
</Views>
</SMTK_AttributeSystem>
<SMTK_AttributeManager Version="1">
<Definitions>
<AttDef Type="ExportSpec" BaseType="" Version="0" Unique="true">
<ItemDefinitions>
<File Name="OutputFile" Label="Output file" Version="0" NumberOfRequiredValues="1"
FileFilters="EMS files (*.ems);;All files (*.*)" />
<File Name="PythonScript" Label="Python script" Version="0" NumberOfRequiredValues="1"
AdvanceLevel="1" ShouldExist="true"
FileFilters="Python files (*.py);;All files (*.*)">
<DefaultValue>EMS.py</DefaultValue>
</File>
</ItemDefinitions>
</AttDef>
</Definitions>
<Attributes />
<RootView Title="Export">
<DefaultColor>1., 1., 0.5, 1.</DefaultColor>
<InvalidColor>1, 0.5, 0.5, 1</InvalidColor>
<AdvancedFontEffects Bold="0" Italic="0" />
<InstancedView Title="ExportSpec">
<InstancedAttributes>
<Att Type="ExportSpec">Options</Att>
</InstancedAttributes>
</InstancedView>
</RootView>
</SMTK_AttributeManager>
<?xml version="1.0"?>
<cmb-resources>
<attribute id="simbuilder" role="template">
<SMTK_AttributeManager Version="1">
<!--********** Category and Analysis Infomation ***********-->
<Categories Default="General"/>
<Analyses>
<Analysis Type="EMS" Default="General"/>
</Analyses>
<!--********** Attribute Definitions ***********-->
<Definitions>
<AttDef Type="Globals" BaseType="" Abstract="0" Version="0" Unique="false" Associations="">
<ItemDefinitions>
<!--*** Solvers Definitions ***-->
<Group Name="Solvers" Label="Solvers" NumberOfRequiredGroups="1">
<ItemDefinitions>
<Double Name="et_leak_rate" Label="et leak rate" Version="0" NumberOfRequiredValues="1">
<Categories