...
Execution modes
User code can be run in mode:
...
Code Block |
---|
def actor_name(integer0, integer1, double0, double1, core_profiles0, core_profiles1, equilibrium0, exec_type='ctypesmpi_local', **kwargs mpi_process = 4, strip_output = True): |
Input arguments required by user C++/F method
...
- very long list of arguments it - it is easy to make a mistake:
- providing incorrect number of arguments
- it is easy to make a mistake providing incorrect order of arguments
- lack of important information, so many features are not handled:
- no debug mode
- MPI parameters - only number of nodes is specified
- no batch mode
Wrapper API - new design
Code Block |
---|
def actor_name(code_args = None, xml_parameters = None, job_settings = None):
return None.
# no returned values! |
Assumptions:
General:
- Python version 3.6+
- Programming conventions (PEP 8?)
- NO BACKWARD COMPATIBILITY
- Incompatibility with existing Python actors! - All input arguments (user method arg and info determining how to launch job ) 'structured' within classes
- Classes will be defined for:
- user code arguments - autogenerated
- XML input parameters
- diagnostic info
- execution modes
- return values - autogeneratedjob settings
- The order of arguments (classes) will be arbitrary - implemented as arguments list (*args) or keyword arguments list (**kwargs)
- All arguments (classes) will be optional. If object of given class will be not provided - default values will be used.
...
Arguments required by user C++/F method
Info |
---|
|
All code samples below use <ToolName> as a prefix of classes. Once we decide on the name, all the classes will contain it as a part of the name in each class that is not actor dependent. |
- All arguments 'packed' within a class <ActorName>Arguments
- Class will be automatically generated within , and copied to a wrapper package
- Order of attributes corresponds to order of user function arguments
- Every attribute is a class FC2PyArgument <ToolName>Argument keeping not only value but also metadata describing argument:
- Name
- Type of value
- Value
- IN or OUT
- Attributes' setters/getters will be overridden - user will set only value of argument
- To reduce complexity visible by user
- To check if arg type is correct
Code Block |
---|
|
# AUTO GENERATED !
class <ActorName>Arguments :
def __init__(self):
self.arg1 = <ToolName>Argument( 'InVar', int, None, IN)
self.arg2 = <ToolName>Argument( 'OutVar', double, None, OUT)
self.diagnostic_info = <ToolName>DiagnosticInfo()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class <ToolName>Argument :
def __init__(self, name, type, sub_type, intent):
self.name = name #'argument name' READ ONLY
self.type = type # (INT, DOUBLE, STRING, COMPLEX, IDS) READ ONLY
self.sub_type = sub_type #'equilibrium' for IDSes only READ ONLY
self.intent = intent # (IN/OUT) READ ONLY
self.value = 7. # to be set by user
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class <ToolName>DiagnosticInfo :
def __init__(self):
self.status
self.message |
XML parameters of user C++/F method
- Not passed as wrapper argument
- Defined (path to XML file) at the time of actor creation by FC2Py <ToolName>
...
- A class passed as wrapper arguments
- Tree (of classes) describing job settings
- FC2PyJobSettings class:
- batch_job - class FC2PyBatchJob:
- debug - class FC2PyDebug
- debugger - TotalView/gdb
- mode - attach/standalone
- mpi - class FC2PyMPI
- open_mp - class FC2PyOpenMP
- openMP parameters - TBD
- ???
- sandbox
- path to sandbox
- sandbox 'lifetime'
Wrapper outcome
class <ToolName>XMLParamaters :
def __init__(self):
self.parameters = # file name or string or... (?)
self.default_parameters = # file name or string or ... (?)
self.schema = # file name or string or ... (?) |
Job settings
Code Block |
---|
|
class <ToolName>JobSettings :
def __init__(self):
self.batch_job = <ToolName>BatchJob()
self.debug = <ToolName>Debug()
self.mpi = <ToolName>MPI()
self.open_mp = <ToolName>OpenMP()
self.sandbox = <ToolName>Sandbox()
self.????? #any other info needed?
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class <ToolName>BatchJob :
def __init__(self):
self.queue =
self.TBD
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class <ToolName>Debug :
def __init__(self):
self.debugger #TotalView/gdb
self.mode #attach/standalone
self.TBD
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class <ToolName>MPI :
def __init__(self):
self.TBD
self.debug_switch
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class <ToolName>OpenMP :
def __init__(self):
self.TBD
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
class <ToolName>Sandbox :
def __init__(self):
self.path
self.lifetime
self.TBD
|
Wrapper outcome
- To be discussed - PREFERRED: OUT arguments - wrapper will update fields of <ActorName>Arguments class
- Returned values - packed within a class:
- autogenerated
- a part of wrapper package
Open points
...
- https://www.python.org/dev/peps/pep-0008/
Example
Code Block |
---|
|
from my_test.wrapper import my_test_actor
# # # # # JOB SETTINGS # # # # # # #
job_settings = <ToolName>JobSettings()
#batch job
job_settings.batch_job.queue = 'gw_default"
#debugging
# no debugging for batch jobs
#mpi
job_settings.mpi.nodes = 5
#OpenMP
# it is not OpenMP job
# Sandbox
job_settings.sandbox.lifetime = LIFTIME_WORKFLOW
job_settings.sandbox.clean_up = True
# # # # # CODE ARGUMENTS # # # # # # #
arguments = <ActorName>Arguments()
self.my_in_arg_01.value = 5
self.my_in_arg_02.value = 0.123
self.my_in_core_profiles_01.value = in_cp_obj
self.my_in_core_profiles_02.value = in_cp_metadata #object keeping shot/run/user
# # # # # RUNNING ACTOR # # # # # # #
my_test(code_args = arguments, job_settings = job_settings)
# # # # # RETURN # # # # # # #
ret_eq = arguments.my_out_equilibrium_02.value |
Open points
...
- Only IN and OUT arguments (no INOUT arguments)
- Arrays as an inout of user method- only "dynamic" - i.e. of variable size
- Wrapper results:
- OUT arguments - wrapper will update fields of <ActorName>Arguments classReturned
- values - packed within a classINCOMPATIBILITY
- Diagnostic info
- Info returned from user method
- status flag
- user defined message
- 'Q: can it be mandatory in user sbrt?
- Sandbox:
- Do we need this feature?
- Alternative library:
- Do we need this feature?
...