BlueprintConverter#

class datarobotx.BlueprintConverter#

Inherited attributes:

CATEGORICAL_COLUMN_TEMPLATE

DEFAULT_IMPORTS

STANDARD_INPUT_TEMPLATE

Methods:

build_blueprint_imports(stages)

rtype:

List[str]

build_preprocessor_pipeline(stages, ...)

Build a preprocessor pipeline from blueprint stages.

construct_stage_input_paths(stages, ...)

rtype:

List[List[str]]

convert(blueprint_json)

Convert a blueprint to an open source representation block of code.

convert_blueprint_class_to_open_representation(...)

rtype:

Tuple[str, str, Union[str, List[str], None]]

extract_dr_class_params_from_blueprint_parts(...)

Extract the input parameters and values from the blueprint class representation.

extract_element_from_stage(stage)

rtype:

Tuple[str, str]

extract_estimator_inputs(blueprint_json)

rtype:

Tuple[List[str], str]

extract_stages(blueprint_json)

rtype:

Dict[str, StageDict]

parse_blueprint_stage(blueprint_stage)

Convert a stage of a blueprint to an open representation mapping.

Inherited methods:

__init__()

format_code_block_with_black(code_block)

rtype:

str

make_blueprint(blueprint_imports, ...)

Construct and format code to create a code representation of a blueprint.

make_column_transformer_element_from_pipeline(...)

Construct a column tranformer element from a pre-formatted transformer pipeline.

make_column_transformer_from_column_transformer_elements(...)

Return a Column Transformer representation from a pre-formatted transformer pipeline The transformer should be ultimately constructed from: make_column_transformer_element_from_pipeline_elements If starting from steps, see make_pipeline_elements_from_steps.

make_pipeline_elements_from_steps(pipeline_steps)

Build a string of pipeline elements from raw pipeline steps.

make_pipeline_from_pipeline_elements(...)

Return a Pipeline representation from a pre-formatted transformer pipeline element Elements should be created from steps with make_pipeline_elements_from_steps.

make_standard_template()

Construct a standard template for the top of the code.

classmethod build_preprocessor_pipeline(stages, stage_input_paths)#

Build a preprocessor pipeline from blueprint stages.

Return type:

List[str]

classmethod convert(blueprint_json)#

Convert a blueprint to an open source representation block of code.

Parameters:

blueprint_json (Union[BlueprintJson, str]) – A json formatted dictionary of a datarobot blueprint. Can be retrieved using the datarobot API. This can also be passed as the string that represents the json formatted dictionary directly.

Return type:

str

static extract_dr_class_params_from_blueprint_parts(blueprint_parts)#

Extract the input parameters and values from the blueprint class representation.

Return type:

Dict[str, str]

classmethod make_blueprint(blueprint_imports, preprocessor_pipeline, estimator_element)#

Construct and format code to create a code representation of a blueprint.

Parameters:
  • blueprint_imports (list[str]) – List of imports that should be added to the header

  • preprocessor_pipeline (list[str]) – Column Transformer code string. See make_column_transformer_from_pipeline

  • estimator_element (Tuple[str, str]) – A tuples represented as (estimator_name, estimator_action). The step_action can either be a class call (e.g. sklearn.impute.SimpleImputer()) or “passthrough”. The step_action is typically generated by the MappingObject.get_open_representation() function.

Return type:

str

classmethod make_column_transformer_element_from_pipeline(transformer_name, transformer_pipeline, transformer_columns=None)#

Construct a column tranformer element from a pre-formatted transformer pipeline.

Pipeline should be created from steps with: make_pipeline_elements_from_steps and make_pipeline_from_pipeline_elements

Return type:

str

static make_column_transformer_from_column_transformer_elements(column_transformer_elements)#

Return a Column Transformer representation from a pre-formatted transformer pipeline The transformer should be ultimately constructed from: make_column_transformer_element_from_pipeline_elements If starting from steps, see make_pipeline_elements_from_steps.

Return type:

str

static make_pipeline_elements_from_steps(pipeline_steps, reverse=False, index=None)#

Build a string of pipeline elements from raw pipeline steps.

Parameters:
  • pipeline_steps (List[Tuple[str, str]]) – A list of tuples, where each tuple is (step_name, step_action). The step_action can either be a class call (e.g. sklearn.impute.SimpleImputer()) or “passthrough”. The step_action is typically generated by the MappingObject.get_open_representation() function.

  • reverse (bool) – Reverse the list. If steps are added from last to first, this should be set to True so that the final pipeline is in the correct direction.

Return type:

str

static make_pipeline_from_pipeline_elements(pipeline_element_str)#

Return a Pipeline representation from a pre-formatted transformer pipeline element Elements should be created from steps with make_pipeline_elements_from_steps.

Return type:

str

classmethod make_standard_template()#

Construct a standard template for the top of the code.

Return type:

str

classmethod parse_blueprint_stage(blueprint_stage)#

Convert a stage of a blueprint to an open representation mapping.

Return type:

StageDict