Commit 0a39087a authored by John Tourtellott's avatar John Tourtellott

Update export template and operator to current cmb:master

* Rename ace3p-simulator.sbt to ACE3P.sbt
* Move resource definitions into sbt file (now version 3)
* No more ExportSpec object, but keeping ExportScope for now
* Drop/hide advance-level item (tailfile) - not showing in view,
  but kept operator disabled because it was not set)
* Minor change to girder_client
parent 1ab1cef8
......@@ -19,11 +19,10 @@ import sys
sys.dont_write_bytecode = True
import smtk
if 'pybind11' == smtk.wrappingProtocol():
#print 'Using pybind11 bindings'
import smtk.attribute
import smtk.model
import smtk.simulation
import smtk.attribute
import smtk.io
import smtk.model
#import smtk.simulation
# Add the directory containing this file to the python module search list
import inspect
......@@ -41,19 +40,8 @@ class Export(smtk.operation.Operation):
return "export ACE3P"
def operateInternal(self):
sim_attrs = smtk.attribute.Resource.CastTo(self.parameters().find('simulation').value())
exp_attrs = smtk.attribute.Resource.CastTo(self.parameters().find('export').value())
model_resource = smtk.model.Resource.CastTo(self.parameters().find('model resource').value())
sim_attrs.setRefModelResource(model_resource)
# create export spec object
spec = smtk.simulation.ExportSpec()
spec.setSimulationAttributes(sim_attrs)
spec.setExportAttributes(exp_attrs)
try:
success = ExportCMB(spec)
success = ExportCMB(self.parameters(), self.log)
except:
smtk.ErrorMessage(self.log(), sys.exc_info()[0])
return self.createResult(smtk.operation.Operation.Outcome.FAILED)
......@@ -65,18 +53,25 @@ class Export(smtk.operation.Operation):
def createSpecification(self):
spec = self.createBaseSpecification()
print 'spec:', spec
opDef = spec.createDefinition('test op', 'operation')
# Load export atts
source_dir = os.path.abspath(os.path.dirname(__file__))
print 'source_dir:', source_dir
sbt_path = os.path.join(source_dir, 'internal', 'ace3p-export.sbt')
print 'sbt_path:', sbt_path
reader = smtk.io.AttributeReader()
result = reader.read(spec, sbt_path, self.log())
print 'reader result:', result
simulationDef = smtk.attribute.ResourceItemDefinition.New('simulation')
# opDef = spec.createDefinition('test op', 'operation')
opDef = spec.findDefinition('ace3p-export')
simulationDef = smtk.attribute.ResourceItemDefinition.New('attributes')
simulationDef.setAcceptsEntries('smtk::attribute::Resource', '', True)
opDef.addItemDefinition(simulationDef)
exportDef = smtk.attribute.ResourceItemDefinition.New('export')
exportDef.setAcceptsEntries('smtk::attribute::Resource', '', True)
opDef.addItemDefinition(exportDef)
modelDef = smtk.attribute.ResourceItemDefinition.New('model resource')
modelDef = smtk.attribute.ResourceItemDefinition.New('model')
modelDef.setAcceptsEntries('smtk::model::Resource', '', True)
opDef.addItemDefinition(modelDef)
......@@ -89,40 +84,39 @@ class Export(smtk.operation.Operation):
ExportScope = type('ExportScope', (object,), dict())
# ---------------------------------------------------------------------
def ExportCMB(spec):
'''Entry function, called by CMB to write export files
def ExportCMB(operator_spec, log):
'''Entry function, called by operator to write export files
Returns boolean indicating success
Parameters
----------
spec: Top-level object passed in from CMB
spec: Attribute Resource specifying the export operation
'''
# print 'Enter ExportCMB()'
print 'Enter ExportCMB()', operator_spec, log
reload(utils)
# Initialize scope instance to store spec values and other info
scope = ExportScope()
scope.logger = spec.getLogger()
scope.sim_atts = spec.getSimulationAttributes()
scope.logger = log
scope.export_atts = operator_spec
scope.sim_atts = smtk.attribute.Resource.CastTo(operator_spec.find('attributes').value())
if scope.sim_atts is None:
msg = 'ERROR - No simlation attributes'
print msg
raise Exception(msg)
reload(utils)
utils.get_model_info(scope)
model_resource = smtk.model.Resource.CastTo(operator_spec.find('model').value())
if model_resource is None:
msg = 'ERROR - No model'
print msg
raise Exception(msg)
scope.model_manager = model_resource
scope.model_path = model_resource.location()
scope.model_file = os.path.basename(scope.model_path)
print 'scope.model_path %s' % scope.model_path
scope.export_atts = spec.getExportAttributes()
if scope.export_atts is not None:
att_list = scope.export_atts.findAttributes('ExportSpec')
if len(att_list) > 1:
msg = 'More than one ExportSpec instance -- ignoring all'
print 'WARNING:', msg
scope.logger.addWarning(msg)
return False
# (else)
export_spec_att = att_list[0]
export_spec_att = operator_spec
# Initialize solver list
solver_item = export_spec_att.findString('Analysis')
......
<?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">
<BriefDescription>
Write ACE3P input file for selected program.
</BriefDescription>
<DetailedDescription>
Todo
</DetailedDescription>
<ItemDefinitions>
<Resource Name="model" Label="Model">
<Accepts>
<Resource Name="smtk::model::Resource"/>
</Accepts>
</Resource>
<Resource Name="attributes" Label="Attributes">
<Accepts>
<Resource Name="smtk::attribute::Resource"/>
</Accepts>
</Resource>
<String Name="Analysis" Label="ACE3P Analysis" Version="0">
<ChildrenDefinitions>
<Directory Name="OutputFolder" Label="Export Folder" Version="0">
......@@ -126,9 +142,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 +225,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>
......@@ -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
......
......@@ -67,7 +67,8 @@ class CumulusClient():
#print 'user', user
user_id = user['_id']
r = self._client.listFolder(user_id, 'user', name='Private')
self._private_folder_id = r.next()['_id']
#self._private_folder_id = r.next()['_id']
self._private_folder_id = r[0]['_id']
print 'private_folder_id', self._private_folder_id
# ---------------------------------------------------------------------
......@@ -152,7 +153,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'
......
......@@ -222,9 +222,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()
......
......@@ -9,7 +9,7 @@ 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_ent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment