Skip to content

Commit

Permalink
test: show s3_uri_from format in pure REST test (kubeflow#219)
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Mortari <matteo.mortari@gmail.com>
  • Loading branch information
tarilabs authored Jul 29, 2024
1 parent 2e98b81 commit bda3731
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/robot/MRkeywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,9 @@ I get ArtifactsByModelVersionID
Fail Not Implemented
END
RETURN ${result}


I use util s3_uri_from
[Arguments] ${path} ${bucket} ${endpoint} ${region}
${result}= s3_uri_from path=${path} bucket=${bucket} endpoint=${endpoint} region=${region}
RETURN ${result}
7 changes: 7 additions & 0 deletions test/robot/ModelRegistry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from model_registry.core import ModelRegistryAPIClient
from model_registry.types import ModelArtifact, ModelVersion, RegisteredModel
from robot.libraries.BuiltIn import BuiltIn
import model_registry.utils


def write_to_console(s):
Expand Down Expand Up @@ -33,6 +34,12 @@ async def upsert_model_artifact(
write_to_console(p)
return (await self.api.upsert_model_artifact(p, model_version_id)).id

def s3_uri_from(self, path, bucket, endpoint, region) -> str:
"""
Expose util to RobotFramework
"""
return model_registry.utils.s3_uri_from(path=path, bucket=bucket, endpoint=endpoint, region=region)


async def test():
demo_instance = ModelRegistry()
Expand Down
29 changes: 29 additions & 0 deletions test/robot/UserStory.robot
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,32 @@ As a MLOps engineer I would like to store an owner for the RegisteredModel
${r} Then I get RegisteredModelByID id=${rId}
And Should be equal ${r["description"]} Lorem ipsum dolor sit amet
And Should be equal ${r["owner"]} My owner

As a MLOps engineer I want to track a Model from an S3 bucket Data Connection
${data_connection_name} Set Variable aws-connection-my-data-connection
${s3_bucket} Set Variable my-bucket
${s3_path} Set Variable my-path
${s3_endpoint} Set Variable https://minio-api.acme.org
${s3_region} Set Variable us-east-1

Set To Dictionary ${registered_model} description=The Model name=${name}
Set To Dictionary ${model_version} description=The Version name=v1.0
${art_uri} I use util s3_uri_from path=${s3_path} bucket=${s3_bucket} endpoint=${s3_endpoint} region=${s3_region}
Set To Dictionary ${model_artifact} description=The Artifact uri=${art_uri} modelFormatName=onnx modelFormatVersion=1 storageKey=${data_connection_name} storagePath=${s3_path}
Log to console ${model_artifact}

${rId} Given I create a RegisteredModel payload=${registered_model}
${vId} And I create a child ModelVersion registeredModelID=${rId} payload=&{model_version}
${aId} And I create a child ModelArtifact modelversionId=${vId} payload=&{model_artifact}
${r} Then I get RegisteredModelByID id=${rId}
And Should be equal ${r["description"]} The Model
${r} Then I get ModelVersionByID id=${vId}
And Should be equal ${r["description"]} The Version
And Should be equal ${r["name"]} v1.0
${r} Then I get ModelArtifactByID id=${aId}
And Should be equal ${r["description"]} The Artifact
And Should be equal ${r["uri"]} s3://my-bucket/my-path?endpoint=https://minio-api.acme.org&defaultRegion=us-east-1
And Should be equal ${r["modelFormatName"]} onnx
And Should be equal ${r["modelFormatVersion"]} 1
And Should be equal ${r["storageKey"]} aws-connection-my-data-connection
And Should be equal ${r["storagePath"]} my-path

0 comments on commit bda3731

Please sign in to comment.