Skip to content

Commit 8d48d2c

Browse files
authored
Move robot TC to pytest (kubeflow#1105)
* Translate robot TC to pytest Signed-off-by: lugi0 <[email protected]> * Update test to only use methods exposed directly by the client Signed-off-by: lugi0 <[email protected]> --------- Signed-off-by: lugi0 <[email protected]>
1 parent 8e3e6a5 commit 8d48d2c

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

clients/python/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,35 @@ Check out our [recommendations on setting up your docker engine](https://github.
362362

363363
### Troubleshooting
364364

365-
- On running `make test test-e2e` if you see a similar problem `unknown flag: --load`, install [buildx](https://formulae.brew.sh/formula/docker-buildx)
365+
- On running `make test test-e2e` if you see a similar problem `unknown flag: --load`, install [buildx](https://formulae.brew.sh/formula/docker-buildx). You will then need to add `cliPluginsExtraDirs` to ~/.docker/config.json, like so:
366+
```
367+
"cliPluginsExtraDirs": [
368+
"/opt/homebrew/lib/docker/cli-plugins" # depending on your system config, brew should give you the proper one
369+
]
370+
```
371+
Before running make, ensure docker is running (`docker ps -a`). If it's not, assuming you're using `colima` on macos, run
372+
`colima start`.
373+
374+
- On running `make test-e2e` you might see an error similar to
375+
```
376+
102.7 /workspace/bin/golangci-lint run cmd/... internal/... ./pkg/... --timeout 3m
377+
124.6 make: *** [Makefile:243: lint] Killed
378+
------
379+
Dockerfile:60
380+
--------------------
381+
58 |
382+
59 | # prepare the build in a separate layer
383+
60 | >>> RUN make clean build/prepare
384+
61 | # compile separately to optimize multi-platform builds
385+
62 | RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} make build/compile
386+
--------------------
387+
ERROR: failed to solve: process "/bin/sh -c make clean build/prepare" did not complete successfully: exit code: 2
388+
make[1]: *** [image/build] Error 1
389+
make: *** [deploy-latest-mr] Error 2
390+
```
391+
To solve it, you can try launching `colima` with these settings:
392+
```
393+
colima start --cpu 6 --memory 16 --profile docker --arch aarch64 --vm-type=vz --vz-rosetta
394+
```
366395

367396
<!-- github-only -->

clients/python/tests/test_client.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,3 +997,53 @@ async def test_register_model_with_owner(client):
997997
assert rm.owner == model_params["owner"]
998998
assert (_get_rm := client.get_registered_model(name=model_params["name"]))
999999
assert _get_rm.owner == model_params["owner"]
1000+
1001+
1002+
@pytest.mark.e2e
1003+
async def test_register_model_with_s3_data_connection(client: ModelRegistry):
1004+
"""As a MLOps engineer I want to track a Model from an S3 bucket Data Connection"""
1005+
data_connection_name = "aws-connection-my-data-connection"
1006+
s3_bucket = "my-bucket"
1007+
s3_path = "my-path"
1008+
s3_endpoint = "https://minio-api.acme.org"
1009+
s3_region = "us-east-1"
1010+
1011+
# Create the S3 URI using the utility function
1012+
uri = utils.s3_uri_from(
1013+
path=s3_path,
1014+
bucket=s3_bucket,
1015+
endpoint=s3_endpoint,
1016+
region=s3_region
1017+
)
1018+
1019+
model_params = {
1020+
"name": "test_model",
1021+
"uri": uri,
1022+
"model_format_name": "onnx",
1023+
"model_format_version": "1",
1024+
"version": "v1.0",
1025+
"description": "The Model", # This will be set on the model version
1026+
"storage_key": data_connection_name,
1027+
"storage_path": s3_path
1028+
}
1029+
1030+
# Register the model with S3 connection details
1031+
rm = client.register_model(**model_params)
1032+
assert rm.id
1033+
1034+
# Get and verify the registered model
1035+
rm_by_name = client.get_registered_model(model_params["name"])
1036+
assert rm_by_name.id == rm.id
1037+
1038+
# Get and verify the model version
1039+
mv = client.get_model_version(model_params["name"], model_params["version"])
1040+
assert mv.description == "The Model"
1041+
assert mv.name == "v1.0"
1042+
1043+
# Get and verify the model artifact
1044+
ma = client.get_model_artifact(model_params["name"], model_params["version"])
1045+
assert ma.uri == uri
1046+
assert ma.model_format_name == "onnx"
1047+
assert ma.model_format_version == "1"
1048+
assert ma.storage_key == data_connection_name
1049+
assert ma.storage_path == s3_path

test/robot/UserStory.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ As a MLOps engineer I would like to store an owner for the RegisteredModel
100100
And Should be equal ${r["owner"]} My owner
101101

102102
As a MLOps engineer I want to track a Model from an S3 bucket Data Connection
103+
# MIGRATED TO test_register_model_with_s3_data_connection in pytest
103104
${data_connection_name} Set Variable aws-connection-my-data-connection
104105
${s3_bucket} Set Variable my-bucket
105106
${s3_path} Set Variable my-path

0 commit comments

Comments
 (0)