Skip to content

Conversation

mart-r
Copy link
Collaborator

@mart-r mart-r commented Aug 21, 2025

Adds method to load model card off disk without loading model pack (though this may include unzipping the archive).
Also adds a few simple tests for it.
And updates the test time model pack to a newer one (the old one was in an older format that didn't have the model card).

"""
# unpack if needed
if model_pack_path.endswith(".zip"):
model_pack_path = cls.attempt_unpack(model_pack_path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey as I've also got some interest in this

Instead of unpacking the whole zip, can you just pull the json out direct?

EG I have a 1GB zip but just need 10kb json right now, would prefer not doubling the storage usage in the cloud just to show model info

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be able to do that. My assumption was that if you're trying to access it, it's fine to unpack as well. But I'm sure I don't need to tell you what I do when I assume...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an option to do that, but disbaled by default.

Copy link
Collaborator

@alhendrickson alhendrickson Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's a fair assumption, it's a "nice to have one day, maybe never" ask from my side, probably bigger from the mlops side

For me - I want to deploy like 1000 instances of the service, but maybe I'm not sure exactly which instance has the model I want, so I could check the /info API first 1k times to find the right one. Right now from an service perspective, medcat is lazy loaded on the first process call, so would cool if /info didnt use any resources up.

I have no plan to really do this but in general it feels like it should be able to get info with minimal side effects.

Copy link
Member

@tomolopolis tomolopolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great thanks - lgtm!

return model_card
return json.dumps(model_card, indent=2, sort_keys=False)

@overload
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

purpose of @overload here rather than -> Union[str, ModelCard] as you've done in the impl?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for typing for the contracts. mypy needs to know that if as_dict=True, we get a ModelCard (i.e a TypedDict) and we get a str if as_dict=False .

If we didn't provide the @overload methods, mypy would always treat the return value as Union[str, ModelCard], even though the type is deterministic based on as_dict.

@mart-r mart-r merged commit dc4096f into main Aug 22, 2025
25 of 27 checks passed
@mart-r mart-r deleted the CU-869a2kpv0-add-method-for-model-card branch August 22, 2025 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants