Snowpark Migration Accelerator: SMA CLI-Anleitung¶
The Snowpark Migration Accelerator (SMA) helps developers migrate their Python or Scala Spark code to Snowpark. It analyzes your code and:
Bewertet die Kompatibilität mit Snowpark
Konvertiert kompatible Spark API-Aufrufe automatisch in Snowpark API
Identifiziert Code, der nicht automatisch konvertiert werden kann
Erstellt ein Inventar von Drittanbieter-Bibliotheksimporten aus Skripten und Notebooks
Erstellt einen bearbeitbaren Kompatibilitätsbericht, der Spark- und Snowpark-Code vergleicht
Snowflake hat eine Befehlszeilenschnittstelle (CLI) für den Snowpark Migration Accelerator (SMA) veröffentlicht. Diese Anleitung zeigt Ihnen, wie Sie CLI sowohl als eigenständiges Tool als auch innerhalb eines Skripts verwenden können.
Verwenden der CLI¶
You can download the Command Line Interface (CLI) from the Download and Access section. Select the version that matches your operating system. You can store the CLI in any accessible location on your machine or container.
Bemerkung
NOTE: Diese Schritt-für-Schritt-Anleitung verwendet zwar Screenshots von einem Mac-Computer, aber der Vorgang ist für Windows- und Linux-Benutzer ähnlich.
Nachdem Sie die Paketdatei heruntergeladen haben (Format .zip oder .tar), entpacken Sie den Inhalt. Das Befehlszeilenschnittstelle-Tool (CLI) befindet sich im Ordner „Orchestrator“ innerhalb der entpackten Dateien.
Öffnen Sie ein Terminal oder eine Eingabeaufforderung im Installationsordner und überprüfen Sie die Installation von CLI, indem Sie den folgenden Befehl ausführen, um die Version zu überprüfen:
./sma –version
Sie werden Ergebnisse sehen, die so aussehen:
The SMA Command Line Interface (CLI) is a local application that runs on your computer, similar to the SMA desktop application. To analyze your code files using the SMA CLI, these files must be stored on your local machine where the CLI can access them. The CLI supports the same file types as the regular SMA application. For a complete list of supported file types, refer to the supported filetypes in the SMA documentation.
Bemerkung
NOTE: To test the CLI functionality, you can use the sample codebase provided in the Assessment section or refer to the Conversion walkthroughs in the SMA documentation.
Die SMA-Dokumentation enthält eine vollständige Liste der CLI-Argumente. Lassen Sie uns in diesem Abschnitt die wichtigsten davon näher betrachten.
The SMA CLI runs in Conversion mode by default, rather than Assessment mode. To run the CLI in assessment mode, use the -a argument. For conversion operations, you’ll need a valid access code. To verify if you have a valid access code, use the following command:
Um eine Konvertierung durchzuführen, müssen Sie Folgendes angeben:
Eingabeverzeichnis (erforderlich)
Ausgabeverzeichnis (erforderlich)
Wenn Sie noch keine Projektdatei erstellt haben, müssen Sie auch diese angeben:
E-Mail des Benutzers
Name der Organisation
Name des Projekts
Sobald Sie diese Parameter zum ersten Mal eingerichtet haben, müssen Sie für künftige Konvertierungen nur noch die Verzeichnisse für die Eingabe und die Ausgabe angeben.
Dieser Bildschirm zeigt eine Zusammenfassung Ihrer Ausführungseinstellungen an und fordert Sie auf zu bestätigen, ob Sie fortfahren möchten.
Um die Bestätigungsaufforderung zu überspringen, fügen Sie den Parameter –yes oder -y hinzu. Dies ist besonders wichtig, wenn Sie CLI über automatisierte Skripte ausführen.
Das Tool liefert während seiner Ausführung detaillierte Fortschrittsinformationen.
While the tool is running, it will continuously print output to the screen. When the process is complete, you will see the prompt again. The tool generates detailed output that includes all processes, issues, and completed or failed steps. You don’t need to read through all of this information while it’s running, as you can review it later in the Logs output folder.
Anzeigen der Ausgabe¶
Die SMA CLI erstellt die gleiche Ausgabe wie die SMA-Anwendung. Wenn Sie das Tool ausführen, erstellt es drei Ordner in dem von Ihnen angegebenen Verzeichnis für die Ausgabe:
For detailed guidance on working with code that has been converted by the Snowpark Migration Accelerator (SMA), refer to the conversion walkthrough.
Using the Workspace Estimator¶
The SMA CLI includes a Workspace Estimator verb (we or workspace-estimator) that connects to a Databricks workspace, extracts metadata such as clusters, jobs, and runs, and optionally uploads the results to Snowflake for analysis.
Command hierarchy¶
The Workspace Estimator currently supports Databricks workspaces through the dbx subcommand. Running sma we dbx without a subcommand displays help listing the available subcommands:
sma we dbx run– Runs both extraction and upload in a single invocation.sma we dbx extract– Extracts workspace metadata to a local.zipfile only.sma we dbx upload– Uploads a previously extracted.zipfile to Snowflake.
Authentication¶
A Databricks Personal Access Token (PAT) is required for extraction. You can supply it in one of two ways:
Pass it directly with
-t/--token.Set the
SMA_DBX_TOKENenvironment variable. If--tokenis omitted, the CLI defaults to this variable.
Running extraction and upload together¶
When you provide all required options to sma we dbx run, the CLI extracts workspace metadata and uploads the resulting .zip file in a single step.
The following table lists the available options for sma we dbx run:
Option |
Short |
Required |
Default |
Description |
|---|---|---|---|---|
|
|
Yes |
– |
Databricks workspace URL (e.g. |
|
|
No |
|
Databricks Personal Access Token (PAT). |
|
|
No |
Current directory |
Directory where the extraction |
|
|
Yes |
– |
Logical name for the workspace. Cannot be empty or whitespace. |
|
|
No |
30 |
Number of days to look back for cluster events (15, 30, or 60). |
|
– |
No |
Information |
Minimum log level for diagnostic output (Trace, Debug, Information, Warning, Error, Critical). |
|
|
Yes |
– |
Company name for this estimation. Cannot be empty or whitespace. |
|
|
Yes |
– |
Email of the person performing the estimation. Must be a valid email address. |
Running extraction only¶
To extract workspace metadata without uploading, use the extract subcommand. This produces a .zip file in the specified output directory.
The extract subcommand accepts the same options listed in the run table above except --company-name and --email, which are only required for upload.
Uploading a previously extracted file¶
If you have already extracted workspace metadata to a .zip file, you can upload it separately using the upload subcommand.
The following table lists the available options for sma we dbx upload:
Option |
Short |
Required |
Default |
Description |
|---|---|---|---|---|
|
|
Yes |
– |
Path to an existing |
|
|
Yes |
– |
Company name for this estimation. Cannot be empty or whitespace. |
|
|
Yes |
– |
Email of the person performing the estimation. Must be a valid email address. |
|
|
Yes |
– |
Logical name for the workspace. Cannot be empty or whitespace. |
|
– |
No |
Information |
Minimum log level for diagnostic output (Trace, Debug, Information, Warning, Error, Critical). |
Programmatische CLI-Ausführung¶
Demnächst verfügbar! Das Team von SMA stellt Ihnen ein Skript zur Verfügung, mit dem Sie die SMA-Befehlszeilenschnittstelle (CLI) automatisch in mehreren Verzeichnissen ausführen können.
Try out the Command Line Interface (CLI) today. If you need help or have questions, contact the Snowpark Migration Accelerator team at sma-support@snowflake.com.