Skip to content

Compute execution

ComputeExecutionMixin

exec_app staticmethod

exec_app(inner_app, map_values=None, map_objs=None, return_keys=None, keys_to_render=None, show_inner_app_results=True, allow_override=False)

Runs an application from the library given the inputs provided in map_values or map_objs which maps the resulting values from the objects already created. Use return_vars to map the variables created during the inner_app execution to new objects.

Parameters:

Name Type Description Default

inner_app

ModuleType

This is the app to be loaded as an instance into the app.

required

map_values

Dict[str, object] | None

Dictionary with the app's input arguments. e.g. {"fck":30, "fcm":50}. Default = None.

None

map_objs

Dict[str, str] | None

Map the to the . This can be useful if you have parameters in the host app that you want to map as inputs to the child app. Default = None.

None

return_keys

Dict[str, str] | None

Map the variable to a new after the inner app finished execution. e.g. {"fck_host": "fck_inner"} creates a copy of "fck_inner" from the inner app, and assigns it to a new variable "fck_host" in the host app. Default = None.

None

keys_to_render

List[str] | None

List with the variables (output) names to include in the report. If "None" all variable names will be rendered. If you want to exclude all output, enter and empty list. Default=None.

None

show_inner_app_results

bool

Show the calculations of the loaded app in the report. Default=True.

True

allow_override

bool

[DEPRECATED]

False

Returns:

Type Description
None

None

Examples:

1
2
3
4
5
6
cb.exec_app(
    inner_app=EC2_ConcreteProperties,
    map_values={"fck": 30},
    return_keys={"Ecm": "Ecm", "fcm":"fcm"},
    var_names_to_render=["fcm"]
)

run_batch staticmethod

run_batch(inner_app, df, keys_to_append)

Runs other applications within your app collection in a batch mode. The variables provided in the form of a pandas dataframe.

Parameters:

Name Type Description Default

inner_app

ModuleType

Provide the type of the app to be executed within this host app

required

df

Dataframe

Provide a dataframe of all the input variables required to execute the "inner_app". Each column should be named identically with the variable name. NB: Default variables will be used if not all the parameters are supplied in the dataframe.

required

keys_to_append

List[str]

Provide a list of strings that are the variable names generated when the "inner_app" is executed the resulting values are appended to the dataframe.

required

Returns:

Type Description
DataFrame

pd.Dataframe

Examples:

1
2
3
4
5
6
7
8
9
from apps.child_app import child_app
import pandas as pd

input_df = pd.DataFrame({"side": [1, 2, 3, 4, 5]})
cb.run_batch(
    inner_app=child_app,
    df=input_df,
    keys_to_append=["area"],
)