canonical / data-science-stack

Stack with machine learning tools needed for local development.
Apache License 2.0
16 stars 6 forks source link

Exploration: how to write and test snaps? #23

Closed DnPlas closed 8 months ago

DnPlas commented 8 months ago

Why it needs to get done

We need to explore how snaps are written and tested before we can start creating one on our own. We need to gather enough information to start writing a snap for DSS.

Estimate 1D

What needs to get done

Explore the following:

When is the task considered done

When we have enough information to answer the questions presented above to get started with writing our first snap.

syncronize-issues-to-jira[bot] commented 8 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/KF-5331.

This message was autogenerated

DnPlas commented 8 months ago

From the Snapcraft overview guide, here are my findings:

  1. snapcraft (similar to rockcraft and charmcraft) allows you to build, publish, debug, test and version control snaps
  2. According to the snapcraft quickstart tour, a snap is a bundle of one or more applications that works without dependencies or modification across many Linux distributions; a containerised application if you will. [1]
  3. Snaps are built in three steps: (1) Identify all sw modules, libraries and packages that make up an application. This is written down in a yaml file. (2) Build the application using snapcraft. (3) Publish the application to the Snap Store (public).

For more details on how to actually write a snap, we can follow this guide.

  1. Snaps are built using plugins, parts, and interfaces that are defined in a snapcraft.yaml file. The snapcraft.yaml schema can be found here.

  2. Building a snap (the project) requires us to define top-level metadata with things like the base os, supported architechtures, etc; then a parts metadata where the application is built and its dependencies imported or added; and finally we can define interface metadata to connect external system resources to the application.

  3. Building the actual application is as easy as running snapcraft --debug in the same dir where the snap was initialised.

  4. For local testing, the snap install <snap file> can be used

  5. This guide provides better information about creating a snap step by step.

  6. There are confinement levels for snaps: a strict snap is a snap that runs in complete isolation with a minimum access level that can be considered safe; on the other hand classic snaps allow access to the system’s resources in much the same way traditional packages do. For the latter, manual reviews are needed.

  7. juju-wait is a familiar example.

References: [1] snaps intro [2] snapcraft overview [3] quickstart tour [4] creating a snap

DnPlas commented 8 months ago

More information:

From here I think we have enough information to start moving on with the first draft of the dss snap.

DnPlas commented 8 months ago

Closing this issue as we have captured all necessary information and we have a path to get us started.