From 734917a21d457ef7f3096fee6513f48f961492c1 Mon Sep 17 00:00:00 2001 From: Isabella Basso Date: Wed, 15 May 2024 11:54:59 -0300 Subject: [PATCH 1/3] py: update ruff config on pyproject (#92) Signed-off-by: Isabella Basso do Amaral --- clients/python/poetry.lock | 59 +++++++++++++++++------------------ clients/python/pyproject.toml | 18 +++++------ 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/clients/python/poetry.lock b/clients/python/poetry.lock index ac77917d..c79be0b1 100644 --- a/clients/python/poetry.lock +++ b/clients/python/poetry.lock @@ -455,13 +455,13 @@ protobuf = ["grpcio-tools (>=1.59.3)"] [[package]] name = "huggingface-hub" -version = "0.23.0" +version = "0.20.3" description = "Client library to download and publish models, datasets and other repos on the huggingface.co hub" optional = true python-versions = ">=3.8.0" files = [ - {file = "huggingface_hub-0.23.0-py3-none-any.whl", hash = "sha256:075c30d48ee7db2bba779190dc526d2c11d422aed6f9044c5e2fdc2c432fdb91"}, - {file = "huggingface_hub-0.23.0.tar.gz", hash = "sha256:7126dedd10a4c6fac796ced4d87a8cf004efc722a5125c2c09299017fa366fa9"}, + {file = "huggingface_hub-0.20.3-py3-none-any.whl", hash = "sha256:d988ae4f00d3e307b0c80c6a05ca6dbb7edba8bba3079f74cda7d9c2e562a7b6"}, + {file = "huggingface_hub-0.20.3.tar.gz", hash = "sha256:94e7f8e074475fbc67d6a71957b678e1b4a74ff1b64a644fd6cbb83da962d05d"}, ] [package.dependencies] @@ -474,17 +474,15 @@ tqdm = ">=4.42.1" typing-extensions = ">=3.7.4.3" [package.extras] -all = ["InquirerPy (==0.3.4)", "Jinja2", "Pillow", "aiohttp", "fastapi", "gradio", "jedi", "minijinja (>=1.0)", "mypy (==1.5.1)", "numpy", "pytest", "pytest-asyncio", "pytest-cov", "pytest-env", "pytest-rerunfailures", "pytest-vcr", "pytest-xdist", "ruff (>=0.3.0)", "soundfile", "types-PyYAML", "types-requests", "types-simplejson", "types-toml", "types-tqdm", "types-urllib3", "typing-extensions (>=4.8.0)", "urllib3 (<2.0)"] +all = ["InquirerPy (==0.3.4)", "Jinja2", "Pillow", "aiohttp", "gradio", "jedi", "mypy (==1.5.1)", "numpy", "pydantic (>1.1,<2.0)", "pydantic (>1.1,<3.0)", "pytest", "pytest-asyncio", "pytest-cov", "pytest-env", "pytest-rerunfailures", "pytest-vcr", "pytest-xdist", "ruff (>=0.1.3)", "soundfile", "types-PyYAML", "types-requests", "types-simplejson", "types-toml", "types-tqdm", "types-urllib3", "typing-extensions (>=4.8.0)", "urllib3 (<2.0)"] cli = ["InquirerPy (==0.3.4)"] -dev = ["InquirerPy (==0.3.4)", "Jinja2", "Pillow", "aiohttp", "fastapi", "gradio", "jedi", "minijinja (>=1.0)", "mypy (==1.5.1)", "numpy", "pytest", "pytest-asyncio", "pytest-cov", "pytest-env", "pytest-rerunfailures", "pytest-vcr", "pytest-xdist", "ruff (>=0.3.0)", "soundfile", "types-PyYAML", "types-requests", "types-simplejson", "types-toml", "types-tqdm", "types-urllib3", "typing-extensions (>=4.8.0)", "urllib3 (<2.0)"] +dev = ["InquirerPy (==0.3.4)", "Jinja2", "Pillow", "aiohttp", "gradio", "jedi", "mypy (==1.5.1)", "numpy", "pydantic (>1.1,<2.0)", "pydantic (>1.1,<3.0)", "pytest", "pytest-asyncio", "pytest-cov", "pytest-env", "pytest-rerunfailures", "pytest-vcr", "pytest-xdist", "ruff (>=0.1.3)", "soundfile", "types-PyYAML", "types-requests", "types-simplejson", "types-toml", "types-tqdm", "types-urllib3", "typing-extensions (>=4.8.0)", "urllib3 (<2.0)"] fastai = ["fastai (>=2.4)", "fastcore (>=1.3.27)", "toml"] -hf-transfer = ["hf-transfer (>=0.1.4)"] -inference = ["aiohttp", "minijinja (>=1.0)"] -quality = ["mypy (==1.5.1)", "ruff (>=0.3.0)"] +inference = ["aiohttp", "pydantic (>1.1,<2.0)", "pydantic (>1.1,<3.0)"] +quality = ["mypy (==1.5.1)", "ruff (>=0.1.3)"] tensorflow = ["graphviz", "pydot", "tensorflow"] -tensorflow-testing = ["keras (<3.0)", "tensorflow"] -testing = ["InquirerPy (==0.3.4)", "Jinja2", "Pillow", "aiohttp", "fastapi", "gradio", "jedi", "minijinja (>=1.0)", "numpy", "pytest", "pytest-asyncio", "pytest-cov", "pytest-env", "pytest-rerunfailures", "pytest-vcr", "pytest-xdist", "soundfile", "urllib3 (<2.0)"] -torch = ["safetensors", "torch"] +testing = ["InquirerPy (==0.3.4)", "Jinja2", "Pillow", "aiohttp", "gradio", "jedi", "numpy", "pydantic (>1.1,<2.0)", "pydantic (>1.1,<3.0)", "pytest", "pytest-asyncio", "pytest-cov", "pytest-env", "pytest-rerunfailures", "pytest-vcr", "pytest-xdist", "soundfile", "urllib3 (<2.0)"] +torch = ["torch"] typing = ["types-PyYAML", "types-requests", "types-simplejson", "types-toml", "types-tqdm", "types-urllib3", "typing-extensions (>=4.8.0)"] [[package]] @@ -984,7 +982,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -1042,28 +1039,28 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.1.15" +version = "0.4.4" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:5fe8d54df166ecc24106db7dd6a68d44852d14eb0729ea4672bb4d96c320b7df"}, - {file = "ruff-0.1.15-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6f0bfbb53c4b4de117ac4d6ddfd33aa5fc31beeaa21d23c45c6dd249faf9126f"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e0d432aec35bfc0d800d4f70eba26e23a352386be3a6cf157083d18f6f5881c8"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9405fa9ac0e97f35aaddf185a1be194a589424b8713e3b97b762336ec79ff807"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c66ec24fe36841636e814b8f90f572a8c0cb0e54d8b5c2d0e300d28a0d7bffec"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:6f8ad828f01e8dd32cc58bc28375150171d198491fc901f6f98d2a39ba8e3ff5"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86811954eec63e9ea162af0ffa9f8d09088bab51b7438e8b6488b9401863c25e"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fd4025ac5e87d9b80e1f300207eb2fd099ff8200fa2320d7dc066a3f4622dc6b"}, - {file = "ruff-0.1.15-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b17b93c02cdb6aeb696effecea1095ac93f3884a49a554a9afa76bb125c114c1"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ddb87643be40f034e97e97f5bc2ef7ce39de20e34608f3f829db727a93fb82c5"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:abf4822129ed3a5ce54383d5f0e964e7fef74a41e48eb1dfad404151efc130a2"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_i686.whl", hash = "sha256:6c629cf64bacfd136c07c78ac10a54578ec9d1bd2a9d395efbee0935868bf852"}, - {file = "ruff-0.1.15-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1bab866aafb53da39c2cadfb8e1c4550ac5340bb40300083eb8967ba25481447"}, - {file = "ruff-0.1.15-py3-none-win32.whl", hash = "sha256:2417e1cb6e2068389b07e6fa74c306b2810fe3ee3476d5b8a96616633f40d14f"}, - {file = "ruff-0.1.15-py3-none-win_amd64.whl", hash = "sha256:3837ac73d869efc4182d9036b1405ef4c73d9b1f88da2413875e34e0d6919587"}, - {file = "ruff-0.1.15-py3-none-win_arm64.whl", hash = "sha256:9a933dfb1c14ec7a33cceb1e49ec4a16b51ce3c20fd42663198746efc0427360"}, - {file = "ruff-0.1.15.tar.gz", hash = "sha256:f6dfa8c1b21c913c326919056c390966648b680966febcb796cc9d1aaab8564e"}, + {file = "ruff-0.4.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:29d44ef5bb6a08e235c8249294fa8d431adc1426bfda99ed493119e6f9ea1bf6"}, + {file = "ruff-0.4.4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:c4efe62b5bbb24178c950732ddd40712b878a9b96b1d02b0ff0b08a090cbd891"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4c8e2f1e8fc12d07ab521a9005d68a969e167b589cbcaee354cb61e9d9de9c15"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:60ed88b636a463214905c002fa3eaab19795679ed55529f91e488db3fe8976ab"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b90fc5e170fc71c712cc4d9ab0e24ea505c6a9e4ebf346787a67e691dfb72e85"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:8e7e6ebc10ef16dcdc77fd5557ee60647512b400e4a60bdc4849468f076f6eef"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b9ddb2c494fb79fc208cd15ffe08f32b7682519e067413dbaf5f4b01a6087bcd"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c51c928a14f9f0a871082603e25a1588059b7e08a920f2f9fa7157b5bf08cfe9"}, + {file = "ruff-0.4.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b5eb0a4bfd6400b7d07c09a7725e1a98c3b838be557fee229ac0f84d9aa49c36"}, + {file = "ruff-0.4.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b1867ee9bf3acc21778dcb293db504692eda5f7a11a6e6cc40890182a9f9e595"}, + {file = "ruff-0.4.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:1aecced1269481ef2894cc495647392a34b0bf3e28ff53ed95a385b13aa45768"}, + {file = "ruff-0.4.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:9da73eb616b3241a307b837f32756dc20a0b07e2bcb694fec73699c93d04a69e"}, + {file = "ruff-0.4.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:958b4ea5589706a81065e2a776237de2ecc3e763342e5cc8e02a4a4d8a5e6f95"}, + {file = "ruff-0.4.4-py3-none-win32.whl", hash = "sha256:cb53473849f011bca6e754f2cdf47cafc9c4f4ff4570003a0dad0b9b6890e876"}, + {file = "ruff-0.4.4-py3-none-win_amd64.whl", hash = "sha256:424e5b72597482543b684c11def82669cc6b395aa8cc69acc1858b5ef3e5daae"}, + {file = "ruff-0.4.4-py3-none-win_arm64.whl", hash = "sha256:39df0537b47d3b597293edbb95baf54ff5b49589eb7ff41926d8243caa995ea6"}, + {file = "ruff-0.4.4.tar.gz", hash = "sha256:f87ea42d5cdebdc6a69761a9d0bc83ae9b3b30d0ad78952005ba6568d6c022af"}, ] [[package]] @@ -1515,4 +1512,4 @@ hf = ["huggingface-hub"] [metadata] lock-version = "2.0" python-versions = ">= 3.9, < 3.11" -content-hash = "975c38bfedd5b1d11a9335aa245933ee8276c685573f772c0578c51ddef1f01a" +content-hash = "a980bbe90ca7c8b4b0e6172b388286497b6fc70d4a6f8d91ab0e91363e0daef1" diff --git a/clients/python/pyproject.toml b/clients/python/pyproject.toml index ee2aa94e..67ae15e1 100644 --- a/clients/python/pyproject.toml +++ b/clients/python/pyproject.toml @@ -31,7 +31,7 @@ pytest = "^7.4.2" coverage = { extras = ["toml"], version = "^7.3.2" } pytest-cov = "^4.1.0" sphinx-autobuild = "^2021.3.14" -ruff = "^0.1.6" +ruff = "^0.4.4" mypy = "^1.7.0" testcontainers = "^3.7.1" @@ -55,6 +55,9 @@ line-length = 119 [tool.ruff] target-version = "py39" +respect-gitignore = true + +[tool.ruff.lint] select = [ "F", # pyflakes # pycodestyle @@ -75,20 +78,15 @@ select = [ "SIM", # flake8-simplify "UP", # pyupgrade ] -respect-gitignore = true ignore = [ "D105", # missing docstring in magic method "E501", # line too long "S101", # use of assert detected ] +mccabe.max-complexity = 8 +per-file-ignores = { "tests/**/*.py" = [ + "D", # missing docstring in public module +] } [tool.ruff.lint.pydocstyle] convention = "google" - -[tool.ruff.per-file-ignores] -"tests/**/*.py" = [ - "D", # missing docstring in public module -] - -[tool.ruff.mccabe] -max-complexity = 8 From ee5ae40de7016eb643191ac8b9a9d182a8f875c7 Mon Sep 17 00:00:00 2001 From: Isabella Basso Date: Thu, 16 May 2024 07:18:44 -0300 Subject: [PATCH 2/3] GHA: test python client connection (#91) Signed-off-by: Isabella Basso do Amaral --- .github/workflows/build-image-pr.yml | 38 ++++-- test/python/test_mlmetadata.py | 176 --------------------------- test/python/test_mr_conn.py | 29 +++++ 3 files changed, 59 insertions(+), 184 deletions(-) delete mode 100644 test/python/test_mlmetadata.py create mode 100644 test/python/test_mr_conn.py diff --git a/.github/workflows/build-image-pr.yml b/.github/workflows/build-image-pr.yml index 3f30b981..ea9e53f5 100644 --- a/.github/workflows/build-image-pr.yml +++ b/.github/workflows/build-image-pr.yml @@ -2,14 +2,14 @@ name: Test container image build and deployment on: pull_request: paths-ignore: - - 'LICENSE*' - - '**.gitignore' - - '**.md' - - '**.txt' - - '.github/ISSUE_TEMPLATE/**' - - '.github/dependabot.yml' - - 'docs/**' - - 'clients/python/**' + - "LICENSE*" + - "**.gitignore" + - "**.md" + - "**.txt" + - ".github/ISSUE_TEMPLATE/**" + - ".github/dependabot.yml" + - "docs/**" + - "clients/python/docs/**" env: IMG_ORG: kubeflow IMG_REPO: model-registry @@ -61,3 +61,25 @@ jobs: kubectl wait --for=condition=available -n kubeflow deployment/model-registry-db --timeout=5m kubectl wait --for=condition=available -n kubeflow deployment/model-registry-deployment --timeout=5m kubectl logs -n kubeflow deployment/model-registry-deployment + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Upgrade pip + run: | + pip install --constraint=.github/workflows/constraints.txt pip + pip --version + - name: Install Poetry + run: | + pipx install --pip-args=--constraint=${{ github.workspace }}/.github/workflows/constraints.txt poetry + poetry --version + - name: Build package + working-directory: clients/python + run: | + poetry build --ansi + pip install dist/*.whl + - name: Connect with Python client + run: | + kubectl port-forward -n kubeflow service/model-registry-service 9090:9090 & + sleep 5 + python test/python/test_mr_conn.py localhost 9090 diff --git a/test/python/test_mlmetadata.py b/test/python/test_mlmetadata.py deleted file mode 100644 index 463f31d4..00000000 --- a/test/python/test_mlmetadata.py +++ /dev/null @@ -1,176 +0,0 @@ -from grpc import insecure_channel - -# from ml_metadata.metadata_store import metadata_store -from ml_metadata.proto import metadata_store_pb2 -from ml_metadata.proto import metadata_store_service_pb2 -from ml_metadata.proto import metadata_store_service_pb2_grpc - - -def main(): - # connection_config = metadata_store_pb2.ConnectionConfig() - # connection_config.sqlite.filename_uri = './metadata.sqlite' - # connection_config.sqlite.connection_mode = 3 # READWRITE_OPENCREATE - # store = metadata_store.MetadataStore(connection_config) - - # connection_config = metadata_store_pb2.ConnectionConfig() - # connection_config.mysql.host = 'localhost' - # connection_config.mysql.port = 3306 - # connection_config.mysql.database = 'mlmetadata' - # connection_config.mysql.user = 'root' - # connection_config.mysql.password = 'my-secret-pw' - # store = metadata_store.MetadataStore(connection_config, enable_upgrade_migration=True) - - channel = insecure_channel("localhost:8080") - store = metadata_store_service_pb2_grpc.MetadataStoreServiceStub(channel) - - # Create ArtifactTypes, e.g., Data and Model - data_type = metadata_store_pb2.ArtifactType() - data_type.name = "DataSet" - data_type.properties["day"] = metadata_store_pb2.INT - data_type.properties["split"] = metadata_store_pb2.STRING - - request = metadata_store_service_pb2.PutArtifactTypeRequest() - request.all_fields_match = True - request.artifact_type.CopyFrom(data_type) - response = store.PutArtifactType(request) - data_type_id = response.type_id - - model_type = metadata_store_pb2.ArtifactType() - model_type.name = "SavedModel" - model_type.properties["version"] = metadata_store_pb2.INT - model_type.properties["name"] = metadata_store_pb2.STRING - - request.artifact_type.CopyFrom(model_type) - response = store.PutArtifactType(request) - model_type_id = response.type_id - - request = metadata_store_service_pb2.GetArtifactTypeRequest() - request.type_name = "SavedModel" - response = store.GetArtifactType(request) - assert response.artifact_type.id == model_type_id - assert response.artifact_type.name == "SavedModel" - - # Query all registered Artifact types. - # artifact_types = store.GetArtifactTypes() - - # Create an ExecutionType, e.g., Trainer - trainer_type = metadata_store_pb2.ExecutionType() - trainer_type.name = "Trainer" - trainer_type.properties["state"] = metadata_store_pb2.STRING - - request = metadata_store_service_pb2.PutExecutionTypeRequest() - request.execution_type.CopyFrom(trainer_type) - response = store.PutExecutionType(request) - # trainer_type_id = response.type_id - - # # Query a registered Execution type with the returned id - # [registered_type] = store.GetExecutionTypesByID([trainer_type_id]) - - # Create an input artifact of type DataSet - data_artifact = metadata_store_pb2.Artifact() - data_artifact.uri = "path/to/data" - data_artifact.properties["day"].int_value = 1 - data_artifact.properties["split"].string_value = "train" - data_artifact.type_id = data_type_id - - request = metadata_store_service_pb2.PutArtifactsRequest() - request.artifacts.extend([data_artifact]) - response = store.PutArtifacts(request) - # data_artifact_id = response.artifact_ids[0] - - # # Query all registered Artifacts - # artifacts = store.GetArtifacts() - # - # # Plus, there are many ways to query the same Artifact - # [stored_data_artifact] = store.GetArtifactsByID([data_artifact_id]) - # artifacts_with_uri = store.GetArtifactsByURI(data_artifact.uri) - # artifacts_with_conditions = store.GetArtifacts( - # list_options=mlmd.ListOptions( - # filter_query='uri LIKE "%/data" AND properties.day.int_value > 0')) - # - # # Register the Execution of a Trainer run - # trainer_run = metadata_store_pb2.Execution() - # trainer_run.type_id = trainer_type_id - # trainer_run.properties["state"].string_value = "RUNNING" - # [run_id] = store.PutExecutions([trainer_run]) - # - # # Query all registered Execution - # executions = store.GetExecutionsByID([run_id]) - # # Similarly, the same execution can be queried with conditions. - # executions_with_conditions = store.GetExecutions( - # list_options = mlmd.ListOptions( - # filter_query='type = "Trainer" AND properties.state.string_value IS NOT NULL')) - # - # # Define the input event - # input_event = metadata_store_pb2.Event() - # input_event.artifact_id = data_artifact_id - # input_event.execution_id = run_id - # input_event.type = metadata_store_pb2.Event.DECLARED_INPUT - # - # # Record the input event in the metadata store - # store.put_events([input_event]) - # - # # Declare the output artifact of type SavedModel - # model_artifact = metadata_store_pb2.Artifact() - # model_artifact.uri = 'path/to/model/file' - # model_artifact.properties["version"].int_value = 1 - # model_artifact.properties["name"].string_value = 'MNIST-v1' - # model_artifact.type_id = model_type_id - # [model_artifact_id] = store.PutArtifacts([model_artifact]) - # - # # Declare the output event - # output_event = metadata_store_pb2.Event() - # output_event.artifact_id = model_artifact_id - # output_event.execution_id = run_id - # output_event.type = metadata_store_pb2.Event.DECLARED_OUTPUT - # - # # Submit output event to the Metadata Store - # store.PutEvents([output_event]) - # - # trainer_run.id = run_id - # trainer_run.properties["state"].string_value = "COMPLETED" - # store.PutExecutions([trainer_run]) - - # Create a ContextType, e.g., Experiment with a note property - experiment_type = metadata_store_pb2.ContextType() - experiment_type.name = "Experiment" - experiment_type.properties["note"] = metadata_store_pb2.STRING - request = metadata_store_service_pb2.PutContextTypeRequest() - request.context_type.CopyFrom(experiment_type) - response = store.PutContextType(request) - # experiment_type_id = response.type_id - - # # Group the model and the trainer run to an experiment. - # my_experiment = metadata_store_pb2.Context() - # my_experiment.type_id = experiment_type_id - # # Give the experiment a name - # my_experiment.name = "exp1" - # my_experiment.properties["note"].string_value = "My first experiment." - # [experiment_id] = store.PutContexts([my_experiment]) - # - # attribution = metadata_store_pb2.Attribution() - # attribution.artifact_id = model_artifact_id - # attribution.context_id = experiment_id - # - # association = metadata_store_pb2.Association() - # association.execution_id = run_id - # association.context_id = experiment_id - # - # store.PutAttributionsAndAssociations([attribution], [association]) - # - # # Query the Artifacts and Executions that are linked to the Context. - # experiment_artifacts = store.GetArtifactsByContext(experiment_id) - # experiment_executions = store.GetExecutionsByContext(experiment_id) - # - # # You can also use neighborhood queries to fetch these artifacts and executions - # # with conditions. - # experiment_artifacts_with_conditions = store.GetArtifacts( - # list_options = mlmd.ListOptions( - # filter_query=('contexts_a.type = "Experiment" AND contexts_a.name = "exp1"'))) - # experiment_executions_with_conditions = store.GetExecutions( - # list_options = mlmd.ListOptions( - # filter_query=('contexts_a.id = {}'.format(experiment_id)))) - - -if __name__ == "__main__": - main() diff --git a/test/python/test_mr_conn.py b/test/python/test_mr_conn.py new file mode 100644 index 00000000..5b8633e8 --- /dev/null +++ b/test/python/test_mr_conn.py @@ -0,0 +1,29 @@ +from model_registry import ModelRegistry + + +def main(server: str, port: int): + mr = ModelRegistry(server, port, author="test", is_secure=False) + + model = mr.register_model( + "my-model", + "https://mybucket.uri/", + version="2.0.0", + model_format_name="onnx", + model_format_version="1", + storage_key="my-data-connection", + storage_path="path/to/model", + metadata={ + "day": 1, + "split": "train", + }, + ) + + m = mr.get_registered_model("my-model") + assert m + assert model.id == m.id, f"{model} != {m}" + + +if __name__ == "__main__": + import sys + + main(sys.argv[1], int(sys.argv[2])) From efe499d5eb1ea7b80343390d5c190af688214a5f Mon Sep 17 00:00:00 2001 From: Matteo Mortari Date: Thu, 16 May 2024 14:31:44 +0200 Subject: [PATCH 3/3] chore: use ubi8/ubi-minimal:latest for security updates (#96) Signed-off-by: Matteo Mortari --- Dockerfile | 2 +- Dockerfile.odh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f94195a..fa1561d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,7 +38,7 @@ RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make clean model-registry # Use distroless as minimal base image to package the model-registry binary # Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8 +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest WORKDIR / # copy the registry binary COPY --from=builder /workspace/model-registry . diff --git a/Dockerfile.odh b/Dockerfile.odh index 86e2114b..e07f4088 100644 --- a/Dockerfile.odh +++ b/Dockerfile.odh @@ -25,7 +25,7 @@ RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 make clean/odh build/odh # Use distroless as minimal base image to package the model-registry binary # Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8 +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest WORKDIR / # copy the registry binary COPY --from=builder /workspace/model-registry .