Anwendungspakete bei deklarativer Freigabe im Native Application Framework

As a provider, you create an application package to bundle your data content and notebooks into a Declarative Native App. This topic explains what an app package is and describes the high-level steps to create one, from creating the initial package to adding your manifest and notebook files.

The application package and the live version

The app package is a container for all the files that make up the app, including the manifest file and any Snowflake Notebooks. When you create an app package, a live (staged) version of the app package is also created. The live version is a development workspace where you can add or update files, such as the manifest file and notebook files, and preview and test the experience before publishing.

Once you’re satisfied with the live version of the app, you can commit the live version to create a new immutable version of the app package, that you can then publish.

Using the live version for development simplifies version management by maintaining a single immutable version of the app package that is ready to be published, and a single live version for development. The Snowflake Native App Framework automatically manages the versioning of the app package, so you don’t need to manually track version numbers.

The Snowflake Native App Framework maintains a live version for any app package automatically. Even if you remove the live version, a new live version is created automatically from the last committed version of the app package.

Anwendungspaket erstellen

Providers develop and test an application (app) package. An app package includes files necessary to share the data in the app, and defines how data can be accessed by consumers.

Dieser Prozess umfasst die folgenden Schritte:

  1. Create an app package project (first time only): creates an app package project that will later be published. This also creates the live version of the app package.

  2. Add content to the app package:

    1. Create or update a manifest file: This file describes the app package and its contents.

    2. Download notebook files. If notebooks are to be included, download a copy to be included in the app package.

    3. Add the files to the live version of the app package.

  3. Build the app package: allows you to verify that the manifest file is valid and that all links in the manifest file are correct.

  4. Test the app. Install the app and try it out. Make changes, and rebuild.

  5. Commit the app package: creates a new immutable version of the app that can be published.

  6. Release the app package. With a released package, you can create a new listing, either privately or publicly on the Snowflake Marketplace.

Dieser Prozess ist unter Tutorial: Erste Schritte mit Declarative Native Apps beschrieben. Dieser Abschnitt enthält zusätzliche Details zu den Optionen, die in den verschiedenen Phasen der Entwicklung verfügbar sind.

Das Diagramm zeigt die Schritte zur Erstellung eines Anwendungspakets: Fügen Sie Live-Paket, Build, Commit und Release hinzu. Das Diagramm zeigt auch die optionalen Schritte, die Sie überspringen können, um eine Live-Version auf einmal zu erstellen, zu committen und zu veröffentlichen.

Neues Anwendungspaket erstellen

First, create a new Declarative Native App package to hold the app’s files, either via Snowsight or SQL commands from Snowflake CLI, using the snow://package/<DECL_SHARE_APP_PKG>/versions/LIVE/ URL scheme.

So erstellen Sie mit Snowsight ein neues Anwendungspaket:

  1. Sign in to Snowsight.

  2. In the navigation menu, select Projects » App Packages.

  3. Wählen Sie auf der Share Data + Code-Kontokarte die Option Create.

  4. Geben Sie einen Namen für Ihr Anwendungspaket ein, und wählen Sie dann Create.

The new empty app package is created. This also creates a live version of the app package that you can edit.

Assemble content for the application package

An app package includes the following components:

  • A manifest file (required): A text-based file that defines the app’s structure.

  • Snowflake Notebook files (optional): One or more text-based files that can act as a front end to the consumer experience, referencing the shared views and tables. They can also include code, reference visualizations, and include logic to help present the data.

Diagramm der Komponenten des App-Pakets

Manifest-Datei erstellen oder aktualisieren

You can create or update a manifest file, which describes the app package and its shared content–for example, notebooks, tables, and views. It defines other metadata, such as app roles included with the app.

The manifest file must be named manifest.yml, and must be added to the root level of the app package.

Weitere Informationen dazu finden Sie unter Referenz zum Declarative Native App-Manifest. Das zugehörige Tutorial: Erste Schritte mit Declarative Native Apps enthält eine Beispiel-Manifest-Datei.

