Skip to content

Commit

Permalink
Merge pull request #255 from spolti/sync
Browse files Browse the repository at this point in the history
Sync community with ODH
  • Loading branch information
openshift-merge-bot[bot] authored Nov 24, 2023
2 parents a14b7c8 + 1fa9f48 commit 2bc3e37
Show file tree
Hide file tree
Showing 17 changed files with 209 additions and 102 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '00 8 * * *'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'go', 'python' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
9 changes: 6 additions & 3 deletions .github/workflows/fvt.yml → .github/workflows/fvt-base.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: FVT
name: FVT Base

on:
workflow_dispatch:
Expand Down Expand Up @@ -94,6 +94,7 @@ jobs:
- name: Install ModelMesh Serving
run: |
export NAMESPACE_SCOPE_MODE=${{ inputs.namespace-scope-mode }}
kubectl create ns modelmesh-serving
./scripts/install.sh --namespace modelmesh-serving --fvt --dev-mode-logging
Expand Down Expand Up @@ -121,13 +122,15 @@ jobs:
run: |
eval $(minikube -p minikube docker-env)
docker images
kubectl get svc
kubectl get pods
kubectl get clusterservingruntimes
kubectl get clusterservingruntimes 2> /dev/null || :
kubectl get servingruntimes 2> /dev/null || :
- name: Run FVTs
run: |
go install github.com/onsi/ginkgo/v2/ginkgo
export PATH=/root/go/bin/:$PATH
export NAMESPACE=modelmesh-serving
export NAMESPACESCOPEMODE=false
export NAMESPACESCOPEMODE=${{ inputs.namespace-scope-mode }}
make fvt
22 changes: 22 additions & 0 deletions .github/workflows/fvt-cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: FVT Cluster Scope

on:
workflow_dispatch:
pull_request:
branches:
- main
- 'release-[0-9].[0-9]+'
paths:
- '**'
- '!.github/**'
- '!.tekton/**'
- '!**.md'
- '!docs/**'
- '.github/workflows/fvt*.yml'

jobs:
fvt-cluster-scope:
uses: ./.github/workflows/fvt-base.yml
with:
namespace-scope-mode: false
secrets: inherit
22 changes: 22 additions & 0 deletions .github/workflows/fvt-ns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: FVT Namespace Scope

on:
workflow_dispatch:
pull_request:
branches:
- main
- 'release-[0-9].[0-9]+'
paths:
- '**'
- '!.github/**'
- '!.tekton/**'
- '!**.md'
- '!docs/**'
- '.github/workflows/fvt*.yml'

jobs:
fvt-namespace-scope:
uses: ./.github/workflows/fvt-base.yml
with:
namespace-scope-mode: true
secrets: inherit
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# general
.env
.DS_Store
.run/
temp/

public/
target/
Expand Down Expand Up @@ -31,7 +33,7 @@ bin
.vscode
*~

# Modelmesh development related artifacts
# ModelMesh development related artifacts
devbuild
.develop_image_name
.dev/
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile.develop
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ ENV HOME=/root
WORKDIR /workspace

# Install build and dev tools
# NOTE: Require python38 to install pre-commit
RUN --mount=type=cache,target=/root/.cache/dnf:rw \
dnf install --setopt=cachedir=/root/.cache/dnf -y --nodocs \
python3 \
python3-pip \
nodejs \
jq \
python38 \
&& ln -sf /usr/bin/python3 /usr/bin/python \
&& ln -sf /usr/bin/pip3 /usr/bin/pip \
&& true

# Install pre-commit
ENV PIP_CACHE_DIR=/root/.cache/pip
RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install pre-commit
pip install pre-commit

# First download and extract older dist of kubebuilder which includes required etcd, kube-apiserver and kubectl binaries
# Then download and overwrite kubebuilder binary with desired/latest version
Expand Down
19 changes: 11 additions & 8 deletions Dockerfile.develop.ci
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ ENV HOME=/go
WORKDIR /go/src/github.com/opendatahub-io/modelmesh-serving/

# Install build and dev tools
RUN --mount=type=cache,target=${HOME}/.cache/dnf:rw \
dnf install --setopt=cachedir=${HOME}/.cache/dnf -y --nodocs \
python3 \
python3-pip \
# NOTE: Require python38 to install pre-commit
RUN --mount=type=cache,target=/root/.cache/dnf:rw \
dnf install --setopt=cachedir=/root/.cache/dnf -y --nodocs \
nodejs \
jq
jq \
python38 \
&& ln -sf /usr/bin/python3 /usr/bin/python \
&& ln -sf /usr/bin/pip3 /usr/bin/pip \
&& true

