Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modelcard for shadow models #833

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ads/aqua/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,19 @@ def get(self, model_id) -> "AquaModel":
if not artifact_path:
logger.debug("Failed to get artifact path from custom metadata.")

is_shadow_type = (
ds_model.freeform_tags.get(Tags.READY_TO_IMPORT.value, "false").upper()
== READY_TO_IMPORT_STATUS
)

aqua_model_atttributes = dict(
**self._process_model(ds_model, self.region),
project_id=ds_model.project_id,
model_card=str(
read_file(
file_path=f"{artifact_path}/{README}",
file_path=f"{artifact_path.rstrip('/')}/config/{README}"
if is_shadow_type
else f"{artifact_path.rstrip('/')}/{README}",
auth=self._auth,
)
),
Expand Down Expand Up @@ -873,6 +880,8 @@ def _create_model_catalog_entry(
if shadow_model
else {Tags.AQUA_TAG.value: "active", Tags.BASE_MODEL_CUSTOM.value: "true"}
)
# Remove `ready_to_import` tag that might get copied from service model.
tags.pop(Tags.READY_TO_IMPORT.value, None)
metadata = None
if shadow_model:
# Shadow model is a model in the service catalog that either has no artifacts but contains all the necessary metadata for deploying and fine tuning.
Expand Down
19 changes: 15 additions & 4 deletions tests/unitary/with_extras/aqua/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,17 @@ def test_get_foundation_models(
aqua_model = self.app.get(model_id=model_id)

mock_from_id.assert_called_with(model_id)
mock_read_file.assert_called_with(
file_path="oci://bucket@namespace/prefix/README.md",
auth=self.app._auth,
)

if foundation_model_type == "shadow":
mock_read_file.assert_called_with(
file_path="oci://bucket@namespace/prefix/config/README.md",
auth=self.app._auth,
)
else:
mock_read_file.assert_called_with(
file_path="oci://bucket@namespace/prefix/README.md",
auth=self.app._auth,
)

assert asdict(aqua_model) == {
"compartment_id": f"{ds_model.compartment_id}",
Expand Down Expand Up @@ -449,6 +456,7 @@ def test_import_shadow_model(
"license": "aqua-license",
"organization": "oracle",
"task": "text-generation",
"ready_to_import": "true",
}
ds_model = (
ds_model.with_compartment_id("test_model_compartment_id")
Expand Down Expand Up @@ -487,6 +495,9 @@ def test_import_shadow_model(
f"oci os object bulk-upload --src-dir {str(tmpdir)}/{hf_model} --prefix prefix/path/{hf_model}/ -bn aqua-bkt -ns aqua-ns --auth api_key --profile DEFAULT"
)
)
ds_freeform_tags.pop(
"ready_to_import"
) # The imported model should not have this tag
assert model.freeform_tags == {
"aqua_custom_base_model": "true",
**ds_freeform_tags,
Expand Down
Loading