Teradata Package for Python Function Reference | 20.00 - deploy - Teradata Package for Python - Look here for syntax, methods and examples for the functions included in the Teradata Package for Python.

Teradata® Package for Python Function Reference - 20.00

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
March 2024
Language
English (United States)
Last Update
2024-04-10
dita:id
TeradataPython_FxRef_Enterprise_2000
Product Category
Teradata Vantage
teradataml.table_operators.Script.deploy = deploy(self, model_column, partition_columns=None, model_file_prefix=None)
DESCRIPTION:
    Function deploys the model generated after `execute_script()` in database or user
    environment in lake.
 
PARAMETERS:
    model_column:
        Required Argument.
        Specifies the column name in which model is present.
        Supported types of model in this column are CLOB and BLOB.
        Note:
            The column mentioned in this argument should be present in
            <apply_obj/script_obj>.result.
        Types: str
 
    partition_columns:
        Optional Argument.
        Specifies the columns on which data is partitioned.
        Note:
            The columns mentioned in this argument should be present in
            <apply_obj/script_obj>.result.
        Types: str OR list of str
 
    model_file_prefix:
        Optional Argument.
        Specifies the prefix to be used to the generated model file.
        If this argument is None, prefix is auto-generated.
        If the argument "model_column" contains multiple models and
            * "partition_columns" is None - model file prefix is appended with
              underscore(_) and numbers starting from one(1) to get model file
              names.
            * "partition_columns" is NOT None - model file prefix is appended
              with underscore(_) and unique values in partition_columns are joined
              with underscore(_) to generate model file names.
        Types: str
 
RETURNS:
    List of generated file names.
 
RAISES:
    TeradatamlException
 
EXAMPLES:
    >>> load_example_data("openml", "multi_model_classification")
 
    >>> df = DataFrame("multi_model_classification")
    >>> df
                   col2      col3      col4  label  group_column  partition_column_1  partition_column_2
    col1
    -1.013454  0.855765 -0.256920 -0.085301      1             9                   0                  10
    -3.146552 -1.805530 -0.071515 -2.093998      0            10                   0                  10
    -1.175097 -0.950745  0.018280 -0.895335      1            10                   0                  11
     0.218497 -0.968924  0.183037 -0.303142      0            11                   0                  11
    -1.471908 -0.029195 -0.166141 -0.645309      1            11                   1                  10
     1.082336  0.846357 -0.012063  0.812633      1            11                   1                  11
    -1.132068 -1.209750  0.065422 -0.982986      0            10                   1                  10
    -0.440339  2.290676 -0.423878  0.749467      1             8                   1                  10
    -0.615226 -0.546472  0.017496 -0.488720      0            12                   0                  10
     0.579671 -0.573365  0.160603  0.014404      0             9                   1                  10
 
    # Install Script file.
    >>> file_location = os.path.join(os.path.dirname(teradataml.__file__), "data", "scripts", "deploy_script.py")
    >>> install_file("deploy_script", file_location, replace=True)
 
    # Variables needed for Script execution.
    >>> script_command = '/opt/teradata/languages/Python/bin/python3 ./ALICE/deploy_script.py'
    >>> partition_columns = ["partition_column_1", "partition_column_2"]
    >>> columns = ["col1", "col2", "col3", "col4", "label",
                   "partition_column_1", "partition_column_2"]
    >>> returns = OrderedDict([("partition_column_1", INTEGER()),
                               ("partition_column_2", INTEGER()),
                               ("model", CLOB())])
 
    # Script execution.
    >>> obj = Script(data=df.select(columns),
                     script_command=script_command,
                     data_partition_column=partition_columns,
                     returns=returns
                     )
    >>> opt = obj.execute_script()
    >>> opt
    partition_column_1  partition_column_2               model                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    model
                    0                  10   b'gAejc1.....drIr'
                    0                  11   b'gANjcw.....qWIu'
                    1                  10   b'abdwcd.....dWIz'
                    1                  11   b'gA4jc4.....agfu'
    
    # Example 1: Provide only "partition_columns" argument. Here, "model_file_prefix" 
    #            is auto generated.
    >>> obj.deploy(model_column="model",
                   partition_columns=["partition_column_1", "partition_column_2"])
    >>> ['model_file_1710436227163427__0_10',
         'model_file_1710436227163427__1_10',
         'model_file_1710436227163427__0_11',
         'model_file_1710436227163427__1_11']
    
    # Example 2: Provide only "model_file_prefix" argument. Here, filenames are suffixed 
    #            with 1, 2, 3, ... for multiple models.
    >>> obj.deploy(model_column="model", model_file_prefix="my_prefix_new_")
    ['my_prefix_new__1',
     'my_prefix_new__2',
     'my_prefix_new__3',
     'my_prefix_new__4']
 
    # Example 3: Without both "partition_columns" and "model_file_prefix" arguments.
    >>> obj.deploy(model_column="model")
    ['model_file_1710438346528596__1',
     'model_file_1710438346528596__2',
     'model_file_1710438346528596__3',
     'model_file_1710438346528596__4']
    
    # Example 4: Provide both "partition_columns" and "model_file_prefix" arguments.
    >>> obj.deploy(model_column="model", model_file_prefix="my_prefix_new_", 
                   partition_columns=["partition_column_1", "partition_column_2"])
    ['my_prefix_new__0_10',
     'my_prefix_new__0_11',
     'my_prefix_new__1_10',
     'my_prefix_new__1_11']