[bitnami/tensorflow] chore: 👷 Add VIB integration (#52039)

* [bitnami/tensorflow] chore: 👷 Add VIB integration

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>

* test:  Add basic example

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>

---------

Signed-off-by: Javier Salmeron Garcia <jsalmeron@vmware.com>
This commit is contained in:
Javier J. Salmerón-García
2023-10-23 11:30:30 +02:00
committed by GitHub
parent dabca17d50
commit 6dd8c44163
5 changed files with 146 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
# Copyright VMware, Inc.
# SPDX-License-Identifier: APACHE-2.0
gossfile:
# Goss tests exclusive to the current container
../../tensorflow/goss/tensorflow.yaml: {}
# Load scripts from .vib/common/goss/templates
../../common/goss/templates/check-app-version.yaml: {}
../../common/goss/templates/check-binaries.yaml: {}
../../common/goss/templates/check-broken-symlinks.yaml: {}
../../common/goss/templates/check-ca-certs.yaml: {}
../../common/goss/templates/check-directories.yaml: {}
../../common/goss/templates/check-linked-libraries.yaml: {}
../../common/goss/templates/check-spdx.yaml: {}

View File

@@ -0,0 +1,15 @@
# Copyright VMware, Inc.
# SPDX-License-Identifier: APACHE-2.0
user:
tensorflow:
exists: true
uid: 1001
gid: 0
command:
basic-example:
exec: python ./tensorflow/goss/testfiles/basic_example.py
timeout: 120000
stdout:
- shape=(5, 10)
exit-status: 0

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env python3
# Taken from https://www.tensorflow.org/tutorials/quickstart/beginner
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10)
])
predictions = model(x_train[:1]).numpy()
tf.nn.softmax(predictions).numpy()
loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
loss_fn(y_train[:1], predictions).numpy()
model.compile(optimizer='adam',
loss=loss_fn,
metrics=['accuracy'])
model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test, verbose=2)
probability_model = tf.keras.Sequential([
model,
tf.keras.layers.Softmax()
])
print(probability_model(x_test[:5]))

View File

@@ -0,0 +1,10 @@
binaries:
- python
root_dir: /opt/bitnami
directories:
- paths:
# Paths to the client and server directories
- /opt/bitnami/python
version:
bin_name: python
flag: "-c 'import tensorflow; print(tensorflow.__version__)'"

View File

@@ -0,0 +1,66 @@
{
"context": {
"resources": {
"url": "{SHA_ARCHIVE}",
"path": "{VIB_ENV_PATH}"
},
"runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd"
},
"phases": {
"package": {
"actions": [
{
"action_id": "container-image-package",
"params": {
"application": {
"details": {
"name": "{VIB_ENV_CONTAINER}",
"tag": "{VIB_ENV_TAG}"
}
},
"architectures": ["linux/amd64", "linux/arm64"]
}
},
{
"action_id": "container-image-lint",
"params": {
"threshold": "error"
}
}
]
},
"verify": {
"actions": [
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib"
},
"tests_file": "tensorflow/goss/goss.yaml",
"vars_file": "tensorflow/goss/vars.yaml",
"remote": {
"pod": {
"workload": "deploy-tensorflow"
}
}
}
},
{
"action_id": "trivy",
"params": {
"threshold": "CRITICAL",
"vuln_type": ["OS"]
}
},
{
"action_id": "grype",
"params": {
"threshold": "CRITICAL",
"package_type": ["OS"]
}
}
]
}
}
}