Using the SMA CLI

Programmatically assess and convert with the SMA CLI

Description

The Snowpark Migration Accelerator (SMA) has a Commond Line Interface (CLI). This CLI can be run using a series of commands that will execute the code processor, install/show an access code, and any other operation you can do from the SMA application.

Note that the SMA has one single code processor for the different supported source platforms. Note that you do not need to specify any arguments for this.

Installation

Before installing the CLI, you will need to download it to an accessible location. Depending on your operating system, you can review the corresponding installation guide:

Commands

To run the tool it needs to be set a sequence of commands according to your needs. To do that, use the following syntax using the long-command or short-command options:

sma [command] [argument] [command] [argument] ...

The available commands are listed below. Click on a command to see a detailed explanation.

Long-command
Short-Command
Description

-h

Show help information.

-v

Show the version of the tool.

install-ac

Install an access code.

show-ac

Show the installed access code(s).

-i

The input folder path

-o

The output folder path

-a

Add it to execute the tool in assessment mode.

-m

Folder path where the custom mapping files are stored.

-j

Flag to indicate if the conversion of Databricks notebooks to Jupyter is enabled or not.

-f

Database engine syntax to be used when a SQL command is detected.

-e

Configure the customer email.

-c

Configure the customer company.

-p

Configure the customer project.

-y

Skip asking for continue when running.

Installing an access code

Before converting your code, you need to install an access code. You can do this by specifying the access code, or by specifying the path to the file that contains the access code information (this is useful when installing the access code without an Internet connection or under restrictive firewall settings).

You can use the following command to install the access code by writing the code:

sma install-access-code <access-code>

This command is equivalent to the previous command:

sma install-ac <access-code>

If you want to install an access code using a file, you can use the --file / -f option, as shown in the following commands:

sma install-access-code --file <path-to-file>
or
sma install-access-code -f <path-to-file>

If there is an error during the license installation, an error is shown.

If you need an access code, you can reach out to sma-support@snowflake.com.

Checking which access codes are installed

If you want to know which access codes are installed on your computer, you can use the following command:

sma show-access-code

This command shows the information for each access code that is installed on your computer.

Converting

Once you installed a valid license, you can execute the code processor to perform a conversion. To do that you must provide the required arguments:

  • Input path: The folder path that contains the source code.

  • Output path: The folder path where the converted code is placed.

Project Information

There are some arguments required the first time you run the code processor (these values are saved for further executions). This is the same information that's required to create a new project in the application. The required fields are:

  • Customer Email: The customer email value ( you must add a valid mail )

  • Customer Company: the customer company.

  • Project Name: The name of the project.

This example shows how to run the code processor with the minimum requirements:

sma -i <input-path> -o <output-path> -e <client email> -c <client company> -p <project name> <additional-parameters>

Once you set the sequence of commands and hit "Enter", the tool shows the current configuration and prompts for confirmation to start the process:

If you need to add/modify any argument, you can type "n" to abort the process or "y" to start it.

Skipping the Project Confirmation

To skip the confirmation where the tools prompts you to continue (as shown above), you can add the argument --yes or -y. Note that if you are going to use this programmatially, this will be required. Without this parameter, the tool will prompt you to confirm that your information is correct with each execution.

For more information about all the additional parameters, please refer to the current link.

Performing an Assessment

When performing an assessment you can use the same commands that you would use for conversion, but you need to add the option --assessment or -a. The commands you would use would look like these:

sma --input <input-path> --output <output-path> --assessment <additional-parameters>

Each of these commands might also receive additional parameters (check the Converting section).

Checking the tool version

You can use any of the following commands to check the tool version and code-processing engine:

sma --version
sma -v

Enabling conversion of Databricks notebooks to Jupyter Notebooks

This option takes input .python and/or .scala files that are in the source directory, and instead of converting them to output .python and/or .scala files, it will convert them to .ipynb Jupyter Notebook files. Note that this does not take into account if the source file(s) were exported from a notebook or were standard code files.

To enable this conversion, you can add the flag command '--enableJupyter' or the shortcut '-j':

sma -i <input-path> -o <output-path> --enableJupyter

Setting the SQL Flavor of the source code

You can set the SQL syntax for use when a SQL command is detected; the command is '--sql' or the shortcut '-f'. the supported syntaxes are 'SparkSql' the default, and 'HiveSql'

sma --input <input-path> --output <output-path> --sql SparkSql
sma --input <input-path> --output <output-path> --sql HiveSql

Need more help?

If you want to see general help for the CLI, you can use the following commands:

sma --help
sma -h

You can get more information about some commands by executing this command:

sma <command> --help

For example, you can execute sma install-access-code --help to get more information about how to install an access code.

Last updated