I've got a configuration file for an application in the form of a python file containing a dict and I'm running an AWS lambda function to get this conf file from S3, change three variables in it and then push a copy back to S3. Is there any easy way to do this? A coworker said to try Jinja templating, but that seems limited to just HTML files?
Thanks
An example of the python config file is below. I need to change the "alpha" and "cycles" variables
import zutil
alpha = 2.13
cycles = 100
def my_transform(x, y, z):
v = [x, y, z]
v = zutil.rotate_vector(v, alpha, 0.0)
return {'v1': v[0], 'v2': v[1], 'v3': v[2]}
parameters = {
# units for dimensional quantities
'units': 'SI',
# reference state
'reference': 'IC_1',
'time marching': {
'unsteady': {
'total time': 1.0,
'time step': 1.0,
'order': 'second',
},
'scheme': {
'name': 'lu-sgs',
'stage': 1,
#'name' : 'runge kutta',
#'stage': 5,
},
'lu-sgs': {
'Number Of SGS Cycles': 8,
'Min CFL': 0.1,
'Max CFL': 5.0,
'Include Backward Sweep': True,
'Include Relaxation': True,
'Jacobian Update Frequency': 1,
'Jacobian Epsilon': 1.0e-08,
'CFL growth': 1.05,
'Use Rusanov Flux For Jacobian': 'true',
'Finite Difference Jacobian': 'false',
},
'multigrid': 10,
'cfl': 2.5,
'cfl transport': 2.5 * 0.5,
'ramp': {'initial': 1.0, 'growth': 1.1},
'cycles': cycles,
},
'equations': 'RANS',
'RANS': {
'order': 'euler_second',
'limiter': 'vanalbada',
'precondition': 'true',
'turbulence': {
'model': 'sst',
},
},
'material': 'air',
'air': {
'gamma': 1.4,
'gas constant': 287.0,
'Sutherlands const': 110.4,
'Prandtl No': 0.72,
'Turbulent Prandtl No': 0.9,
},
'IC_1': {
'temperature': 310.928,
'pressure': 101325.0,
'alpha': alpha, # User defined variable used for post processing
'V': {
'vector': zutil.vector_from_angle(alpha, 0.0),
'Mach': 0.85,
},
'Reynolds No': 5.0e6,
'Reference Length': 275.8,
'turbulence intensity': 1.e-4,
'eddy viscosity ratio': 0.1,
},
'BC_1': {
'ref': 7,
'type': 'symmetry',
},
'BC_2': {
'ref': 3,
'type': 'wall',
'kind': 'noslip',
},
'BC_3': {
'ref': 9,
'type': 'farfield',
'condition': 'IC_1',
'kind': 'riemann',
},
'write output': {
'format': 'vtk',
'surface variables': ['V', 'p', 'T', 'rho', 'walldist', 'yplus', 'mach', 'cp', 'eddy', 'pressureforce', 'frictionforce'],
'volume variables': ['V', 'p', 'T', 'rho', 'walldist', 'mach', 'cp', 'eddy'],
'frequency': 500,
},
'report': {
'frequency': 10,
'forces': {
'FR_1': {
'name': 'wall',
'zone': [9, 10, 11, 12, 13],
'transform': my_transform,
'reference area': 594720.0 * 0.5, # half model area # half model area # half model area
},
},
},
}