Skip to content

Commit

Permalink
Merge pull request #93 from tarilabs/tarilabs-20240711-sync
Browse files Browse the repository at this point in the history
periodic sync upstream KF to midstream ODH
  • Loading branch information
openshift-merge-bot[bot] authored Jul 11, 2024
2 parents 3cf62c8 + 5780826 commit e382520
Show file tree
Hide file tree
Showing 219 changed files with 27,070 additions and 2,485 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-image-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ jobs:
pip install dist/*.whl
- name: Connect with Python client
run: |
kubectl port-forward service/modelregistry-sample 9090:9090 &
kubectl port-forward service/modelregistry-sample 8080:8080 &
sleep 5
python test/python/test_mr_conn.py localhost 9090
python test/python/test_mr_conn.py http://localhost 8080
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.19"
go-version: '1.21'
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pip==23.3.1
nox==2023.04.22
nox-poetry==1.0.2
poetry==1.6.1
pip==23.3.2
nox==2023.4.22
nox-poetry==1.0.3
poetry==1.8.3
poetry-plugin-export==1.8.0
virtualenv==20.24.6
2 changes: 1 addition & 1 deletion .github/workflows/python-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ jobs:
strategy:
fail-fast: false
matrix:
python: ["3.10"]
python: ["3.12"]
session: [lint, tests, mypy, docs-build]
include:
- python: "3.9"
session: tests
- python: "3.10"
session: tests
- python: "3.11"
session: tests
env:
NOXSESSION: ${{ matrix.session }}
FORCE_COLOR: "1"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ bin/protoc-gen-go-grpc:

GOLANGCI_LINT ?= ${PROJECT_BIN}/golangci-lint
bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_BIN) v1.54.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_BIN) v1.59.1

GOVERTER ?= ${PROJECT_BIN}/goverter
bin/goverter:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Model registry provides a central repository for model developers to store and m
[![codecov](https://codecov.io/github/kubeflow/model-registry/graph/badge.svg?token=61URLQA3VS)](https://codecov.io/github/kubeflow/model-registry)

## Pre-requisites:
- go >= 1.19
- go >= 1.21
- protoc v24.3 - [Protocol Buffers v24.3 Release](https://github.com/protocolbuffers/protobuf/releases/tag/v24.3)
- npm >= 10.2.0 - [Installing Node.js and npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
- Java >= 11.0
Expand Down
36 changes: 36 additions & 0 deletions clients/python/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.PHONY: install
install:
../../bin/openapi-generator-cli generate -i ../../api/openapi/model-registry.yaml -g python -o src/ --package-name mr_openapi --additional-properties=library=asyncio,generateSourceCodeOnly=true,useOneOfDiscriminatorLookup=true
mv src/mr_openapi{_,/}README.md
git apply patches/*
poetry install

.PHONY: clean
clean:
rm -rf src/mr_openapi

.PHONY: test
test:
poetry run pytest -s

.PHONY: lint-check
lint-check:
poetry run ruff check
poetry run black src/mr_openapi --check

.PHONY: lint-apply
lint-apply:
poetry run ruff check --fix --unsafe-fixes || true
poetry run black src/mr_openapi

.PHONY: build
build: install lint-apply
poetry build

.PHONY: publish
publish: install
poetry publish --build -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD}

.PHONY: update
update:
poetry lock
52 changes: 11 additions & 41 deletions clients/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ This library provides a high level interface for interacting with a model regist
```py
from model_registry import ModelRegistry

registry = ModelRegistry("server-address", author="Ada Lovelace") # Defaults to a secure connection via port 443
registry = ModelRegistry("https://server-address", author="Ada Lovelace") # Defaults to a secure connection via port 443

# registry = ModelRegistry("server-address", 1234, author="Ada Lovelace", is_secure=False) # To use MR without TLS
# registry = ModelRegistry("http://server-address", 1234, author="Ada Lovelace", is_secure=False) # To use MR without TLS

model = registry.register_model(
"my-model", # model name
Expand All @@ -35,9 +35,9 @@ model = registry.register_model(

model = registry.get_registered_model("my-model")

version = registry.get_model_version("my-model", "v2.0")
version = registry.get_model_version("my-model", "2.0.0")

experiment = registry.get_model_artifact("my-model", "v2.0")
experiment = registry.get_model_artifact("my-model", "2.0.0")
```

### Importing from S3
Expand Down Expand Up @@ -103,51 +103,21 @@ There are caveats to be noted when using this method:
)
```

## Advanced use-cases

### Using Model Registry Python Client with newer Python versions (>=3.11)

> [!CAUTION]
> The mechanism described in this section is a temporary workaround and likely will never be supported.
> This workaround is ONLY applicable if your Python/Notebook project does NOT make use of MLMD directly or indirectly.

<!-- a longer-term plan to address this ties to the investigations to rebase this client on top of MR REST api directly,
so to avoid having to wrap the MLMD Wheel. See more: https://github.com/kubeflow/model-registry/pull/59 -->

This project _currently_ depends for internal implementations on the Google's [MLMD Python library](https://pypi.org/project/ml-metadata/).
Due to this dependency, this project supports [only the Python versions](https://github.com/kubeflow/model-registry/blob/8d77c13100c6cc5a9465d4293403114a3576fdd7/clients/python/pyproject.toml#L14) which are also available for the MLMD library (see more [here](https://pypi.org/project/ml-metadata/#files)).

As a workaround, **only IF your Python/Notebook project does NOT make use of MLMD directly or indirectly**,
you could opt-in to make use of a non-constrained variant of the MLMD dependency supporting _only_ remote gRPC calls (and not constrained by specific Python versions or architectures):

```
!pip install "https://github.com/opendatahub-io/ml-metadata/releases/download/v1.14.0%2Bremote.1/ml_metadata-1.14.0+remote.1-py3-none-any.whl" # need a Python 3.11 compatible version
!pip install --no-deps --ignore-requires-python --pre "model-registry" # ignore dependencies because of the above override
```

You can read more about this use-case, in the [Remote-only packaging of MLMD Python lib](https://github.com/kubeflow/model-registry/blob/main/docs/remote_only_packaging_of_MLMD_Python_lib.md) document.

## Development

Common tasks, such as building documentation and running tests, can be executed using [`nox`](https://github.com/wntrblm/nox) sessions.

Use `nox -l` to list sessions and execute them using `nox -s [session]`.

### Running Locally on Mac M1 or M2 (arm64 architecture)

If you want run tests locally you will need to set up a development environment, including docker engine; we recommend following the instructions [here](https://github.com/kubeflow/model-registry/blob/main/CONTRIBUTING.md#docker-engine).
Alternatively, use `make install` to setup a local Python virtual environment with `poetry`.

You will also have to change the package source to one compatible with ARM64 architecture. This can be actioned by uncommenting lines 14 or 15 in the pyproject.toml file. Run the following command after you have uncommented the line.
To run the tests you will need `docker` (or equivalent) and the `compose` extension command.
This is necessary as the test suite will manage a Model Registry server and an MLMD instance to ensure a clean state on
each run.
You can use `make test` to execute `pytest`.

```sh
poetry lock
```

Use the following commands to directly run the tests with individual test output. Alternatively you can use the nox session commands above.
### Running Locally on Mac M1 or M2 (arm64 architecture)

```sh
poetry install
poetry run pytest -v
```
Check out our [recommendations on setting up your docker engine](https://github.com/kubeflow/model-registry/blob/main/CONTRIBUTING.md#docker-engine) on an ARM processor.

<!-- github-only -->
Loading

0 comments on commit e382520

Please sign in to comment.