Create or update a manifest file from a Snowflake data share

Bemerkung

Der folgende Inhalt wird von Snowflake nicht unterstützt. Der gesamte Code wird „AS IS“ und ohne Garantie zur Verfügung gestellt.

Wenn Sie über eine bestehende Datenfreigabe in Snowflake verfügen, können Sie automatisch eine Manifest-Datei mit dem Open-Source-Tool „Manifest from Share“ erstellen. Dieses von Snowflake bereitgestellte Tool generiert eine Manifest-Datei auf der Grundlage der Objekte in einer angegebenen Freigabe. Das Tool enthält auch Optionen, um die generierte Manifest-Datei anzupassen. Sie können dieses Tool auf folgende Weise verwenden:

  • Generieren Sie eine Manifest-Datei mit der Befehlszeilenschnittstelle (CLI).

  • Integrieren Sie das Tool als Bibliothek in einen bestehenden Python-Automatisierungs-Workflow.

Weitere Informationen zum Herunterladen und Verwenden des Tools finden Sie unter `Snowflake-Manifest von Freigabe<https://github.com/snowflakedb/native-apps-examples/tree/main/snowflake-manifest-from-share-library>`_-Repository auf GitHub.

Bemerkung

Das Tool „Manifest from Share“ erstellt nur die Manifest-Datei unter Verwendung der Datenbanken, Schemas, Tabellen und Ansichten der Datenfreigabe. Das Tool fügt keine anderen Objekte in die generierte Manifest-Datei ein.

Notizbuchdateien abrufen

If Snowflake Notebooks are to be included in the app, download a copy of each notebook file so you can include it in the app package.

Über Snowsight:

  1. Wählen Sie im Navigationsmenü die Option Projects » Notebooks aus, und wählen Sie dann das Notizbuch aus, das Sie herunterladen möchten.

  2. In the left pane, next to your notebook, select » Download.

Die Datei wird auf Ihren lokalen Computer als Datei mit dem Namen <notebook_name>.ipynb heruntergeladen.

Bemerkung

Die Notizbuch-Umgebung verfügt über eine Reihe vorinstallierter Anaconda-Pakete, darunter Python und Streamlit. Wenn Ihr Notizbuch zusätzliche Anaconda-Pakete verwendet, müssen Sie diese als Pakete zu Ihrem Notizbuch hinzufügen, damit sie in der Umgebung des Verbrauchenden verwendet werden können. Informationen darüber, wie Sie Anaconda-Pakete zu Ihrem Notizbuch hinzufügen, finden Sie unter Add Anaconda packages to a notebook.

Add files to the live version

Add the manifest and notebook files to the live version of the app package:

So füllen Sie mithilfe von Snowsight das Anwendungspaket auf:

  1. If you’re not already viewing the app package’s listing, from the navigation menu, select Projects » App Packages, and then select the app package you want to add files to.

  2. Wählen Sie Upload files aus. (Wenn Sie Dateien ersetzen oder zusätzliche Dateien hinzufügen, wählen Sie Manage files und dann Upload files aus.)

  3. Ziehen Sie die Notizbuch-Dateien und das Manifest von Ihrer Festplatte in das Dialogfeld Upload files, falls angegeben, oder wählen Sie Browse, um die Dateien zu suchen und auszuwählen.

  4. Wählen Sie Upload aus, um die Dateien in den Live-Stagingbereich hochzuladen und einen Build auszulösen.

Download a file from the application package

Sie können eine Datei aus dem Anwendungspaket mit dem GET SQL-Befehl in Snowflake CLI herunterladen:

now sql -q "GET snow://package/<package_name>/versions/LIVE/manifest.yml file://manifest.yml"
Copy

Remove content from the application package

You can remove files from the application package.

Using Snowsight:

  1. If you’re not already viewing the app package’s listing, from the navigation menu, select Projects » App Packages, and then select the app package you want to remove files from.

  2. Wählen Sie Manage files » Remove files aus.

  3. Wählen Sie die Datei(en) aus, die Sie entfernen möchten, und wählen Sie dann Delete.

  4. Wählen Sie im Dialogfeld Remove files die zu entfernenden Dateien aus, und wählen Sie dann Remove & build aus.

