forked from red-hat-data-services/ods-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
843 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tests/Resources/CLI/ModelRegistry/samples/mysql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
186 changes: 186 additions & 0 deletions
186
ods_ci/tests/Resources/CLI/ModelRegistry/MRMS_TEST_RUNNER.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0c76fa56-07ef-4238-9f8b-faab2ad33f64", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"!pip install python-dotenv" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "62280df3-74a4-48d8-be64-5b4b73f0eb4b", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"!pip install --pre model-registry=='0.2.3a1'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9c27045c-68f7-423e-9f29-8b865fbe8388", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"from dotenv import load_dotenv\n", | ||
"load_dotenv(dotenv_path='istio.env')\n", | ||
"DOMAIN = os.getenv('DOMAIN')\n", | ||
"print(DOMAIN)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6e102db9-88c6-4a5e-92ad-57c2fb79c0c4", | ||
"metadata": { | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import subprocess\n", | ||
"TOKEN = subprocess.check_output([\"oc\",\"whoami\",\"-t\"]).decode('utf-8').strip()\n", | ||
"from model_registry import ModelRegistry\n", | ||
"os.environ[\"CERT\"] = \"domain.crt\"\n", | ||
"registry=ModelRegistry(\"https://modelregistry-sample-rest.PLACEHOLDER\", 443, author=\"Tony\", user_token=TOKEN)\n", | ||
" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "354a584a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"registeredmodel_name = \"mnist\"\n", | ||
"version_name = \"v0.1\"\n", | ||
"\n", | ||
"rm = registry.register_model(\n", | ||
" registeredmodel_name,\n", | ||
" \"https://github.com/tarilabs/demo20231212/raw/main/v1.nb20231206162408/mnist.onnx\",\n", | ||
" model_format_name=\"onnx\",\n", | ||
" model_format_version=\"1\",\n", | ||
" version=version_name,\n", | ||
" description=\"lorem ipsum minst 1\",\n", | ||
" metadata={\n", | ||
" \"accuracy\": 3.14,\n", | ||
" \"license\": \"apache-2.0\"\n", | ||
" }\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "678a3392", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"registeredmodel_name = \"mnist\"\n", | ||
"version_name = \"v0.2\"\n", | ||
"\n", | ||
"rm = registry.register_model(\n", | ||
" registeredmodel_name,\n", | ||
" \"https://github.com/tarilabs/demo20231212/raw/main/v1.nb20231206162408/mnist.onnx\",\n", | ||
" model_format_name=\"onnx\",\n", | ||
" model_format_version=\"2\",\n", | ||
" version=version_name,\n", | ||
" description=\"lorem ipsum minst 2\",\n", | ||
" metadata={\n", | ||
" \"accuracy\": 3.14,\n", | ||
" \"license\": \"apache-2.0\"\n", | ||
" }\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "bd3ac694", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"model = registry.get_registered_model(\"mnist\")\n", | ||
"model" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "63ecc47a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"version = registry.get_model_version(\"mnist\", \"v0.1\")\n", | ||
"version" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "14f6796f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"version = registry.get_model_version(\"mnist\", \"v0.2\")\n", | ||
"version" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "35f3b2d8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"experiment = registry.get_model_artifact(\"mnist\", \"v0.1\")\n", | ||
"experiment" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e1ce5564", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"experiment = registry.get_model_artifact(\"mnist\", \"v0.2\")\n", | ||
"experiment" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3.9", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
24 changes: 24 additions & 0 deletions
24
ods_ci/tests/Resources/CLI/ModelRegistry/enable_rest_api_route.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: modelregistry.opendatahub.io/v1alpha1 | ||
kind: ModelRegistry | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: modelregistry | ||
app.kubernetes.io/instance: modelregistry-sample | ||
app.kubernetes.io/part-of: model-registry-operator | ||
app.kubernetes.io/managed-by: kustomize | ||
app.kubernetes.io/created-by: model-registry-operator | ||
name: modelregistry-sample | ||
spec: | ||
# TODO(user): Add fields here | ||
grpc: | ||
port: 9090 | ||
rest: | ||
port: 8080 | ||
serviceRoute: enabled | ||
mysql: | ||
host: model-registry-db | ||
database: model_registry | ||
username: mlmduser | ||
passwordSecret: | ||
name: model-registry-db | ||
key: database-password |
18 changes: 18 additions & 0 deletions
18
ods_ci/tests/Resources/CLI/ModelRegistry/generate_certs.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
DOMAIN=$1 | ||
mkdir -p certs | ||
# create CA cert | ||
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -subj "/O=modelregistry Inc./CN=$DOMAIN" -keyout certs/domain.key -out certs/domain.crt | ||
# create rest cert and private key | ||
echo "subjectAltName = DNS:modelregistry-sample-rest.$DOMAIN" > certs/modelregistry-sample-rest.domain.ext | ||
openssl req -out certs/modelregistry-sample-rest.domain.csr -newkey rsa:2048 -nodes -keyout certs/modelregistry-sample-rest.domain.key -subj "/CN=modelregistry-sample-rest/O=modelregistry organization" -addext "subjectAltName = DNS:modelregistry-sample-rest.$DOMAIN" | ||
openssl x509 -req -sha256 -days 365 -CA certs/domain.crt -CAkey certs/domain.key -set_serial 0 -in certs/modelregistry-sample-rest.domain.csr -out certs/modelregistry-sample-rest.domain.crt -extfile certs/modelregistry-sample-rest.domain.ext | ||
# create grpc cert and private key | ||
echo "subjectAltName = DNS:modelregistry-sample-grpc.$DOMAIN" > certs/modelregistry-sample-grpc.domain.ext | ||
openssl req -out certs/modelregistry-sample-grpc.domain.csr -newkey rsa:2048 -nodes -keyout certs/modelregistry-sample-grpc.domain.key -subj "/CN=modelregistry-sample-grpc/O=modelregistry organization" -addext "subjectAltName = DNS:modelregistry-sample-grpc.$DOMAIN" | ||
openssl x509 -req -sha256 -days 365 -CA certs/domain.crt -CAkey certs/domain.key -set_serial 0 -in certs/modelregistry-sample-grpc.domain.csr -out certs/modelregistry-sample-grpc.domain.crt -extfile certs/modelregistry-sample-grpc.domain.ext | ||
|
||
# create DB service cert and private key | ||
openssl req -out certs/model-registry-db.csr -newkey rsa:2048 -nodes -keyout certs/model-registry-db.key -subj "/CN=model-registry-db/O=modelregistry organization" | ||
openssl x509 -req -sha256 -days 365 -CA certs/domain.crt -CAkey certs/domain.key -set_serial 0 -in certs/model-registry-db.csr -out certs/model-registry-db.crt |
4 changes: 4 additions & 0 deletions
4
ods_ci/tests/Resources/CLI/ModelRegistry/samples/istio/components/authconfig-labels.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- op: replace | ||
path: /spec/istio/authConfigLabels | ||
value: | ||
security.opendatahub.io/authorization-group: default |
4 changes: 4 additions & 0 deletions
4
ods_ci/tests/Resources/CLI/ModelRegistry/samples/istio/components/example_istio.env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AUTH_PROVIDER=opendatahub-auth-provider | ||
ISTIO_INGRESS=ingressgateway | ||
REST_CREDENTIAL_NAME=modelregistry-sample-rest-credential | ||
GRPC_CREDENTIAL_NAME=modelregistry-sample-grpc-credential |
15 changes: 15 additions & 0 deletions
15
ods_ci/tests/Resources/CLI/ModelRegistry/samples/istio/components/istio_modelregistry.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: modelregistry.opendatahub.io/v1alpha1 | ||
kind: ModelRegistry | ||
metadata: | ||
name: modelregistry-sample | ||
spec: | ||
istio: | ||
authProvider: AUTH_PROVIDER | ||
authConfigLabels: {} | ||
gateway: | ||
domain: DOMAIN | ||
istioIngress: ISTIO_INGRESS | ||
rest: | ||
gatewayRoute: enabled | ||
grpc: | ||
gatewayRoute: enabled |
26 changes: 26 additions & 0 deletions
26
ods_ci/tests/Resources/CLI/ModelRegistry/samples/istio/components/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: kustomize.config.k8s.io/v1alpha1 | ||
kind: Component | ||
|
||
# Istio config patch | ||
patches: | ||
- path: istio_modelregistry.yaml | ||
- target: | ||
group: modelregistry.opendatahub.io | ||
version: v1alpha1 | ||
kind: ModelRegistry | ||
name: modelregistry-sample | ||
path: authconfig-labels.yaml | ||
|
||
# Config map and replacements to use istio.env for cluster specific config | ||
configMapGenerator: | ||
- envs: | ||
- istio.env | ||
files: | ||
- authconfig-labels.yaml | ||
name: modelregistry-sample-environment | ||
generatorOptions: | ||
disableNameSuffixHash: true | ||
replacements: | ||
- path: replacements.yaml | ||
|
||
#+kubebuilder:scaffold:manifestskustomizesamples |
32 changes: 32 additions & 0 deletions
32
ods_ci/tests/Resources/CLI/ModelRegistry/samples/istio/components/replacements.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# replacements from configmap using istio.env for cluster specific config | ||
- source: | ||
kind: ConfigMap | ||
name: modelregistry-sample-environment | ||
fieldPath: data.AUTH_PROVIDER | ||
targets: | ||
- select: | ||
apiVersion: modelregistry.opendatahub.io/v1alpha1 | ||
kind: ModelRegistry | ||
name: modelregistry-sample | ||
fieldPaths: | ||
- spec.istio.authProvider | ||
- source: | ||
kind: ConfigMap | ||
name: modelregistry-sample-environment | ||
fieldPath: data.DOMAIN | ||
targets: | ||
- select: | ||
kind: ModelRegistry | ||
name: modelregistry-sample | ||
fieldPaths: | ||
- spec.istio.gateway.domain | ||
- source: | ||
kind: ConfigMap | ||
name: modelregistry-sample-environment | ||
fieldPath: data.ISTIO_INGRESS | ||
targets: | ||
- select: | ||
kind: ModelRegistry | ||
name: modelregistry-sample | ||
fieldPaths: | ||
- spec.istio.gateway.istioIngress |
13 changes: 13 additions & 0 deletions
13
...sts/Resources/CLI/ModelRegistry/samples/istio/components/tls/istio_tls_modelregistry.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: modelregistry.opendatahub.io/v1alpha1 | ||
kind: ModelRegistry | ||
metadata: | ||
name: modelregistry-sample | ||
spec: | ||
istio: | ||
gateway: | ||
rest: | ||
tls: | ||
credentialName: REST_CREDENTIAL_NAME | ||
grpc: | ||
tls: | ||
credentialName: GRPC_CREDENTIAL_NAME |
12 changes: 12 additions & 0 deletions
12
ods_ci/tests/Resources/CLI/ModelRegistry/samples/istio/components/tls/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: kustomize.config.k8s.io/v1alpha1 | ||
kind: Component | ||
## Append samples of your project ## | ||
|
||
# Istio tls config patch | ||
patches: | ||
- path: istio_tls_modelregistry.yaml | ||
|
||
replacements: | ||
- path: tls-replacements.yaml | ||
|
||
#+kubebuilder:scaffold:manifestskustomizesamples |
21 changes: 21 additions & 0 deletions
21
ods_ci/tests/Resources/CLI/ModelRegistry/samples/istio/components/tls/tls-replacements.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# replacements from configmap using istio.env for cluster specific config | ||
- source: | ||
kind: ConfigMap | ||
name: modelregistry-sample-environment | ||
fieldPath: data.REST_CREDENTIAL_NAME | ||
targets: | ||
- select: | ||
kind: ModelRegistry | ||
name: modelregistry-sample | ||
fieldPaths: | ||
- spec.istio.gateway.rest.tls.credentialName | ||
- source: | ||
kind: ConfigMap | ||
name: modelregistry-sample-environment | ||
fieldPath: data.GRPC_CREDENTIAL_NAME | ||
targets: | ||
- select: | ||
kind: ModelRegistry | ||
name: modelregistry-sample | ||
fieldPaths: | ||
- spec.istio.gateway.grpc.tls.credentialName |
10 changes: 10 additions & 0 deletions
10
ods_ci/tests/Resources/CLI/ModelRegistry/samples/istio/mysql-tls/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
## Append samples of your project ## | ||
resources: | ||
- ../mysql | ||
|
||
components: | ||
- ../components/tls | ||
|
||
#+kubebuilder:scaffold:manifestskustomizesamples |
Oops, something went wrong.