# Install pre-commit
ENV PIP_CACHE_DIR=${HOME}/.cache/pip
RUN --mount=type=cache,target=${HOME}/.cache/pip \
pip3 install pre-commit
ENV PIP_CACHE_DIR=/root/.cache/pip
RUN --mount=type=cache,target=/root/.cache/pip \
pip install pre-commit

# First download and extract older dist of kubebuilder which includes required etcd, kube-apiserver and kubectl binaries
# Then download and overwrite kubebuilder binary with desired/latest version
Expand Down
23 changes: 16 additions & 7 deletions controllers/hpa/hpa_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ func getHPAMetrics(metadata metav1.ObjectMeta) []hpav2.MetricSpec {
resourceName := corev1.ResourceCPU

if value, ok := annotations[constants.TargetUtilizationPercentage]; ok {
utilizationInt, _ := strconv.Atoi(value)
utilization = int32(utilizationInt)
if valueInt, err := strconv.ParseInt(value, 10, 32); err != nil {
log.Error(err, "Could not parse TargetUtilizationPercentage", "value", value)
} else {
utilization = int32(valueInt)
}
}

if value, ok := annotations[constants.AutoscalerMetrics]; ok {
Expand Down Expand Up @@ -90,13 +93,19 @@ func createHPA(runtimeMeta metav1.ObjectMeta, mmDeploymentName string, mmNamespa
annotations := runtimeMeta.Annotations

if value, ok := annotations[mmcontstant.MinScaleAnnotationKey]; ok {
minReplicasInt, _ := strconv.Atoi(value)
minReplicas = int32(minReplicasInt)

if valueInt, err := strconv.ParseInt(value, 10, 32); err != nil {
log.Error(err, "Could not parse MinScaleAnnotationKey", "value", value)
} else {
minReplicas = int32(valueInt)
}
}

if value, ok := annotations[mmcontstant.MaxScaleAnnotationKey]; ok {
maxReplicasInt, _ := strconv.Atoi(value)
maxReplicas = int32(maxReplicasInt)
if valueInt, err := strconv.ParseInt(value, 10, 32); err != nil {
log.Error(err, "Could not parse MaxScaleAnnotationKey", "value", value)
} else {
maxReplicas = int32(valueInt)
}
}

if maxReplicas < minReplicas {
Expand Down
9 changes: 5 additions & 4 deletions controllers/modelmesh/modelmesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,29 +265,30 @@ func (m *Deployment) addMMEnvVars(deployment *appsv1.Deployment) error {
}

if m.EnableAccessLogging {
// See https://github.com/kserve/modelmesh/blob/v0.11.0/src/main/java/com/ibm/watson/modelmesh/ModelMeshEnvVars.java#L55
// See https://github.com/kserve/modelmesh/blob/v0.11.1/src/main/java/com/ibm/watson/modelmesh/ModelMeshEnvVars.java#L55
if err := setEnvironmentVar(ModelMeshContainerName, "MM_LOG_EACH_INVOKE", "true", deployment); err != nil {
return err
}
}

if m.GrpcMaxMessageSize > 0 {
// See https://github.com/kserve/modelmesh/blob/v0.11.0/src/main/java/com/ibm/watson/modelmesh/ModelMeshEnvVars.java#L38
// See https://github.com/kserve/modelmesh/blob/v0.11.1/src/main/java/com/ibm/watson/modelmesh/ModelMeshEnvVars.java#L38
if err := setEnvironmentVar(ModelMeshContainerName, "MM_SVC_GRPC_MAX_MSG_SIZE", strconv.Itoa(m.GrpcMaxMessageSize), deployment); err != nil {
return err
}
}

// See https://github.com/kserve/modelmesh/blob/v0.11.0/src/main/java/com/ibm/watson/modelmesh/ModelMeshEnvVars.java#L31
// See https://github.com/kserve/modelmesh/blob/v0.11.1/src/main/java/com/ibm/watson/modelmesh/ModelMeshEnvVars.java#L31
if err := setEnvironmentVar(ModelMeshContainerName, "MM_KVSTORE_PREFIX", ModelMeshEtcdPrefix, deployment); err != nil {
return err
}
// See https://github.com/kserve/modelmesh/blob/v0.11.0/src/main/java/com/ibm/watson/modelmesh/ModelMeshEnvVars.java#L68
// See https://github.com/kserve/modelmesh/blob/v0.11.1/src/main/java/com/ibm/watson/modelmesh/ModelMeshEnvVars.java#L68
if err := setEnvironmentVar(ModelMeshContainerName, "MM_DEFAULT_VMODEL_OWNER", m.DefaultVModelOwner, deployment); err != nil {
return err
}

if len(m.PayloadProcessors) > 0 {
// See https://github.com/kserve/modelmesh/blob/v0.11.1/src/main/java/com/ibm/watson/modelmesh/ModelMeshEnvVars.java#L26
if err := setEnvironmentVar(ModelMeshContainerName, "MM_PAYLOAD_PROCESSORS", m.PayloadProcessors, deployment); err != nil {
return err
}
Expand Down
31 changes: 16 additions & 15 deletions docs/model-formats/openvino-ir.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## Format

Full documentation on OpenVINO IR format can be found [here](https://docs.openvino.ai/2022.1/openvino_docs_MO_DG_IR_and_opsets.html#intermediate-representation-used-in-openvino).
Full documentation on OpenVINO IR format can be found [here](https://docs.openvino.ai/2022.3/openvino_docs_MO_DG_IR_and_opsets.html#intermediate-representation-used-in-openvino).

OpenVINO™ toolkit introduces its own format of graph representation and its own operation set. A graph is represented with two files: an XML file and a binary file. This representation is commonly referred to as the Intermediate Representation or IR.

An example of a small IR XML file can be found in the same [link above](https://docs.openvino.ai/2022.1/openvino_docs_MO_DG_IR_and_opsets.html#intermediate-representation-used-in-openvino). The XML file doesn’t have big constant values, like convolution weights. Instead, it refers to a part of the accompanying binary file that stores such values in a binary format.
An example of a small IR XML file can be found in the same [link above](https://docs.openvino.ai/2022.3/openvino_docs_MO_DG_IR_and_opsets.html#intermediate-representation-used-in-openvino). The XML file doesn’t have big constant values, like convolution weights. Instead, it refers to a part of the accompanying binary file that stores such values in a binary format.

Models trained in other formats (Caffe, TensorFlow, MXNet, PaddlePaddle and ONNX) can be converted to OpenVINO IR format. To do so, use OpenVINO’s [Model Optimizer](https://docs.openvino.ai/2022.1/openvino_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html).
Models trained in other formats (Caffe, TensorFlow, MXNet, PaddlePaddle and ONNX) can be converted to OpenVINO IR format. To do so, use OpenVINO’s [Model Optimizer](https://docs.openvino.ai/2022.3/openvino_docs_MO_DG_Deep_Learning_Model_Optimizer_DevGuide.html).

## Configuration

Expand All @@ -20,7 +20,7 @@ Here is an example of client code:
input_tensorname = 'input'
request.inputs[input_tensorname].CopyFrom(make_tensor_proto(img, shape=(1, 3, 224, 224)))

.....
...

output_tensorname = 'resnet_v1_50/predictions/Reshape_1'
predictions = make_ndarray(result.outputs[output_tensorname])
Expand All @@ -46,21 +46,22 @@ More details on model configuration can be found [here](https://docs.openvino.ai

The OpenVINO models need to be placed and mounted in a particular directory structure:

```
```shell
tree models/

models/
├── model1
   ├── 1
   │   ├── ir_model.bin
   │   └── ir_model.xml
   └── 2
   ├── ir_model.bin
   └── ir_model.xml
├── 1
├── ir_model.bin
└── ir_model.xml
└── 2
├── ir_model.bin
└── ir_model.xml
└── model2
   └── 1
      ├── ir_model.bin
      ├── ir_model.xml
      └── mapping_config.json
└── 1
├── ir_model.bin
├── ir_model.xml
└── mapping_config.json
└── model3
└── 1
└── model.onnx
Expand Down
2 changes: 1 addition & 1 deletion docs/predictors/run-inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ This would give a response similar to the following:
{
"name": "predict",
"datatype": "FP32",
"shape": [1],
"shape": [1, 1],
"data": [8]
}
]
Expand Down
Loading

0 comments on commit 2bc3e37

Please sign in to comment.