Anwendungspaket erstellen

Als Nächstes erstellen Sie eine testbare Version der App.

In Snowsight:

  • Wenn Sie einen vollständigen Satz von Dateien in das Anwendungspaket hochladen, wird automatisch ein Build gestartet.

  • Um einen Build zu einem anderen Zeitpunkt auszuführen, wählen Sie die Schaltfläche „Build“ auf der Seite des Anwendungspakets aus.

If there are any errors in the manifest file, the build fails and gives information on how to fix the error. Correct the errors and rebuild the app package.

Die erstellte Anwendung bleibt im Live-Status, und Sie können weiterhin Änderungen am Anwendungspaket vornehmen.

Überspringen Sie!

For updates that don’t require further testing, you can skip ahead by building, committing, and releasing an app package all at once using the ALTER APPLICATION PACKAGE … RELEASE LIVE VERSION command.

ALTER APPLICATION PACKAGE <DECL_SHARE_APP_PKG> RELEASE LIVE VERSION;
Copy

Anwendung testen

After building the app package, you can perform basic tests on it from the live environment.

Install the app from an app package using the command: CREATE APPLICATION … FROM APPLICATION PACKAGE, replacing <DECL_SHARE_APP> with the name of the app. For example:

CREATE APPLICATION <DECL_SHARE_APP> FROM APPLICATION PACKAGE <DECL_SHARE_APP_PKG>
Copy

Update the files in the app package as needed, and then see if it worked by using the command: ALTER APPLICATION PACKAGE … UPGRADE USING VERSION LIVE.

ALTER APPLICATION PACKAGE <DECL_SHARE_APP_PKG> UPGRADE USING VERSION LIVE;
Copy

To test some features, such as app roles, you must first release a new version of the app package, and then test using a separate consumer account. For more information, see Declarative Native App installieren and Zugriff auf Inhalte in einer Declarative Native App.

Optional: Änderungen an einer Live-Version zurücksetzen

If the edits made to the live version of the app package are no longer needed, you can reset the app package to the state before the edits were made with the ALTER APPLICATION PACKAGE … ABORT LIVE VERSION command.

ALTER APPLICATION PACKAGE <DECL_SHARE_APP_PKG> ABORT LIVE VERSION;
Copy

When you use the preceding command to remove the current live version, a new live version is created with the same contents as the last committed version of the app package. The live version is reset to the last committed version, and all changes made to the live version are discarded.

Commit and release the application package

Committing the app package builds a new immutable version of the app that can’t be edited and is ready to be published. Releasing the app package does the following:

  • Stellt eine bestätigte App bereit, mit Verbrauchenden geteilt zu werden.

  • Wenn der Anbietende die App bereits für Verbrauchende freigegeben hat, steht diesen Verbrauchenden automatisch die neue Version zur Verfügung.

  • If there’s already a live version of the app on the Snowflake Marketplace, the new version is automatically available to consumers who have installed the app.

So übertragen Sie mit Snowsight das Anwendungspaket und geben es frei:

  1. If you’re not already viewing the app package’s listing, from the navigation menu, select Projects » App Packages, and then select the app package you want to release.

  2. Wählen Sie Commit & release aus.

  3. Wählen Sie im Bestätigungsdialog Acknowledge & continue aus.

The committed app package is released, and the live version of the app package is removed. A new live version of the app package is created from the new committed version for further development.

Sobald Sie für das Anwendungspaket ein Commit ausgeführt und freigegeben haben, wird auf der Registerkarte Latest release der Inhalt des Releases angezeigt, der mit dem Inhalt des letzten Builds übereinstimmt.

After you release the app package, you can create a new listing for the app, either privately or publicly on the Snowflake Marketplace. For more information, see Freigabeangebot mit deklarativer Freigabe erstellen.