sampo.api.gen_src

sampo.api.gen_src(file=None, template=None, params=None)

Generates SAMPO Run Configuration from an SRC file, SRC template text file, or template string. Supports multibyte Japanese characters when operating in Python 3.

Parameters
filestring or None

Path of a text file that is SRC syntax compliant.

templatestring or None

String object that is SRC template syntax compliant. Templates follow Jinja2 syntax. http://jinja.pocoo.org/docs/2.10/ If file is specified, this parameter is ignored.

paramsdict or None

Parameters to render on to templates. Newlines in string parameters are converted to spaces. If SRC base syntax is followed by file or template this parameter is ignored.

Returns
srcsampo.core.RunConfiguration

Examples

>>> from sampo.api import gen_src
>>> learn_src = gen_src(file=fabhmerg_learn.src)
>>> from sampo.api import gen_src
>>> learn_src_content = '''
... learn_1:
...    spd: fabhmerg.spd
...    type: learn
...    data_sources:
...         dl:
...            df: input_df
...            attr_schema: asd
... '''
>>> learn_src = gen_src(template=learn_src_content)
>>> from sampo.api import gen_src
>>> learn_src_templ = '''
... learn_1:
...    spd: fabhmerg.spd
...    type: learn
...    data_sources:
...         dl:
...            df: {{ df }}
...            attr_schema: {{ attr_schema }}
... '''
>>> src_param = {'df': input_df, 'attr_schema': asd}
>>> learn_src = gen_src(template=learn_src_templ, params=src_param)